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

Bug 2035903: handle resources with feature-gate annotation #444

Merged
merged 2 commits into from
Jan 21, 2022

Conversation

joelddiaz
Copy link
Contributor

@joelddiaz joelddiaz commented Jan 17, 2022

First commit disables processing of resources with feature-gate annotation.

Second commit adds new --enable-tech-preview parameter which allows tech-preview-annotated resources through. Adds several test cases to cover it.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 17, 2022
@joelddiaz joelddiaz changed the title ignore resources with feature-gate annotation Bug 2035903: ignore resources with feature-gate annotation Jan 17, 2022
@openshift-ci openshift-ci bot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Jan 17, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 17, 2022

@joelddiaz: This pull request references Bugzilla bug 2035903, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @lwan-wanglin

In response to this:

Bug 2035903: ignore resources with feature-gate annotation

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.

@joelddiaz
Copy link
Contributor Author

/assign @akhil-rane
FWIW, we'll ignore-by-default (given the present uncertainty with how to future-proof our CLI parameters), but someone really motivated will always be able to remove the annotation before asking ccoctl to process the extracted CredentialsRequests.

@codecov
Copy link

codecov bot commented Jan 17, 2022

Codecov Report

Merging #444 (4a2c157) into master (238bd0e) will decrease coverage by 0.04%.
The diff coverage is 43.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #444      +/-   ##
==========================================
- Coverage   45.79%   45.74%   -0.05%     
==========================================
  Files          92       92              
  Lines        9314     9336      +22     
==========================================
+ Hits         4265     4271       +6     
- Misses       4541     4556      +15     
- Partials      508      509       +1     
Impacted Files Coverage Δ
pkg/cmd/provisioning/alibabacloud/alibaba.go 0.00% <ø> (ø)
pkg/cmd/provisioning/aws/aws.go 0.00% <ø> (ø)
pkg/cmd/provisioning/aws/create_all.go 0.00% <0.00%> (ø)
pkg/cmd/provisioning/gcp/create_all.go 0.00% <0.00%> (ø)
pkg/cmd/provisioning/gcp/gcp.go 0.00% <ø> (ø)
pkg/cmd/provisioning/ibmcloud/ibmcloud.go 0.00% <ø> (ø)
...kg/cmd/provisioning/gcp/create_service_accounts.go 52.97% <33.33%> (-0.88%) ⬇️
.../cmd/provisioning/alibabacloud/create-ram-users.go 38.58% <40.00%> (-0.43%) ⬇️
pkg/cmd/provisioning/aws/create-iam-roles.go 61.32% <40.00%> (-0.59%) ⬇️
pkg/cmd/provisioning/ibmcloud/create_service_id.go 43.75% <50.00%> (-0.56%) ⬇️
... and 4 more

// featureGateAnnotation is the annotation used to indicate that a specific manifest is hidden behind a feature gate.
featureGateAnnotation = "release.openshift.io/feature-gate"
// validTechPreviewAnnotationValue is the only valid value for the feature-gate annoation
validTechPreviewAnnotationValue = "TechPreviewNoUpgrade"
Copy link
Member

Choose a reason for hiding this comment

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

You can use configv1.TechPreviewNoUpgrade instead of defining your own variable for this.

cloud-credential-operator $ git --no-pager grep TechPreviewNoUpgrade
vendor/github.com/openshift/api/config/v1/types_feature.go:     // TechPreviewNoUpgrade turns on tech preview features that are not part of the normal supported platform. Turning
vendor/github.com/openshift/api/config/v1/types_feature.go:     TechPreviewNoUpgrade FeatureSet = "TechPreviewNoUpgrade"
vendor/github.com/openshift/api/config/v1/types_feature.go:     TechPreviewNoUpgrade: newDefaultFeatures().

@lwan-wanglin
Copy link

@joelddiaz Whether there is a way to not extract such CredentialsRequests when running oc adm release extract --credentials-requests ? otherwise we need to document such case, we support both manual and manual+sts mode, if we only fix ccoctl, we need to tell the customer don't create secret manifests for such CRs when cco in manual mode, am I right?

log.Printf("CredentialsRequests %s/%s has unexpected feature-gate value", cr.Namespace, cr.Name)

}
log.Printf("Ignoring CredentialsRequest %s/%s with tech-preview annotation", cr.Namespace, cr.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will make it impossible for users to bootstrap a cluster as a TechPreviewNoUpgrade cluster on certain platforms right? I think this will break a number of release informing jobs and QE scenarios as we, as an org, decided a while back, bootstrapping as a TPNU cluster should be supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can just take a new CLI parameter to opt into processing these annotated manifests.

@joelddiaz joelddiaz changed the title Bug 2035903: ignore resources with feature-gate annotation Bug 2035903: handle resources with feature-gate annotation Jan 19, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 19, 2022

@joelddiaz: This pull request references Bugzilla bug 2035903, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @lwan-wanglin

In response to this:

Bug 2035903: handle resources with feature-gate annotation

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.

}

// Ingore CredentialsRequest with the feature-gate annotation
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Ingore CredentialsRequest with the feature-gate annotation
// Ignore CredentialsRequest with the feature-gate annotation

@@ -59,7 +59,8 @@ func deleteServiceIDCmd(cmd *cobra.Command, args []string) error {

func deleteServiceIDs(client ibmcloud.Client, accountID, name, credReqDir string, force bool) error {
// Process directory
credReqs, err := provisioning.GetListOfCredentialsRequests(credReqDir)
// (always tech-preview==true because we should do a full cleanup to be on the safe side)
Copy link
Contributor

Choose a reason for hiding this comment

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

why brackets () ?

Suggested change
// (always tech-preview==true because we should do a full cleanup to be on the safe side)
// always tech-preview==true because we should do a full cleanup to be on the safe side

if credreq.Annotations == nil {
credreq.Annotations = map[string]string{}
}
credreq.Annotations[featureGateAnnotation] = "TechPreviewNoUpgrade"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
credreq.Annotations[featureGateAnnotation] = "TechPreviewNoUpgrade"
credreq.Annotations[featureGateAnnotation] = configv1.TechPreviewNoUpgrade

Comment on lines +182 to +193
if value, ok := cr.Annotations[featureGateAnnotation]; ok {
if !enableTechPreview {
log.Printf("Ignoring CredentialsRequest %s/%s with tech-preview annotation", cr.Namespace, cr.Name)
continue
}
if value != string(configv1.TechPreviewNoUpgrade) {
log.Printf("Ignoring CredentialsRequest %s/%s with tech-preview value %s", cr.Namespace, cr.Name, value)
continue
} // else allow it to be added it to the list of CredReqs to process
}

credRequests = append(credRequests, cr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ignore a CredentialsRequest if featureGateAnnotation value is not equal to TechPreviewNoUpgrade?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's how I wrote it up. That is supposed to be an invalid value for the annotation and undefined. So just log it and move on...

Comment on lines +181 to +191
// Handle CredentialsRequest with the feature-gate annotation
if value, ok := cr.Annotations[featureGateAnnotation]; ok {
if !enableTechPreview {
log.Printf("Ignoring CredentialsRequest %s/%s with tech-preview annotation", cr.Namespace, cr.Name)
continue
}
if value != string(configv1.TechPreviewNoUpgrade) {
log.Printf("Ignoring CredentialsRequest %s/%s with tech-preview value %s", cr.Namespace, cr.Name, value)
continue
} // else allow it to be added it to the list of CredReqs to process
}
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, first we should check if featureGateAnnotation value is equal to TechPreviewNoUpgrade and then check if tech preview is enabled?

Suggested change
// Handle CredentialsRequest with the feature-gate annotation
if value, ok := cr.Annotations[featureGateAnnotation]; ok {
if !enableTechPreview {
log.Printf("Ignoring CredentialsRequest %s/%s with tech-preview annotation", cr.Namespace, cr.Name)
continue
}
if value != string(configv1.TechPreviewNoUpgrade) {
log.Printf("Ignoring CredentialsRequest %s/%s with tech-preview value %s", cr.Namespace, cr.Name, value)
continue
} // else allow it to be added it to the list of CredReqs to process
}
// Handle CredentialsRequest with the feature-gate annotation
if value, ok := cr.Annotations[featureGateAnnotation]; ok {
if value != string(configv1.TechPreviewNoUpgrade) {
log.Printf("Ignoring CredentialsRequest %s/%s with release.openshift.io/feature-gate annotation value %s", cr.Namespace, cr.Name, value)
continue
}
if !enableTechPreview {
log.Printf("Ignoring CredentialsRequest %s/%s with release.openshift.io/feature-gate annotation value %s", cr.Namespace, cr.Name, configv1.TechPreviewNoUpgrade)
continue
}
// else allow it to be added to the list of CredentialsRequests to process
}

Cannot assume that a feature is enabled, and should not process them by
default. We can revisit properly handling them going forward, but for
now keep ccoctl from processing optional resources by default.
@joelddiaz
Copy link
Contributor Author

/test e2e-aws-manual-oidc-sts

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 19, 2022

@joelddiaz: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test coverage
  • /test e2e-aws
  • /test e2e-upgrade
  • /test images
  • /test unit
  • /test verify
  • /test verify-deps

The following commands are available to trigger optional jobs:

  • /test e2e-aws-manual-oidc
  • /test e2e-azure
  • /test e2e-azure-upgrade
  • /test e2e-gcp
  • /test e2e-gcp-manual-oidc
  • /test e2e-openstack
  • /test e2e-openstack-parallel

Use /test all to run the following jobs that were automatically triggered:

  • pull-ci-openshift-cloud-credential-operator-master-coverage
  • pull-ci-openshift-cloud-credential-operator-master-e2e-aws
  • pull-ci-openshift-cloud-credential-operator-master-e2e-upgrade
  • pull-ci-openshift-cloud-credential-operator-master-images
  • pull-ci-openshift-cloud-credential-operator-master-unit
  • pull-ci-openshift-cloud-credential-operator-master-verify
  • pull-ci-openshift-cloud-credential-operator-master-verify-deps

In response to this:

/test e2e-aws-manual-oidc-sts

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.

@joelddiaz
Copy link
Contributor Author

/test e2e-aws-manual-oidc

@joelddiaz
Copy link
Contributor Author

/retest

1 similar comment
@akhil-rane
Copy link
Contributor

/retest

@@ -103,6 +104,7 @@ func NewCreateAllCmd() *cobra.Command {
createAllCmd.PersistentFlags().StringVar(&CreateAllOpts.CredRequestDir, "credentials-requests-dir", "", "Directory containing files of CredentialsRequests to create IAM Roles for (can be created by running 'oc adm release extract --credentials-requests --cloud=aws' against an OpenShift release image)")
createAllCmd.MarkPersistentFlagRequired("credentials-requests-dir")
createAllCmd.PersistentFlags().StringVar(&CreateAllOpts.TargetDir, "output-dir", "", "Directory to place generated files (defaults to current directory)")
createAllCmd.PersistentFlags().BoolVar(&CreateAllOpts.EnableTechPreview, "--enable-tech-preview", false, "Opt into processing CredentialsRequests marked as tech-preview")

Choose a reason for hiding this comment

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

@joelddiaz "--enable-tech-preview" unnecessary --

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the -- is unnecessary. Pushed an update to the PR. Thanks!

This new parameter will allow ccoctl to either include or exclude any
CredentialsRequest that is is processing based on the presence/value of
the tech-preview annotation.

Add some sanity checking that will ignore a CredReq with the
tech-preview annotation, but with an unexpected value.

Add test cases to cover the GetListOfCredentialsRequests function, and
introduce a new test pattern for building resources that are needed for
testing.
Copy link
Contributor

@akhil-rane akhil-rane left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akhil-rane, joelddiaz

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:
  • OWNERS [akhil-rane,joelddiaz]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2022

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

@openshift-merge-robot openshift-merge-robot merged commit 85a406b into openshift:master Jan 21, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2022

@joelddiaz: All pull requests linked via external trackers have merged:

Bugzilla bug 2035903 has been moved to the MODIFIED state.

In response to this:

Bug 2035903: handle resources with feature-gate annotation

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.

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/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants