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

fix: Remove crashOnFailureFetchingExpectations flag #3453

Conversation

David-Jaeyoon-Lee
Copy link
Contributor

@David-Jaeyoon-Lee David-Jaeyoon-Lee commented Jul 22, 2024

What this PR does / why we need it:
Remove the flag crashOnFailureFetchingExpectations.

Special notes for your reviewer:

@David-Jaeyoon-Lee David-Jaeyoon-Lee requested a review from a team as a code owner July 22, 2024 08:39
Signed-off-by: David-Jaeyoon-Lee <davjlee@google.com>
@David-Jaeyoon-Lee David-Jaeyoon-Lee force-pushed the davjlee/refactor/ready-tracker-flag branch from 979c50b to c340a30 Compare July 22, 2024 08:40
@codecov-commenter
Copy link

codecov-commenter commented Jul 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.08%. Comparing base (3350319) to head (0a818a0).
Report is 104 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (3350319) and HEAD (0a818a0). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3350319) HEAD (0a818a0)
unittests 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3453      +/-   ##
==========================================
- Coverage   54.49%   48.08%   -6.42%     
==========================================
  Files         134      219      +85     
  Lines       12329    14844    +2515     
==========================================
+ Hits         6719     7137     +418     
- Misses       5116     6903    +1787     
- Partials      494      804     +310     
Flag Coverage Δ
unittests 48.08% <100.00%> (-6.42%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The value of the flag is moot so we want to hide it from the user.

Signed-off-by: David-Jaeyoon-Lee <davjlee@google.com>
var crashOnFailureFetchingExpectations = flag.Bool("crash-on-failure-fetching-expectations", false, "Unless set (defaults to false), gatekeeper will ignore errors when gathering expectations. This prevents bootstrapping errors from crashing Gatekeeper at the cost of increasing the risk Gatekeeper will under-enforce policy. Enabling this will help prevent under-enforcement at the risk of crashing during startup. Note that enabling this flag currently does not achieve the aforementioned effect since fetching expectations will retry until success.")
// Commenting out the flag and replacing with a false boolean constant because the value of the flag is currently moot without a retry limit
// var crashOnFailureFetchingExpectations = flag.Bool("crash-on-failure-fetching-expectations", false, "Unless set (defaults to false), gatekeeper will ignore errors when gathering expectations. This prevents bootstrapping errors from crashing Gatekeeper at the cost of increasing the risk Gatekeeper will under-enforce policy. Enabling this will help prevent under-enforcement at the risk of crashing during startup. Note that enabling this flag currently does not achieve the aforementioned effect since fetching expectations will retry until success.")
const crashOnFailureFetchingExpectations = false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do &false. I could do something like
var falseValue = false
var crashOnFailureFetchingExpectations = &falseValue, but seemed unnecessary

@@ -90,7 +91,8 @@ type Tracker struct {

// NewTracker creates a new Tracker and initializes the internal trackers.
func NewTracker(lister Lister, mutationEnabled, externalDataEnabled, expansionEnabled bool) *Tracker {
return newTracker(lister, mutationEnabled, externalDataEnabled, expansionEnabled, *crashOnFailureFetchingExpectations, nil, nil)
// Dereference crashOnFailureFetchingExpectations when we change crashOnFailureFetchingExpectations back to a flag
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a result of how I set crashOnFailureFetchingExpectations above, I added a comment to change this when we switch back to a flag, but maybe I need to add a TODO? not sure if just a comment is sufficient. @maxsmythe

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO as a comment and open issue to track so we remember to add the flag back would be great!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Is a plain TODO sufficient or is there a way to reference/embed an issue to it. Here is the issue I created: #3460

ritazh and others added 3 commits July 23, 2024 23:43
When we support retry count on fetching expectations we want to expose the
crashOnFailureFetchingExpectations as a flag instead of a constant.

Signed-off-by: David-Jaeyoon-Lee <davjlee@google.com>
@ritazh ritazh changed the title refactor: Shorten message for crashOnFailureFetchingExpectations flag Remove crashOnFailureFetchingExpectations flag Jul 24, 2024
@ritazh ritazh changed the title Remove crashOnFailureFetchingExpectations flag fix: Remove crashOnFailureFetchingExpectations flag Jul 24, 2024
Copy link
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ritazh ritazh added this to the v3.17.0 milestone Jul 24, 2024
Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maxsmythe maxsmythe merged commit 9fff28f into open-policy-agent:master Jul 30, 2024
19 checks passed
Ankurk99 pushed a commit to Ankurk99/gatekeeper that referenced this pull request Aug 1, 2024
…t#3453)

Signed-off-by: David-Jaeyoon-Lee <davjlee@google.com>
Co-authored-by: Rita Zhang <rita.z.zhang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants