Skip to content

OCPBUGS-16313: pkg/operator: correctly fetch CA for AWS minter #575

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

Conversation

stevekuznetsov
Copy link
Contributor

We just need to read one and only one ConfigMap, so add a Role to let us and use a live client to just read the thing.

We just need to read *one* and only *one* ConfigMap, so add a Role to
let us and use a live client to just read the thing.

Signed-off-by: Steve Kuznetsov <[email protected]>
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 20, 2023
@openshift-ci-robot
Copy link
Contributor

@stevekuznetsov: This pull request references Jira Issue OCPBUGS-16313, which is invalid:

  • expected the bug to be in one of the following states: NEW, ASSIGNED, POST, but it is ON_QA instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

We just need to read one and only one ConfigMap, so add a Role to let us and use a live client to just read the thing.

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 openshift-ci bot requested review from 2uasimojo and lleshchi July 20, 2023 01:23
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #575 (48d6ccc) into master (798b771) will decrease coverage by 0.06%.
The diff coverage is 31.25%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #575      +/-   ##
==========================================
- Coverage   47.72%   47.66%   -0.06%     
==========================================
  Files          93       94       +1     
  Lines       11682    11696      +14     
==========================================
  Hits         5575     5575              
- Misses       5480     5494      +14     
  Partials      627      627              
Impacted Files Coverage Δ
pkg/operator/utils/client.go 0.00% <0.00%> (ø)
pkg/operator/secretannotator/aws/reconciler.go 44.91% <50.00%> (-0.39%) ⬇️
pkg/aws/actuator/actuator.go 63.75% <66.66%> (-0.08%) ⬇️

... and 1 file with indirect coverage changes

@stevekuznetsov
Copy link
Contributor Author

/retest

@abutcher
Copy link
Member

/lgtm

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

openshift-ci bot commented Jul 20, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abutcher, stevekuznetsov

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 Jul 20, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 20, 2023

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

@abutcher
Copy link
Member

/jira refresh

@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Jul 20, 2023
@openshift-ci-robot
Copy link
Contributor

@abutcher: This pull request references Jira Issue OCPBUGS-16313, which is valid. The bug has been moved to the POST state.

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

Requesting review from QA contact:
/cc @fxierh

In response to this:

/jira refresh

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 openshift-ci-robot removed the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Jul 20, 2023
@openshift-ci openshift-ci bot requested a review from fxierh July 20, 2023 14:52
@openshift-merge-robot openshift-merge-robot merged commit b5be125 into openshift:master Jul 20, 2023
@openshift-ci-robot
Copy link
Contributor

@stevekuznetsov: Jira Issue OCPBUGS-16313: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-16313 has been moved to the MODIFIED state.

In response to this:

We just need to read one and only one ConfigMap, so add a Role to let us and use a live client to just read the thing.

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.

wking added a commit to wking/cloud-credential-operator that referenced this pull request Jan 3, 2025
Even when awsSTSIAMRoleARN is empty, we want the label so that
pkg/cmd/operator's NewOperator's filteredWatchPossible label-selector
can find these Secrets.  Then the controller will notice if they're
deleted (so it can update the CredentialsRequest status to point that
out) or when they haven't been changed (so it can avoid "I can't find
the Secret!" overly-frequent bumping in the hasRecentlySynced
calculation, because it thinks crSecretExists=false).

And we want the annotation, so it's clear why the Secret needs to
exist (because of the annotation-referenced CredentialsRequest).

