Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Scheduling Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xx network
Scheduling Scripts
Commits
cf00a61b
Commit
cf00a61b
authored
Jan 7, 2022
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Fix revoke to use stored IP, pass proper params to funcs
parent
83d65c90
No related branches found
No related tags found
1 merge request
!9
Remove truncate and add on conflict clause instead
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scheduling.py
+16
-12
16 additions, 12 deletions
scheduling.py
with
16 additions
and
12 deletions
scheduling.py
+
16
−
12
View file @
cf00a61b
...
...
@@ -71,7 +71,7 @@ def main():
auth_nids
=
set
()
current_bins
=
[]
current_chain_conf
=
{}
init_auth
=
get_authorizer_nodes
()
init_auth
=
get_authorizer_nodes
(
auth_conn
)
for
i
in
init_auth
:
auth_nids
.
add
(
i
[
0
])
while
True
:
...
...
@@ -103,9 +103,9 @@ def main():
new_auth_set
=
set
(
new_auth_nids
)
to_add
=
new_auth_set
.
difference
(
auth_nids
)
to_delete
=
auth_nids
.
difference
(
new_auth_set
)
set_authorizer_nodes
(
auth_conn
,
to_add
,
to_delete
)
auth_nids
=
new_auth_
nids
revoke_auth
(
to_
delet
e
)
to_revoke
=
set_authorizer_nodes
(
auth_conn
,
to_add
,
to_delete
)
auth_nids
=
new_auth_
set
revoke_auth
(
to_
revok
e
)
# Pass a copy because the dict will be mutated
set_active_nodes
(
conn
,
copy
.
deepcopy
(
new_dict
))
...
...
@@ -699,21 +699,24 @@ def set_authorizer_nodes(conn, to_add, to_delete):
:param conn: database connection object
:param to_add: list of node IDs to add
:param to_delete: list of node IDs to delete
:return
:
:return
list[ip_address]: list of IPs to revoke auth
"""
cur
=
conn
.
cursor
()
# Convert Node information into authorizer insert command
node_list
=
get_authorizer_nodes
(
conn
)
to_revoke
=
[]
delete_command
=
"
DELETE FROM nodes WHERE id = ?;
"
for
n
in
to_delete
:
for
row
in
node_list
:
if
row
[
0
]
in
to_delete
:
try
:
cur
.
execute
(
delete_command
,
(
n
,))
cur
.
execute
(
delete_command
,
(
row
[
0
]
,))
log
.
debug
(
cur
.
query
)
except
Exception
as
e
:
log
.
error
(
f
"
Failed to remove node from authorizer DB:
{
cur
.
query
}
"
)
raise
e
to_revoke
.
append
(
row
[
1
])
insert_list
=
[(
i
,
None
,
None
)
for
i
in
to_add
]
# Insert Node information into authorizer db
...
...
@@ -729,6 +732,7 @@ def set_authorizer_nodes(conn, to_add, to_delete):
raise
e
finally
:
cur
.
close
()
return
to_revoke
def
check_table
(
conn
,
table_name
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment