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
panic in featuregate if a requested feature is unknown #84865
Conversation
Checking for enablement of a feature that is not registered is a programming error. I'm generally in favor of this. Will be interesting to see what in CI complains about this. |
Surely it will all work fine.... |
/approve needs a release note, since this is consumable by external components |
38372ba
to
e8d91b3
Compare
/retest |
e8d91b3
to
5b9cb83
Compare
we agree on slack that the message is very clear. |
} | ||
}() | ||
|
||
ipv6DualStackEnabled = utilfeature.DefaultFeatureGate.Enabled(IPv6DualStack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it still possible to change the value? I don't understand how this can work, flags won't have been parsed while init functions are running?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, this can't be initialized in init. could make it a member of the Cloud struct and set it in NewCloud
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, yeah, I asked for that exact thing in my other comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where's @liggittlamp when you need him
@@ -104,6 +104,26 @@ const ( | |||
clusterNameKey = "kubernetes-cluster-name" | |||
) | |||
|
|||
var ( | |||
// ipv6DualStack allows overriding for unit testing. It's normally initialized from featuregates | |||
ipv6DualStackEnabled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it a member variable of something and set it on construction.
@@ -128,6 +132,10 @@ func setUnsetAlphaGates(known map[Feature]FeatureSpec, enabled map[Feature]bool, | |||
// Set, String, and Type implement pflag.Value | |||
var _ pflag.Value = &featureGate{} | |||
|
|||
// internalPackages are packages that ignored when creating a name for featureGates These packages are in the common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run-on sentence.
@@ -128,6 +132,10 @@ func setUnsetAlphaGates(known map[Feature]FeatureSpec, enabled map[Feature]bool, | |||
// Set, String, and Type implement pflag.Value | |||
var _ pflag.Value = &featureGate{} | |||
|
|||
// internalPackages are packages that ignored when creating a name for featureGates These packages are in the common | |||
// call chains, so they'd be low entropy names for reflectors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/low entropy/unhelpful/
... this way I don't have to debate with myself any more if "low" or "high" entropy is more technically correct
5b9cb83
to
46c17bd
Compare
comments addressed |
46c17bd
to
20c956c
Compare
func() { | ||
// this allows the code ot launch without featuregates defined. It is currently required for unit tests where the | ||
// featuregates are not registered. This is effectively coding by side effect and an explicit register should | ||
// be eventually created instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open a follow up issue for cloud-controller-manager/providers to resolve this?
// this allows the code ot launch without featuregates defined. It is currently required for unit tests where the | ||
// featuregates are not registered. This is effectively coding by side effect and an explicit register should | ||
// be eventually created instead. | ||
defer func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you split the NewCloud function so that test code doesn't have to execute this, do you still need to catch the panic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you split the NewCloud function so that test code doesn't have to execute this, do you still need to catch the panic?
And let it straight die instead? That's not consistent with existing behavior. I'm honestly unsure if this ever worked properly when it really ran. Are you sure you want to change behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And let it straight die instead?
Yup, that's the goal of the change, isn't it? :)
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, liggitt The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@khenidak This update makes the azure cloud provider require the definition of IPv6DualStack feature gate or it will fail with a message saying the featuregate is not defined. It can be defined as false (this is the default in the cloud-controller-manager). |
80cee5c
to
7d897d5
Compare
/retest |
1 similar comment
/retest |
return az, nil | ||
} | ||
|
||
// NewCloudWithoutFeatureGates returns a Cloud without trying to wire the feature gates. This is used by the unit tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Looks like it can't be made private, or I would definitely ask for that. Oh well.
/lgtm @khenidak If you run this cloud provider in alternative environments, you'll definitely want to take a look at this. |
/retest Review the full test history for this PR. Silence the bot with an |
featuregates.Enabled should not silently return false if a request feature is not registered. This PR updates the code to panic so that coding error is noticed at the point of usage instead of silently going down unexpected branches.
You get items like
/kind bug
/priority important-soon
@kubernetes/sig-api-machinery-bugs