Opened 3 months ago

Closed 2 months ago

#31305 closed defect (fixed)

Add more useful logging to fallback scripts variable config

Reported by: teor Owned by: teor
Priority: Medium Milestone:
Component: Core Tor/Fallback Scripts Version:
Severity: Normal Keywords: fallback, 043-should
Cc: teor Actual Points: 0.3
Parent ID: #30971 Points: 0.1
Reviewer: nickm Sponsor:

Description

In #29100, nickm says:

As a followup, I suggest changing the definition of getvar_conf() so that on error, it gives a more useful explaining what the problem is, and changing the definition of opt() so that it turns the empty string and/or a missing option into None, but reports errors otherwise.

Child Tickets

Change History (4)

comment:1 Changed 3 months ago by teor

Keywords: 043-should added
Parent ID: #29100#30971

We should fix these logging issues in 0.4.3, or the next time we do a fallback scripts update.

comment:2 Changed 3 months ago by teor

Actual Points: 0.3
Points: 0.1
Reviewer: nickm
Status: assignedneeds_review

See my pull request:
https://github.com/torproject/fallback-scripts/pull/7

This fix was a bit more complicated than I expected, because python's default bool conversion accepts any string.

This is the improved error output:

int

$ TOR_FB_REASONABLY_LIVE_TIME="bad-int" ./updateFallbackDirs.py
ERROR::Could not cast env var "TOR_FB_REASONABLY_LIVE_TIME" using function "<type 'int'>" and default "86400". ValueError: "invalid literal for int() with base 10: 'bad-int'"
Exit 1

int, optional=True

$ TOR_FB_MAX_FALLBACK_COUNT=bad-int ./updateFallbackDirs.py
ERROR::Could not cast optional env var value "bad-int" using function "<type 'int'>". ValueError: "invalid literal for int() with base 10: 'bad-int'"
ERROR::Could not cast env var "TOR_FB_MAX_FALLBACK_COUNT" using function "<function opt_type_fn at 0x106ebab90>" and default "200". ValueError: "invalid literal for int() with base 10: 'bad-int'"
Exit 1

bool

$ TOR_FB_PERFORM_IPV4_DIRPORT_CHECKS="bad-bool" ./updateFallbackDirs.py
ERROR::Could not cast env var "TOR_FB_PERFORM_IPV4_DIRPORT_CHECKS" using function "<function custom_bool at 0x1014dab18>" and default "True". ValueError: "invalid literal for custom_bool(): 'bad-bool', default_val: 'True', var_name: 'TOR_FB_PERFORM_IPV4_DIRPORT_CHECKS'"
Exit 1

bool, optional
I temporarily added a TOR_FB_TEST_BOOL_OPT variable for testing

$ TOR_FB_TEST_BOOL_OPT="bad-bool" ./updateFallbackDirs.py
ERROR::Could not cast optional env var value "bad-bool" using function "<function custom_bool at 0x10257ab90>". ValueError: "invalid literal for custom_bool(): 'bad-bool', default_val: 'True', var_name: 'TOR_FB_TEST_BOOL_OPT'"
ERROR::Could not cast env var "TOR_FB_TEST_BOOL_OPT" using function "<function opt_type_fn at 0x10257ac08>" and default "True". ValueError: "invalid literal for custom_bool(): 'bad-bool', default_val: 'True', var_name: 'TOR_FB_TEST_BOOL_OPT'"
Exit 1

comment:3 Changed 2 months ago by nickm

Status: needs_reviewmerge_ready

This looks plausible to me. Let's merge it and see if we want to iterate.

comment:4 Changed 2 months ago by teor

Resolution: fixed
Status: merge_readyclosed

Merged as ba94afc.

Note: See TracTickets for help on using tickets.