Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbardino committed Jan 6, 2024
2 parents ae39e79 + 733066f commit 4a4aaaf
Show file tree
Hide file tree
Showing 2 changed files with 246 additions and 49 deletions.
19 changes: 14 additions & 5 deletions mig/server/cleansessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# --- BEGIN_HEADER ---
#
# cleansessions - Helper to clean up stale griddaemon session tracking entries
# Copyright (C) 2003-2023 The MiG Project lead by Brian Vinter
# Copyright (C) 2003-2024 The MiG Project lead by Brian Vinter
#
# This file is part of MiG.
#
Expand Down Expand Up @@ -36,7 +36,8 @@
import sys

from mig.shared.conf import get_configuration_object
from mig.shared.griddaemons.sessions import expire_dead_sessions
from mig.shared.griddaemons.sessions import expire_dead_sessions, \
expire_dead_sessions_chunked


def usage(name='cleansessions.py'):
Expand All @@ -46,6 +47,7 @@ def usage(name='cleansessions.py'):
Usage:
%(name)s [OPTIONS] [PROTO ...]
Where OPTIONS may be one or more of:
-c Use chunked clean up for big speed up with many sessions
-f Force operations to continue past errors
-h Show this help
-v Verbose output
Expand All @@ -57,10 +59,11 @@ def usage(name='cleansessions.py'):

if __name__ == '__main__':
args = None
chunked = False
force = False
verbose = False
username = None
opt_args = 'fhvu:'
opt_args = 'cfhvu:'
try:
(opts, args) = getopt.getopt(sys.argv[1:], opt_args)
except getopt.GetoptError as err:
Expand All @@ -69,7 +72,9 @@ def usage(name='cleansessions.py'):
sys.exit(1)

for (opt, val) in opts:
if opt == '-f':
if opt == '-c':
chunked = True
elif opt == '-f':
force = True
elif opt == '-h':
usage()
Expand All @@ -95,7 +100,11 @@ def usage(name='cleansessions.py'):
cleaned = []
configuration = get_configuration_object(skip_log=True)
for cur_proto in proto_list:
expired = expire_dead_sessions(configuration, cur_proto, username)
if chunked:
expired = expire_dead_sessions_chunked(configuration, cur_proto,
username)
else:
expired = expire_dead_sessions(configuration, cur_proto, username)
cleaned += list(expired)

if cleaned:
Expand Down
Loading

0 comments on commit 4a4aaaf

Please sign in to comment.