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

🐛clusterctl discovery should ignore provider's resources #5684

Conversation

fabriziopandini
Copy link
Member

What this PR does / why we need it:
While managing components (for cert-manager or providers) clusterctl implements a discovery function to seek for all the objects part of the component.

This PR makes this code to ignore resources for a provider (e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager) given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual state of cert-manager web hooks; in fact, those operations can now work when web-hooks are not functioning (due to provider's deployment already deleted, to provider scaled down to 0, to other errors)

@fabriziopandini
Copy link
Member Author

/test pull-cluster-api-e2e-main
/test pull-cluster-api-e2e-full-main
/test pull-cluster-api-e2e-ipv6-main

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 16, 2021
@sbueringer
Copy link
Member

/retest

Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Overall lgtm, I think

@@ -237,27 +242,26 @@ func (k *proxy) ListResources(labels map[string]string, namespaces ...string) ([
return nil, errors.Wrap(err, "failed to list api resources")
}

// If labels indicates that resources of a specific provider should be listed, exclude CRDs of other providers.
// Exclude from discovery the objects from the cert-manager/provider's CRDs.
Copy link
Member

Choose a reason for hiding this comment

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

To confirm my understanding.

We're calling this func in two cases:

  • certManagerClient.EnsureLatestVersion
    • in this case we're not listing any CRDs
  • providerComponents.Delete
    • in this case we're not listing any provider CRDs, i.e. we still list Certificate and CertificateRequest (which is what we want)

If I'm correct, maybe we should adjust the godocs of the func slightly, as they could also be interpreted differently (i.e. that the func is only not returning resources of the CRDs of the current component)

Copy link
Member Author

Choose a reason for hiding this comment

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

~ right
In both cases we are not listing resources for any CRDs installed by clusterctl (including cert-manager CRDs and providers CRDs).

In other words, we are only concerned about provider components (deployments, RBAC rules, CRD definitions) but not in the resource created on top of that (Clusters, Machines, AWSCluster etc) because the latter are not relevant for upgrade/delete.

@kubernetes-sigs kubernetes-sigs deleted a comment from k8s-ci-robot Nov 19, 2021
@sbueringer
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 19, 2021
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 19, 2021
@k8s-ci-robot k8s-ci-robot merged commit c117510 into kubernetes-sigs:main Nov 19, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.1 milestone Nov 19, 2021
@fabriziopandini
Copy link
Member Author

/cherry-pick release-1.0

@k8s-infra-cherrypick-robot

@fabriziopandini: #5684 failed to apply on top of branch "release-1.0":

Applying: clusterctl discovery should ignore provider's resources
Using index info to reconstruct a base tree...
M	cmd/clusterctl/client/cluster/proxy.go
Falling back to patching base and 3-way merge...
Auto-merging cmd/clusterctl/client/cluster/proxy.go
CONFLICT (content): Merge conflict in cmd/clusterctl/client/cluster/proxy.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 clusterctl discovery should ignore provider's resources
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.0

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.

Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 20, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

Reason for backporting:

This issue that was solved in db5b183 on the main branch is also effecting
older releases of CAPI currently in use thus the patch is applicable
on older branches.
Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 20, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

Reason for backporting:

This issue that was solved in db5b183 on the main branch is also effecting
older releases of CAPI currently in use thus the patch is applicable
on older branches.
Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 20, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

This commit also introduces some logic originally implemented in commit
f5a9d76 that implements the ability to skip excluded CRD during
resource listing.

Reason for backporting:

The issues that were solved by commit db5b183 and f5a9d76  on the main
branch are also effecting older releases of CAPI currently in use thus backporting
the "discovery fix" and some related code from f5a9d76 would solve a lot of issue
faced by users e.g related to upgrade process as mentioned in the original db5b183 commit.
Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 22, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

This commit also introduces some logic originally implemented in commit
f5a9d76 that implements the ability to skip excluded CRD during
resource listing.

Reason for backporting:

The issues that were solved by commit db5b183 and f5a9d76  on the main
branch are also effecting older releases of CAPI currently in use thus backporting
the "discovery fix" and some related code from f5a9d76 would solve a lot of issues
faced by users e.g related to upgrade process as mentioned in the original db5b183 commit.
@fabriziopandini fabriziopandini deleted the clusterctl-discovery-ignore-providers-resources branch November 23, 2021 13:25
Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 24, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

This commit also introduces some logic originally implemented in commit
f5a9d76 that implements the ability to skip excluded CRD during
resource listing.

Reason for backporting:

The issues that were solved by commit db5b183 and f5a9d76  on the main
branch are also effecting older releases of CAPI currently in use thus backporting
the "discovery fix" and some related code from f5a9d76 would solve a lot of issues
faced by users e.g related to upgrade process as mentioned in the original db5b183 commit.
Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 24, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

This commit also introduces some logic originally implemented in commit
f5a9d76 that implements the ability to skip excluded CRD during
resource listing.

Reason for backporting:

The issues that were solved by commit db5b183 and f5a9d76  on the main
branch are also effecting older releases of CAPI currently in use thus backporting
the "discovery fix" and some related code from f5a9d76 would solve a lot of issue
faced by users e.g related to upgrade process as mentioned in the original db5b183 commit.
Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 24, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

This commit also introduces some logic originally implemented in commit
f5a9d76 that implements the ability to skip excluded CRD during
resource listing.

Reason for backporting:

The issues that were solved by commit db5b183 and f5a9d76  on the main
branch are also effecting older releases of CAPI currently in use thus backporting
the "discovery fix" and some related code from f5a9d76 would solve a lot of issue
faced by users e.g related to upgrade process as mentioned in the original db5b183 commit.
Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 24, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

This commit also introduces some logic originally implemented in commit
f5a9d76 that implements the ability to skip excluded CRD during
resource listing.

Reason for backporting:

The issues that were solved by commit db5b183 and f5a9d76  on the main
branch are also effecting older releases of CAPI currently in use thus backporting
the "discovery fix" and some related code from f5a9d76 would solve a lot of issues
faced by users e.g related to upgrade process as mentioned in the original db5b183 commit.
Rozzii pushed a commit to Nordix/cluster-api that referenced this pull request Nov 24, 2021
This patch was originally introduced in PR kubernetes-sigs#5684.
Original name: "clusterctl discovery should ignore provider's resources"
Original commit id: db5b183

Original description:

While managing components (for cert-manager or providers) clusterctl
implements a discovery function to seek for all the objects
part of the component.

This commit makes this code to ignore resources for a provider
(e.g Cluster for CAPI, AWSCluster for CAPA, Certificates for cert-manager)
given that those resources are not part of the component itself.

This will make operations like upgrade plan or apply and delete resilient to actual
state of cert-manager web hooks; in fact, those operations can now work when
web-hooks are not functioning (due to provider's deployment already deleted,
to provider scaled down to 0, to other errors)

This commit also introduces some logic originally implemented in commit
f5a9d76 that implements the ability to skip excluded CRD during
resource listing.

Reason for backporting:

The issues that were solved by commit db5b183 and f5a9d76  on the main
branch are also effecting older releases of CAPI currently in use thus backporting
the "discovery fix" and some related code from f5a9d76 would solve a lot of issues
faced by users e.g related to upgrade process as mentioned in the original db5b183 commit.
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants