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-372: Azure Workload Identity info in CredsRequests creates a Secret #587

Merged
merged 1 commit into from Nov 29, 2023

Conversation

bentito
Copy link
Contributor

@bentito bentito commented Aug 2, 2023

Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

pkg/azure/actuator_test.go should get a review for changes that were needed to pre-existing unit tests. The changes were needed because of the requirements of the new detection for Workload Identity in-use flow.

Known issues:

  • - Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
    * Reviewed the several bug fix PRs against the AWS STS work, most fixes were in credentialsrequest_controller so their all present for this Azure branch as well, just OCPBUGS-16684 had an actuator change that seemed to be needed here.
  • - This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow
    * PR to add calling make target to azure e2e is here: Add cmd make test-e2e-azident to e2e-azure-manual-oidc release#42126

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 2, 2023
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 2, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test (and unit tests eventually).

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.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 2, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 2, 2023
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 8, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

Known issue: Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.

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.

@bentito bentito marked this pull request as ready for review August 8, 2023 06:42
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2023
@openshift-ci openshift-ci bot requested review from abutcher and dlom August 8, 2023 06:43
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 8, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

Known issues:

  • Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
  • This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow

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.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 8, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

pkg/azure/actuator_test.go should get a review for changes that were needed to pre-existing unit tests. The changes were needed because of the requirements of the new detection for Workload Identity in-use flow.

Known issues:

  • Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
  • This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow

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.

@bentito bentito changed the title CCO-372: Azure Workload Identity info in CredsRequests creates a Secret CCO-372: WIP: Azure Workload Identity info in CredsRequests creates a Secret Aug 8, 2023
@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Merging #587 (7c970c7) into master (5a6da9c) will increase coverage by 0.06%.
Report is 4 commits behind head on master.
The diff coverage is 68.75%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #587      +/-   ##
==========================================
+ Coverage   47.90%   47.96%   +0.06%     
==========================================
  Files          96       96              
  Lines       11680    11737      +57     
==========================================
+ Hits         5595     5630      +35     
- Misses       5465     5483      +18     
- Partials      620      624       +4     
Files Coverage Δ
...redentialsrequest/credentialsrequest_controller.go 48.78% <0.00%> (ø)
pkg/azure/actuator.go 60.97% <69.62%> (+7.27%) ⬆️

... and 3 files with indirect coverage changes

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 9, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

pkg/azure/actuator_test.go should get a review for changes that were needed to pre-existing unit tests. The changes were needed because of the requirements of the new detection for Workload Identity in-use flow.

Known issues:

  • - Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
    • Reviewed the several bug fix PRs against the AWS STS work, most fixes were in credentialsrequest_controller so their all present for this Azure branch as well, just OCPBUGS-16684 had an actuator change that seemed to be needed here.
  • - This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow

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.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 9, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

pkg/azure/actuator_test.go should get a review for changes that were needed to pre-existing unit tests. The changes were needed because of the requirements of the new detection for Workload Identity in-use flow.

Known issues:

  • - Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
    • Reviewed the several bug fix PRs against the AWS STS work, most fixes were in credentialsrequest_controller so their all present for this Azure branch as well, just OCPBUGS-16684 had an actuator change that seemed to be needed here.
  • - This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow

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.

@bentito
Copy link
Contributor Author

bentito commented Aug 9, 2023

/retest e2e-hypershift

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 9, 2023

@bentito: The /retest command does not accept any targets.
The following commands are available to trigger required jobs:

  • /test coverage
  • /test e2e-aws-ovn
  • /test e2e-hypershift
  • /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-manual-oidc
  • /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-ovn
  • pull-ci-openshift-cloud-credential-operator-master-e2e-hypershift
  • 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:

/retest e2e-hypershift

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.

@bentito
Copy link
Contributor Author

bentito commented Aug 9, 2023

/test e2e-hypershift

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 9, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

pkg/azure/actuator_test.go should get a review for changes that were needed to pre-existing unit tests. The changes were needed because of the requirements of the new detection for Workload Identity in-use flow.

