Skip to content

Commit 393207b

Browse files
authored
bug: Fix the report args. (#987)
Due to a few last minute recommendations, the args fell out of sync. Taking the opportunity to fix up some of the arguments to make better lexicographic sense.
1 parent 20cf810 commit 393207b

File tree

1 file changed

+11
-33
lines changed

1 file changed

+11
-33
lines changed

scripts/reliability/reliability_report.py

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ async def terminal_snapshot(self) -> Dict[str, int]:
367367
self.log.info(
368368
f"🧹 Recording expired data: {term_counts} for {start_of_day}"
369369
)
370-
expiry = start_of_day + timedelta(days=self.settings.max_retention)
370+
expiry = start_of_day + timedelta(
371+
days=self.settings.terminal_max_retention_days
372+
)
371373
# Write the values to storage.
372374
await self.redis.zadd(
373375
self.settings.terminal_table,
@@ -430,24 +432,14 @@ def config(env_args: os._Environ = os.environ) -> argparse.Namespace:
430432

431433
parser.add_argument("-c", "--config", help="configuration_file", action="append")
432434

433-
parser.add_argument(
434-
"--db_dsn",
435-
"-b",
436-
help="Database DSN connection string",
437-
default=env_args.get(
438-
"AUTOEND__DB_DSN",
439-
env_args.get("AUTOCONNECT__DB_DSN", "grpc://localhost:8086"),
440-
),
441-
)
442-
443435
parser.add_argument(
444436
"--db_settings",
445437
"-s",
446438
help="Database settings",
447439
default=env_args.get(
448-
"AUTOEND__DB_SETTINGS",
440+
"AUTOCONNECT__DB_SETTINGS",
449441
env_args.get(
450-
"AUTOCONNECT__DB_SETTINGS",
442+
"AUTOEND__DB_SETTINGS",
451443
'{"message_family":"message","router_family":"router", "table_name":"projects/test/instances/test/tables/autopush"}',
452444
),
453445
),
@@ -459,12 +451,6 @@ def config(env_args: os._Environ = os.environ) -> argparse.Namespace:
459451
default=env_args.get("AUTOTRACK_FAMILY", RELIABILITY_FAMILY),
460452
)
461453

462-
parser.add_argument(
463-
"--bucket_name",
464-
help="GCP Storage Bucket name",
465-
default=env_args.get("AUTOTRACK_BUCKET_NAME"),
466-
)
467-
468454
parser.add_argument(
469455
"--bucket_retention_days",
470456
help="Number of days to retain generated reports in the Bucket",
@@ -485,8 +471,8 @@ def config(env_args: os._Environ = os.environ) -> argparse.Namespace:
485471
"-r",
486472
help="DSN to connect to the Redis like service.",
487473
default=env_args.get(
488-
"AUTOEND__RELIABILITY_DSN",
489-
env_args.get("AUTOCONNECT__RELIABILITY_DSN", "redis://localhost"),
474+
"AUTOCONNECT__RELIABILITY_DSN",
475+
env_args.get("AUTOEND__RELIABILITY_DSN", "redis://localhost"),
490476
),
491477
)
492478

@@ -525,18 +511,10 @@ def config(env_args: os._Environ = os.environ) -> argparse.Namespace:
525511
default=env_args.get("AUTOTRACK_TERM_MAX_RETENTION_DAYS", 1),
526512
)
527513

528-
parser.add_argument(
529-
"--report_max_retention_days",
530-
help="Number of days to retain reports in the reliability bucket",
531-
default=env_args.get("AUTOTRACK_REPORT_MAX_RETENTION_DAYS", 30),
532-
)
533-
534514
parser.add_argument(
535515
"--report_bucket_name",
536516
help="Name of the bucket to store reliability reports",
537-
default=env_args.get(
538-
"AUTOTRACK_REPORT_BUCKET_NAME", "autopush-dev-reliability"
539-
),
517+
default=env_args.get("AUTOTRACK_REPORT_BUCKET_NAME", "autopush-reliability"),
540518
)
541519

542520
parser.add_argument(
@@ -600,9 +578,9 @@ async def amain(log: logging.Logger, settings: argparse.Namespace):
600578
if await counter.get_lock():
601579
await counter.terminal_snapshot()
602580
# if we have a bucket to write to, write the reports to the bucket.
603-
if settings.bucket_name:
581+
if settings.report_bucket_name:
604582
client = storage.Client()
605-
bucket = client.lookup_bucket(bucket_name=settings.bucket_name)
583+
bucket = client.lookup_bucket(bucket_name=settings.report_bucket_name)
606584
if bucket:
607585
report_name = datetime.now().strftime("%Y-%m-%d")
608586
# technically, `bucket.list_blobs` can return `.num_results` but since this is
@@ -619,7 +597,7 @@ async def amain(log: logging.Logger, settings: argparse.Namespace):
619597
else:
620598
log.debug("Reports already generated, skipping...")
621599
# Maybe we're just interested in getting a report?
622-
if not settings.bucket_name:
600+
if not settings.report_bucket_name:
623601
for style in settings.output:
624602
print(await bigtable.output(style))
625603
print("\f")

0 commit comments

Comments
 (0)