-
Notifications
You must be signed in to change notification settings - Fork 192
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
CCO-318: Read feature gates for future usage #908
CCO-318: Read feature gates for future usage #908
Conversation
8c71879
to
771cd17
Compare
338cd18
to
e51a8ae
Compare
/test all |
/retest-required |
/lgtm |
/retitle CCO-318: Read feature gates for future usage |
@deads2k: This pull request references CCO-318 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/retest-required |
/retest |
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.
Would you mind mentioning the Jira issue in the Git commit message?
- clusterversions | ||
verbs: | ||
- get | ||
- list | ||
- watch |
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.
I suppose this permission would be needed in the future for versioned featuregates, but why is it needed today?
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.
I suppose this permission would be needed in the future for versioned featuregates, but why is it needed today?
Because the informer is started to be code compatible with the update comes.
var fg configv1.FeatureGate | ||
if err := r.cache.Get(ctx, request.NamespacedName, &fg); err != nil { | ||
if apierrors.IsNotFound(err) { | ||
log.Info("featuregate not found; reconciliation will be skipped", "request", request) | ||
return reconcile.Result{}, nil | ||
} | ||
return reconcile.Result{}, err | ||
} | ||
|
||
if !featureIsEnabled(featureGateName, &fg) { | ||
if !r.config.GatewayAPIEnabled { |
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.
With this change, there isn't really a good reason for this controller to watch featuregates at all. However, it does make sense to have a control loop to retry creating a CRD when a create fails. In addition, we really do want to have the controller but have it reconcile customresourcedefinitions if they change (see https://issues.redhat.com/browse/NE-1273), so let's leave it as a followup to modify the controller to watch and reconcile customresourcedefinitions.
// featureIsEnabled takes a feature name and a featuregate config API object and | ||
// returns a Boolean indicating whether the named feature is enabled. | ||
// | ||
// This function determines whether a named feature is enabled as follows: | ||
// | ||
// - First, if the featuregate's spec.featureGateSelection.featureSet field is | ||
// set to "CustomNoUpgrade", then the feature is enabled if, and only if, it | ||
// is specified in spec.featureGateSelection.customNoUpgrade.enabled. | ||
// | ||
// - Second, if spec.featureGateSelection.featureSet is set to a value that | ||
// isn't defined in configv1.FeatureSets, then the feature is *not* enabled. | ||
// | ||
// - Finally, the feature is enabled if, and only if, the feature is specified | ||
// in configv1.FeatureSets[spec.featureGateSelection.featureSet].enabled. |
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.
Could this comment be preserved somewhere? It took me a bit of effort to work out from the features API documentation and Slack conversations what the logic is for enabling a feature.
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.
Could this comment be preserved somewhere? It took me a bit of effort to work out from the features API documentation and Slack conversations what the logic is for enabling a feature.
Spoke on slack. With the just-today-merged FeatureGate.Status, this comment is no longer pertinent. We'll update in two stages so ingress isn't a guinea pig, but we won't preserve this 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.
@Miciah I use featureIsEnabled
in my E2E tests and can preserve it there.
pkg/operator/operator.go
Outdated
desiredVersion := config.OperatorReleaseVersion | ||
missingVersion := statuscontroller.UnknownVersionValue | ||
|
||
// by default, this will exit(0) the process if the featuregates ever change to a different set of values. |
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.
I usually ask people to write full sentences in comments.
// by default, this will exit(0) the process if the featuregates ever change to a different set of values. | |
// By default, this will exit(0) the process if the featuregates ever change to a different set of values. |
pkg/operator/operator.go
Outdated
klog.Infof("FeatureGates initialized: enabled=%v disabled=%v", enabled, disabled) | ||
case <-time.After(1 * time.Minute): | ||
klog.Errorf("timed out waiting for FeatureGate detection") |
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 there a reason to use klog?
klog.Infof("FeatureGates initialized: enabled=%v disabled=%v", enabled, disabled) | |
case <-time.After(1 * time.Minute): | |
klog.Errorf("timed out waiting for FeatureGate detection") | |
log.Infof("FeatureGates initialized", "enabled", enabled, "disabled", disabled) | |
case <-time.After(1 * time.Minute): | |
log.Error(nil, "timed out waiting for FeatureGate detection") |
62206bb
to
1f94fb3
Compare
comments updated to be full sentences, switch to log, updated commit message. |
Looks like you need a |
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.
For this to be usable by #906, it will need to be updated to be compatible with a newer openshift/api to include the AzureWorkloadIdentity commit. As it stands now, #906 cannot use the newer api due to the addition of the featureGateName type. As a result, the changes in this PR are no longer compatible.
1f94fb3
to
dde23cc
Compare
updated. The kcm-o and kas-o have already switched. The code remained the same, but the library-go changed underneath it. |
pkg/operator/operator.go
Outdated
} | ||
// example of future featuregate read and usage to set a variable to pass to a controller | ||
_ = sets.New[configv1.FeatureGateName](enabled...).Has("AzureWorkloadIdentity") | ||
gatewayAPIEnabled := sets.New[configv1.FeatureGateName](enabled...).Has("GatewayAPI") |
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.
Ooh, generics!
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Miciah 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 |
/test all |
infra Error: creating EC2 Instance: InsufficientInstanceCapacity: We currently do not have sufficient m6a.xlarge capacity in t /retest |
/retest |
1 similar comment
/retest |
/lgtm |
related to the external CCM flow, so labeling so it'll merge. |
@deads2k: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
This is needed for the AzureWorkloadIdentity work (see #906), so adding the core featuregate access here.
When we eventually read featuregates from the cluster itself, this golang construct will remain the same.
/cc @abutcher @jstuever
/assign @Miciah