Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to ignore the last execution of the repocleaner #2452

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-cleaner
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def parseArgs():
help='Number of parallel workers.')
parser.add_argument('--only-path-no-subdir', action='store_true', default=False, help='Set to true if the '
'only-path points to an object rather than a folder or if subdirectories must be ignored.')
parser.add_argument('--ignore-last-execution', dest='ignore_last_execution', action='store_true', default=False,
help='Do not check when was the last execution, run from timestamp 0.')
args = parser.parse_args()
dryable.set(args.dry_run)
logging.info(args)
Expand Down Expand Up @@ -183,7 +185,7 @@ def downloadConfigFromConsul(consul_url: str, consul_port: str, file_name: str):
logging.debug(f"config file from consul : \n{data['Value']}")
text = data["Value"].decode()
logging.debug(f"config file from consul : \n{text}")
path = "/tmp/repoCleanerConfig.yaml"
path = "/tmp/" + file_name
with open(path, 'w') as f:
f.write(text)
logging.info(f"Config path : {path}")
Expand Down Expand Up @@ -214,12 +216,16 @@ filepath = tempfile.gettempdir() + "/repoCleaner.txt"
currentTimeStamp = int(time.time() * 1000)


def getTimestampLastExecution():
def getTimestampLastExecution(ignore_last_execution: bool):
"""
Returns the timestamp of the last execution.
It is stored in a file in $TMP/repoCleaner.txt.
:return: the timestampe of the last execution or 0 if it cannot find it.
"""
if ignore_last_execution:
logging.info(f"Option ignore_last_execution set, we return 0 as timestamp.")
return 0

try:
f = open(filepath, "r")
except IOError as e:
Expand Down Expand Up @@ -371,7 +377,7 @@ def run(args, ccdb_url, rules):
ccdb.logger = logging.getLogger
ccdb.set_adjustable_eov = args.set_adjustableEOV
logging.info(f"ccdb.set_adjustable_eov: {ccdb.set_adjustable_eov}")
paths = ccdb.getObjectsList(getTimestampLastExecution(), args.only_path, args.only_path_no_subdir)
paths = ccdb.getObjectsList(getTimestampLastExecution(args.ignore_last_execution), args.only_path, args.only_path_no_subdir)
if args.only_path != '':
paths = [item for item in paths if item is not None and item.startswith(args.only_path)]
logging.debug(paths)
Expand Down
Loading