Known issues:

  • - Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
    • Reviewed the several bug fix PRs against the AWS STS work, most fixes were in credentialsrequest_controller so their all present for this Azure branch as well, just OCPBUGS-16684 had an actuator change that seemed to be needed here.
  • - This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow

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.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 9, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

pkg/azure/actuator_test.go should get a review for changes that were needed to pre-existing unit tests. The changes were needed because of the requirements of the new detection for Workload Identity in-use flow.

Known issues:

  • - Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
    • Reviewed the several bug fix PRs against the AWS STS work, most fixes were in credentialsrequest_controller so their all present for this Azure branch as well, just OCPBUGS-16684 had an actuator change that seemed to be needed here.
  • - This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow

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.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 9, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

WIP: Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

pkg/azure/actuator_test.go should get a review for changes that were needed to pre-existing unit tests. The changes were needed because of the requirements of the new detection for Workload Identity in-use flow.

Known issues:

  • - Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
    • Reviewed the several bug fix PRs against the AWS STS work, most fixes were in credentialsrequest_controller so their all present for this Azure branch as well, just OCPBUGS-16684 had an actuator change that seemed to be needed here.
  • - This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow

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.

@bentito
Copy link
Contributor Author

bentito commented Aug 9, 2023

/test e2e-hypershift

1 similar comment
@bentito
Copy link
Contributor Author

bentito commented Aug 9, 2023

/test e2e-hypershift

@bentito
Copy link
Contributor Author

bentito commented Aug 9, 2023

/test e2e-azure-manual-oidc

@bentito bentito changed the title CCO-372: WIP: Azure Workload Identity info in CredsRequests creates a Secret CCO-372: Azure Workload Identity info in CredsRequests creates a Secret Aug 9, 2023
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 9, 2023

@bentito: This pull request references CCO-372 which is a valid jira issue.

In response to this:

Adds Azure Workload Identity (Timed Access Token) support and e2e test and unit tests.

pkg/azure/actuator_test.go should get a review for changes that were needed to pre-existing unit tests. The changes were needed because of the requirements of the new detection for Workload Identity in-use flow.

Known issues:

  • - Still need to verify OCPBUGS filed against the AWS STS work, particularly around properly setting status, conditions and lastSync times that were fixed for AWS STS are not brought back here for Azure.
    • Reviewed the several bug fix PRs against the AWS STS work, most fixes were in credentialsrequest_controller so their all present for this Azure branch as well, just OCPBUGS-16684 had an actuator change that seemed to be needed here.
  • - This should be e2e testable with a PR in release which actually calls the new Make target: test-e2e-azident with the e2e-azure-manual-oidc workflow

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.

@bentito
Copy link
Contributor Author

bentito commented Aug 10, 2023

/test e2e-azure-manual-oidc

@bentito
Copy link
Contributor Author

bentito commented Aug 10, 2023

@abutcher we're running into trouble here with Azure that we didn't see on AWS:

With the error at runtime looking like:

time="2023-08-05T02:35:39Z" level=error msg="error checking whether credentials already exists: Secret \"azure-credentials\" not found" controller=credreq cr=openshift-cloud-credential-operator/nginx secret=default/nginx-credentials

There is certainly more logic in the non-STSDetected flow after the else before the .Exists() check, but I'm not sure what in it might need to be pulled up to the STS flow section? Any ideas?

@gallettilance
Copy link
Contributor

/test e2e-upgrade

@gallettilance
Copy link
Contributor

/test e2e-aws-ovn

@gallettilance
Copy link
Contributor

cred-req-secret-creationdeletion.webm

@jstuever here is a demo of the secret being created and deleted

@jstuever
Copy link
Contributor

/test e2e-azure e2e-azure-upgrade

@gallettilance
Copy link
Contributor

cred-req-workload-identity.webm

Update based on our convo @jstuever

  • no errors for "old" manual mode
  • updates of the secret to make it look exactly as the ccoctl tool does

Copy link
Contributor

@gallettilance gallettilance left a comment

Choose a reason for hiding this comment

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

Some notes for reviewers

return err
}
if credentialsMode == operatorv1.CloudCredentialsModeManual {
logger.Debug("running delete in manual mode")
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to reviewers: the delete works because of the annotation on the secret

return true, err
}
if credentialsMode == operatorv1.CloudCredentialsModeManual {
return true, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to reviewers: what's in the credReq should be the source of truth propagated down to the secret.

}
// Check for old Manual Mode where all 4 fields are empty - defaulting to old behavior
// where CCO exists and the secret is created manually
if azureProviderSpec.AzureClientID == "" && azureProviderSpec.AzureTenantID == "" && azureProviderSpec.AzureSubscriptionID == "" && azureProviderSpec.AzureRegion == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to reviewers: if none of the fields are provided, we assume the creator of the credReq is intending to use the old manual mode where the secrets are created by the ccoctl tool and CCO doesn't do anything (as is the case with openshift operators today).

if azureProviderSpec.AzureClientID == "" && azureProviderSpec.AzureTenantID == "" && azureProviderSpec.AzureSubscriptionID == "" && azureProviderSpec.AzureRegion == "" {
return nil
}
err = validateAzureProviderSpec(*azureProviderSpec)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to reviewers: if some but not all fields required for this new manual mode workload identity workflow are set then we should error

@@ -391,16 +460,24 @@ func (a *Actuator) syncCredentialSecrets(ctx context.Context, cr *minterv1.Crede
secret.Annotations = map[string]string{}
}
secret.Annotations[minterv1.AnnotationCredentialsRequest] = fmt.Sprintf("%s/%s", cr.Namespace, cr.Name)
if desiredSecret.Data == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to reviewers: this if statement checks that the desiredSecret is from the new manual mode workload identity workflow since it does not set the Data field

@@ -463,9 +509,31 @@ func TestActuator(t *testing.T) {
},
{
name: "Mint annotation",
expectedErr: fmt.Errorf("error determining whether a credentials update is needed"),
expectedErr: fmt.Errorf("unexpected value or missing cloudcredential.openshift.io/mode annotation on admin credentials Secret"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to reviewers: this change is a result of erroring earlier in the process as a result of checking for the cloudcredentials mode.

AzureResourcePrefix = "azure_resource_prefix"
AzureSubscriptionID = "azure_subscription_id"
AzureTenantID = "azure_tenant_id"
AzureFederatedTokenFile = "azure_federated_token_file"
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to reviewers: just adding the AzureFederatedTokenFile

@jstuever
Copy link
Contributor

/test e2e-azure e2e-azure-upgrade

return true, nil
}
if credentialsMode == operatorv1.CloudCredentialsModeMint {
return true, errors.New("mint mode is invalid")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this return false?

return true, err
}
if credentialsMode == operatorv1.CloudCredentialsModeManual {
return true, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, we would actually check if the secret differs from the source of truth similar to AWS mint mode. However, this can be taken away as tech debt.

@jstuever
Copy link
Contributor

/test e2e-azure
/test e2e-azure-upgrade

@jstuever
Copy link
Contributor

/test e2e-hypershift

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.

/lgtm
/approve

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

openshift-ci bot commented Nov 29, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bentito, jstuever

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 Nov 29, 2023
Copy link
Contributor

openshift-ci bot commented Nov 29, 2023

@bentito: 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-bot openshift-merge-bot bot merged commit e295bb2 into openshift:master Nov 29, 2023
12 checks passed
@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build ose-cloud-credential-operator-container-v4.15.0-202311300249.p0.ge295bb2.assembly.stream for distgit ose-cloud-credential-operator.
All builds following this will include this PR.

@gallettilance
Copy link
Contributor

/cherry-pick release-4.14

@openshift-cherrypick-robot

@gallettilance: new pull request created: #643

In response to this:

/cherry-pick release-4.14

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

None yet

7 participants