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

Setting FailureMode from ENV #1030

Merged
merged 3 commits into from
Nov 20, 2024
Merged

Setting FailureMode from ENV #1030

merged 3 commits into from
Nov 20, 2024

Conversation

didierofrivia
Copy link
Member

Closes #866

Reading the values from ENV, with the following defaults:

Auth => Deny
RateLimit => Allow

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 83.94%. Comparing base (cc1b41f) to head (161d965).
Report is 45 commits behind head on main.

Files with missing lines Patch % Lines
pkg/wasm/utils.go 66.66% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1030      +/-   ##
==========================================
+ Coverage   76.15%   83.94%   +7.78%     
==========================================
  Files         111       81      -30     
  Lines        8986     6694    -2292     
==========================================
- Hits         6843     5619    -1224     
+ Misses       1852      860     -992     
+ Partials      291      215      -76     
Flag Coverage Δ
bare-k8s-integration 15.73% <0.00%> (+4.85%) ⬆️
controllers-integration 76.37% <70.00%> (+17.51%) ⬆️
envoygateway-integration 40.79% <65.00%> (+8.29%) ⬆️
gatewayapi-integration 16.06% <0.00%> (+2.62%) ⬆️
istio-integration 43.74% <65.00%> (+9.41%) ⬆️
unit 18.12% <0.00%> (-7.24%) ⬇️

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

Components Coverage Δ
api/v1beta1 (u) 90.00% <100.00%> (-2.19%) ⬇️
api/v1beta2 (u) ∅ <ø> (∅)
pkg/common (u) ∅ <ø> (∅)
pkg/istio (u) 62.06% <ø> (+15.03%) ⬆️
pkg/log (u) 93.18% <ø> (ø)
pkg/reconcilers (u) 24.67% <ø> (∅)
pkg/rlptools (u) ∅ <ø> (∅)
controllers (i) 86.82% <90.18%> (+2.39%) ⬆️
Files with missing lines Coverage Δ
controllers/envoy_gateway_extension_reconciler.go 84.88% <100.00%> (+0.34%) ⬆️
controllers/istio_extension_reconciler.go 85.71% <100.00%> (+2.21%) ⬆️
pkg/wasm/utils.go 88.88% <66.66%> (+6.34%) ⬆️

... and 29 files with indirect coverage changes

---- 🚨 Try these New Features:

@eguzki eguzki added the kind/enhancement New feature or request label Nov 19, 2024
pkg/wasm/types.go Outdated Show resolved Hide resolved
Copy link
Member

@adam-cattermole adam-cattermole left a comment

Choose a reason for hiding this comment

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

Primarily just tests need fixing but otherwise looks good

case string(FailureModeAllow), string(FailureModeDeny):
return FailureModeType(value)
default:
fmt.Printf("Warning: Invalid value '%s' for %s. Using default value '%s'.\n", value, envVarName, defaultValue)
Copy link
Member

Choose a reason for hiding this comment

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

Seems slightly odd to use standard printing here instead of using a logger but I guess that's because it's not easy to get the logger here?

Copy link
Member Author

@didierofrivia didierofrivia Nov 19, 2024

Choose a reason for hiding this comment

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

Yup, I wanted to avoid having to create an instance of the logger just for this... but I could if desired.

Copy link
Member Author

Choose a reason for hiding this comment

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

I could also remove the message xD

Copy link
Member

Choose a reason for hiding this comment

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

I think it's nice to have the message at least to know that if you set it with a typo there's a reason why it's not being set.. but it's also going to look weird with interleaved Printf messages with the operator logs every time there's an event that triggers modification to the plugin that goes through this code. I don't want to hold up this PR though not a big issue

Copy link
Contributor

Choose a reason for hiding this comment

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

I would panic, it is wrong to have an invalid value

Copy link
Contributor

Choose a reason for hiding this comment

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

But happy to merge this as it is as well

Copy link
Member Author

@didierofrivia didierofrivia Nov 19, 2024

Choose a reason for hiding this comment

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

Take a look at 161d965, an alternative would be creating a different instance just for the logging that setting or leave it to fmt.Println

tests/envoygateway/extension_reconciler_test.go Outdated Show resolved Hide resolved
Copy link
Member

@adam-cattermole adam-cattermole left a comment

Choose a reason for hiding this comment

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

lgtm, verified and all appears to be working

@didierofrivia didierofrivia force-pushed the failure-mode branch 5 times, most recently from 57d6c8d to 3220fbd Compare November 19, 2024 17:38
Signed-off-by: dd di cesare <didi@posteo.net>
Signed-off-by: dd di cesare <didi@posteo.net>
Signed-off-by: dd di cesare <didi@posteo.net>
@didierofrivia didierofrivia merged commit b70d785 into main Nov 20, 2024
33 of 34 checks passed
@didierofrivia didierofrivia deleted the failure-mode branch November 20, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Expose Wasm failureMode setting
3 participants