The risk here is that we might end up contending over label/annotation
presence with the external controller that is populating the
'credentials' data inside the Secret.  But the alternative of an
unfiltered Secret informer in the client is still too
resource-intensive, as described in the filteredWatchPossible comment
and the a58a09c (*: use a filtered LIST + WATCH on Secrets for AWS
STS, 2023-06-29, openshift#545) commit that added the filteredWatchPossible
logic.  Additional labels and annotations are properties that external
controllers should be able to accept.  For example, [1] has ArgoCD
discussing:

  apiVersion: argoproj.io/v1alpha1
  kind: ApplicationSet
  spec:
    # (...)
    preservedFields:
      annotations: ["my-custom-annotation"]
      labels: ["my-custom-label"]

to ignore annotations and labels injected by external-to-ArgoCD
controllers, which is what the CCO-specific annotation/label I'm
touching now would be.

Moving to 48d6ccc (pkg/operator: correctly fetch CA for AWS minter,
2023-07-19, openshift#575)'s LiveClient avoids confusing CreateOrPatch.  With
the cached .Client, it would have:

1. Failed to retrive an unlabeled Secret, because the
   externally-created Secret lacked the label that the Client's
   filteredWatchPossible informer is filtered on.
2. Thought that it should Create a new Secret.
3. Had that Create attempt fail on 'secrets "$NAME" already exists'.

With the LiveClient, that becomes:

1. Successfully retrived an unlabeled Secret, with the uncached
   reader.
2. Thought that it should Patch the Secret.
3. Successfully Patch the Secret.
4. Once the Patch sets the label, future attempts to Get the Secret
   through the filtered informer cache will succeed.

[1]: https://argo-cd.readthedocs.io/en/release-2.13/operator-manual/applicationset/Controlling-Resource-Modification/#preserving-changes-made-to-an-applications-annotations-and-labels
wking added a commit to wking/cloud-credential-operator that referenced this pull request Jan 4, 2025
Even when awsSTSIAMRoleARN is empty, we want the label so that
pkg/cmd/operator's NewOperator's filteredWatchPossible label-selector
can find these Secrets.  Then the controller will notice if they're
deleted (so it can update the CredentialsRequest status to point that
out) or when they haven't been changed (so it can avoid "I can't find
the Secret!" overly-frequent bumping in the hasRecentlySynced
calculation, because it thinks crSecretExists=false).

And we want the annotation, so it's clear why the Secret needs to
exist (because of the annotation-referenced CredentialsRequest).

The risk here is that we might end up contending over label/annotation
presence with the external controller that is populating the
'credentials' data inside the Secret.  But the alternative of an
unfiltered Secret informer in the client is still too
resource-intensive, as described in the filteredWatchPossible comment
and the a58a09c (*: use a filtered LIST + WATCH on Secrets for AWS
STS, 2023-06-29, openshift#545) commit that added the filteredWatchPossible
logic.  Additional labels and annotations are properties that external
controllers should be able to accept.  For example, [1] has ArgoCD
discussing:

  apiVersion: argoproj.io/v1alpha1
  kind: ApplicationSet
  spec:
    # (...)
    preservedFields:
      annotations: ["my-custom-annotation"]
      labels: ["my-custom-label"]

to ignore annotations and labels injected by external-to-ArgoCD
controllers, which is what the CCO-specific annotation/label I'm
touching now would be.

Moving to 48d6ccc (pkg/operator: correctly fetch CA for AWS minter,
2023-07-19, openshift#575)'s LiveClient avoids confusing CreateOrPatch.  With
the cached .Client, it would have:

1. Failed to retrive an unlabeled Secret, because the
   externally-created Secret lacked the label that the Client's
   filteredWatchPossible informer is filtered on.
2. Thought that it should Create a new Secret.
3. Had that Create attempt fail on 'secrets "$NAME" already exists'.

With the LiveClient, that becomes:

1. Successfully retrived an unlabeled Secret, with the uncached
   reader.
2. Thought that it should Patch the Secret.
3. Successfully Patch the Secret.
4. Once the Patch sets the label, future attempts to Get the Secret
   through the filtered informer cache will succeed.

[1]: https://argo-cd.readthedocs.io/en/release-2.13/operator-manual/applicationset/Controlling-Resource-Modification/#preserving-changes-made-to-an-applications-annotations-and-labels
wking added a commit to wking/cloud-credential-operator that referenced this pull request Jan 4, 2025
Even when awsSTSIAMRoleARN is empty, we want the label so that
pkg/cmd/operator's NewOperator's filteredWatchPossible label-selector
can find these Secrets.  Then the controller will notice if they're
deleted (so it can update the CredentialsRequest status to point that
out) or when they haven't been changed (so it can avoid "I can't find
the Secret!" overly-frequent bumping in the hasRecentlySynced
calculation, because it thinks crSecretExists=false).

And we want the annotation, so it's clear why the Secret needs to
exist (because of the annotation-referenced CredentialsRequest).

The risk here is that we might end up contending over label/annotation
presence with the external controller that is populating the
'credentials' data inside the Secret.  But the alternative of an
unfiltered Secret informer in the client is still too
resource-intensive, as described in the filteredWatchPossible comment
and the a58a09c (*: use a filtered LIST + WATCH on Secrets for AWS
STS, 2023-06-29, openshift#545) commit that added the filteredWatchPossible
logic.  Additional labels and annotations are properties that external
controllers should be able to accept.  For example, [1] has ArgoCD
discussing:

  apiVersion: argoproj.io/v1alpha1
  kind: ApplicationSet
  spec:
    # (...)
    preservedFields:
      annotations: ["my-custom-annotation"]
      labels: ["my-custom-label"]

to ignore annotations and labels injected by external-to-ArgoCD
controllers, which is what the CCO-specific annotation/label I'm
touching now would be.

Moving to 48d6ccc (pkg/operator: correctly fetch CA for AWS minter,
2023-07-19, openshift#575)'s LiveClient avoids confusing CreateOrPatch.  With
the cached .Client, it would have:

1. Failed to retrive an unlabeled Secret, because the
   externally-created Secret lacked the label that the Client's
   filteredWatchPossible informer is filtered on.
2. Thought that it should Create a new Secret.
3. Had that Create attempt fail on 'secrets "$NAME" already exists'.

With the LiveClient, that becomes:

1. Successfully retrived an unlabeled Secret, with the uncached
   reader.
2. Thought that it should Patch the Secret.
3. Successfully Patch the Secret.
4. Once the Patch sets the label, future attempts to Get the Secret
   through the filtered informer cache will succeed.

[1]: https://argo-cd.readthedocs.io/en/release-2.13/operator-manual/applicationset/Controlling-Resource-Modification/#preserving-changes-made-to-an-applications-annotations-and-labels
stephenfin added a commit to shiftstack/cloud-credential-operator that referenced this pull request Jun 9, 2025
This was first introduced in commit 48d6ccc as a resolution to
OCPBUGS-16313 [1][2], which was itself introduced by the removal of
configmaps read access from the cluster role used by CCO. However,
non-caching clients are expensive and with the change introduced in the
previous commit, which restricted caching to specific config maps, plus
the existing role allowing access to these config maps, their use should
no longer be necessary.

[1] openshift#575
[2] https://issues.redhat.com/browse/OCPBUGS-16313

Signed-off-by: Stephen Finucane <[email protected]>
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-bug Indicates that a referenced Jira 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.

4 participants