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

CCO-318: Read feature gates for future usage #908

Merged
merged 7 commits into from
May 8, 2023

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Apr 11, 2023

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

@deads2k
Copy link
Contributor Author

deads2k commented Apr 12, 2023

/test all

@jstuever
Copy link
Contributor

/retest-required

@jstuever
Copy link
Contributor

jstuever commented Apr 18, 2023

/lgtm
I was able to use this PR in addition to #906 to read the AzureWorkloadIdentity featureGate and toggle relevant code paths as intended.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 18, 2023
@Miciah
Copy link
Contributor

Miciah commented Apr 18, 2023

/retitle CCO-318: Read feature gates for future usage

@openshift-ci openshift-ci bot changed the title read feature gates for future usage CCO-318: Read feature gates for future usage Apr 18, 2023
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 18, 2023
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Apr 18, 2023

@deads2k: This pull request references CCO-318 which is a valid jira issue.

In response to this:

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

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.

@jstuever
Copy link
Contributor

/retest-required

@deads2k
Copy link
Contributor Author

deads2k commented Apr 24, 2023

/retest

Copy link
Contributor

@Miciah Miciah left a 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?

Comment on lines +104 to +108
- clusterversions
verbs:
- get
- list
- watch
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Comment on lines -87 to +82
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 {
Copy link
Contributor

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.

Comment on lines -118 to -131
// 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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

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.
Copy link
Contributor

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.

Suggested change
// 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.

Comment on lines 122 to 124
klog.Infof("FeatureGates initialized: enabled=%v disabled=%v", enabled, disabled)
case <-time.After(1 * time.Minute):
klog.Errorf("timed out waiting for FeatureGate detection")
Copy link
Contributor

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?

Suggested change
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")

@deads2k deads2k force-pushed the use-feature-gates branch from 62206bb to 1f94fb3 Compare April 24, 2023 19:39
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 24, 2023
@deads2k
Copy link
Contributor Author

deads2k commented Apr 24, 2023

comments updated to be full sentences, switch to log, updated commit message.

@Miciah
Copy link
Contributor

Miciah commented Apr 25, 2023

Looks like you need a go mod tidy to remove the addition of k8s.io/klog/v2 to go.mod etc. that your latest changes obviated.

Copy link
Contributor

@jstuever jstuever left a 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.

@deads2k deads2k force-pushed the use-feature-gates branch from 1f94fb3 to dde23cc Compare April 27, 2023 20:14
@deads2k
Copy link
Contributor Author

deads2k commented Apr 27, 2023

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.

updated. The kcm-o and kas-o have already switched. The code remained the same, but the library-go changed underneath it.

}
// 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")
Copy link
Contributor

Choose a reason for hiding this comment

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

Ooh, generics!

@Miciah
Copy link
Contributor

Miciah commented Apr 27, 2023

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 27, 2023

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 27, 2023
@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2023

requires openshift/cluster-config-operator#301

@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2023

/test all

@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2023

infra Error: creating EC2 Instance: InsufficientInstanceCapacity: We currently do not have sufficient m6a.xlarge capacity in t

/retest

@deads2k deads2k force-pushed the use-feature-gates branch from 03ac3d9 to 3d26626 Compare May 3, 2023 20:16
@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2023

/retest

1 similar comment
@jstuever
Copy link
Contributor

jstuever commented May 4, 2023

/retest

@jstuever
Copy link
Contributor

jstuever commented May 4, 2023

/lgtm
This works as expected for #906

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 4, 2023
@jstuever jstuever removed their assignment May 4, 2023
@deads2k deads2k added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label May 8, 2023
@deads2k
Copy link
Contributor Author

deads2k commented May 8, 2023

related to the external CCM flow, so labeling so it'll merge.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 8, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants