This is an automated email from the git hooks/post-receive script.
praiskup pushed a commit to branch main
in repository copr/copr.
commit 21701e00f86bbef421ddd6a1b75b91d6e1d4cd5a
Author: Jakub Kadlcik <frostyx(a)email.cz>
AuthorDate: Tue Aug 9 23:40:30 2022 +0200
backend: add option for infinite number of attempts to the hitcounter script
I don't think this will be useful in production for two reasons. We
don't want to use this option for cron tasks. Also, in production,
once we process an access file, we delete it from S3. Therefore
re-running the script won't count anything twice nor waste any time
with already counted files.
But this option is useful when debugging. I don't want the script to
die after hours of counting accesses that would be counted again when
re-running the script.
---
backend/copr_backend/hitcounter.py | 9 +++++++--
backend/run/copr-aws-s3-hitcounter | 9 ++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/backend/copr_backend/hitcounter.py b/backend/copr_backend/hitcounter.py
index 1c53ebd2..2a2e0327 100644
--- a/backend/copr_backend/hitcounter.py
+++ b/backend/copr_backend/hitcounter.py
@@ -59,7 +59,7 @@ def url_to_key_strings(url):
return []
-def update_frontend(accesses, log, dry_run=False):
+def update_frontend(accesses, log, dry_run=False, try_indefinitely=False):
"""
Increment frontend statistics based on these `accesses`
"""
@@ -86,7 +86,12 @@ def update_frontend(accesses, log, dry_run=False):
"from_backend",
)
if not dry_run:
- SafeRequest(auth=opts.frontend_auth, log=log).post(url, result)
+ request = SafeRequest(
+ auth=opts.frontend_auth,
+ log=log,
+ try_indefinitely=try_indefinitely,
+ )
+ request.post(url, result)
def get_hit_data(accesses, log):
diff --git a/backend/run/copr-aws-s3-hitcounter b/backend/run/copr-aws-s3-hitcounter
index 8b795ae2..f7031f4b 100755
--- a/backend/run/copr-aws-s3-hitcounter
+++ b/backend/run/copr-aws-s3-hitcounter
@@ -141,6 +141,12 @@ def get_arg_parser():
"--verbose",
action="store_true",
help=("Print verbose information about what is going on"))
+ parser.add_argument(
+ "--try-indefinitely",
+ action="store_true",
+ help=("If true, try infinite number of attempts when contacting the "
+ "frontend. Do not use this option for cron tasks because the "
+ "number of simultaneously running instances might go up"))
return parser
@@ -170,7 +176,8 @@ def main():
# a scenario when we increment the accesses on the frontend but then
# leave the s3 file untouched, which would result in parsing and
# incrementing from the same file again in the next run
- update_frontend(accesses, log=log, dry_run=args.dry_run)
+ update_frontend(accesses, log=log, dry_run=args.dry_run,
+ try_indefinitely=args.try_indefinitely)
s3.delete_file(s3file)
# Clean all temporary files
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.