Skip to content

Commit

Permalink
src/timeout: only update nodes owned by the current user
Browse files Browse the repository at this point in the history
In order to avoid hitting issues with API permissions when updating
nodes that aren't owned by the current user, even with an admin API
token, ignore nodes that have a different owner to the current user
running the timeout service.

This is most likely a temporary measure until API permissions have
been fixed as the timeout service should in principle be able to
transition all nodes from all users.

Signed-off-by: Guillaume Tucker <[email protected]>
  • Loading branch information
gctucker committed Sep 4, 2023
1 parent a8b705c commit 173f52c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def __init__(self, configs, args, name):
state.value for state in self._api.node_states
if state != state.DONE
]
self._user = self._api.whoami()
self._username = self._user['profile']['username']

def _setup(self, args):
return {
Expand All @@ -39,7 +41,9 @@ def _get_pending_nodes(self, filters=None):
for state in self._pending_states:
node_filters['state'] = state
for node in self._api.get_nodes(node_filters):
nodes[node['id']] = node
# Until permissions for the timeout service are fixed:
if node['owner'] == self._username:
nodes[node['id']] = node
return nodes

def _count_running_child_nodes(self, parent_id):
Expand Down Expand Up @@ -89,6 +93,7 @@ def _check_pending_nodes(self, pending_nodes):
def _run(self, ctx):
self.log.info("Looking for nodes with lapsed timeout...")
self.log.info("Press Ctrl-C to stop.")
self.log.info(f"Current user: {self._username}")

while True:
pending_nodes = self._get_pending_nodes({
Expand Down

0 comments on commit 173f52c

Please sign in to comment.