Skip to content

Proposal to use tags for tracking PowerVS cluster resources #2364

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

arshadd-b
Copy link
Contributor

What this PR does / why we need it:
Proposal for adding the tags to PowerVS Cluster resources and performing delete of resources on the bases of tags
Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

/area provider/ibmcloud

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

Add tags to PowerVS Cluster resources and delete resources based on tags

@k8s-ci-robot k8s-ci-robot added the area/provider/ibmcloud Issues or PRs related to ibmcloud provider label May 20, 2025
@k8s-ci-robot k8s-ci-robot requested a review from Karthik-K-N May 20, 2025 08:00
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 20, 2025
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 20, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @arshadd-b. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 20, 2025
Copy link

netlify bot commented May 20, 2025

Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!

Name Link
🔨 Latest commit c3f4178
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-cluster-api-ibmcloud/deploys/6895d50d841c090008902d12
😎 Deploy Preview https://deploy-preview-2364.cluster-api-ibmcloud.sigs.k8s.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Amulyam24
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 20, 2025
@Amulyam24
Copy link
Contributor

/retitle Proposal to use tags for tracking PowerVS cluster resources

@k8s-ci-robot k8s-ci-robot changed the title Add tags to PowerVS Cluster resources and delete resources based on tags Proposal to use tags for tracking PowerVS cluster resources May 22, 2025
Copy link
Contributor

@Karthik-K-N Karthik-K-N left a comment

Choose a reason for hiding this comment

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

In the delete flow diagram, I think If is not needed inside the rhombus as its already a decision block
In create flow diagram I think you missed to consider COSInstance

Copy link
Contributor

@Karthik-K-N Karthik-K-N left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, Most of the things are good,lets update it bit more to make it better.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 29, 2025
@arshadd-b arshadd-b force-pushed the add-tags-proposal branch from 48c48f4 to e0b2d89 Compare May 29, 2025 13:48
@arshadd-b
Copy link
Contributor Author

In the delete flow diagram, I think If is not needed inside the rhombus as its already a decision block In create flow diagram I think you missed to consider COSInstance

done

@arshadd-b arshadd-b requested a review from Karthik-K-N May 30, 2025 10:22
@arshadd-b arshadd-b force-pushed the add-tags-proposal branch from e0b2d89 to d862267 Compare May 30, 2025 13:24
@arshadd-b arshadd-b force-pushed the add-tags-proposal branch from d862267 to 0f4cb6b Compare May 30, 2025 13:29
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 30, 2025
Copy link
Contributor

@Amulyam24 Amulyam24 left a comment

Choose a reason for hiding this comment

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

Hi @arshadd-b, Thank you for the proposal!

I'm not clear on how user tags will be used apart from the controller tag. Can you please share more details on it?

@arshadd-b
Copy link
Contributor Author

Hi @arshadd-b, Thank you for the proposal!

I'm not clear on how user tags will be used apart from the controller tag. Can you please share more details on it?

Hi @Amulyam24 , It is the same functionality that we do from UI, adding tags to IBM Cloud resources if user wants to tag resources. It can help to user in resource management.

@arshadd-b arshadd-b requested a review from Amulyam24 June 11, 2025 14:25
Copy link
Contributor

@Amulyam24 Amulyam24 left a comment

Choose a reason for hiding this comment

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

Hi @Amulyam24 , It is the same functionality that we do from UI, adding tags to IBM Cloud resources if user wants to tag resources. It can help to user in resource management.

Got it, Thanks for the clarification.

A couple of suggestions have been added.

In the create flow diagram, how about we enhance the condition such as cluster.spec.UserTags > 0 , then proceed to attach user provided tags.

Comment on lines 37 to 38
- Currently TransitGateway Connections doesn't support tagging, So we will handle deletion of connections based on VPC.
- DHCP Server doesn't support tagging, So we will tag DHCP Network and handle deletion based on Network.
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
- Currently TransitGateway Connections doesn't support tagging, So we will handle deletion of connections based on VPC.
- DHCP Server doesn't support tagging, So we will tag DHCP Network and handle deletion based on Network.
Currently transit gateway connections and DHCP server don't support tagging. We will handle their deletion using the VPC and network tag respectively.

When DHCP server is created, we use its network right, is that taggable?

should we depend on workspace resource tag instead?

cc @Karthik-K-N

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Amulyam24 Actually there is ause case when workspace is already created but DHCP network is newly created,
in that case we want to delete the network only not workspace. So for this case we have to tag the network.
I have already checked for network tagging is supported .

@arshadd-b arshadd-b requested a review from Amulyam24 June 17, 2025 14:07


### Controller tag
A tag of format`powervs.cluster.x-k8s.io-resource-owner:<cluster_name>` will be added by the controller to newly created cloud resources marking the resource as created by controller. During deletion phase the system will look for the presence of the tag inorder to proceed with deletion or to keep as it is.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can discuss on tag format again here

I see aws using something like sigs.k8s.io/cluster-api-provider-aws/cluster/<cluster-name>: owned
@dharaneeshvrd I remember even hypershift uses tags, whats the format there?

Copy link
Contributor

Choose a reason for hiding this comment

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

What if in future if we want to adopt some pre-created resources, I think this format does not allow it.

Copy link
Contributor

Choose a reason for hiding this comment

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

kubernetes.io-cluster-<cluster_name>:owned
https://github.com/openshift/hypershift/blob/4f139f8181bb22a26fcffde2067dc8c73705ec5f/cmd/infra/powervs/create.go#L135
This is the format used in hypershift which we got it from IPI at that time.

Copy link
Contributor

Choose a reason for hiding this comment

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

cool thanks, I think having owned helps as later we can add more keywords if required, Then can we stick to this format

sigs.k8s.io/cluster-api-provider-ibmcloud/cluster/<cluster-name>: owned

@arshadd-b arshadd-b force-pushed the add-tags-proposal branch from f1517e2 to 85da3c1 Compare June 24, 2025 06:08
@arshadd-b arshadd-b requested a review from Karthik-K-N June 25, 2025 04:11
Copy link
Contributor

@Amulyam24 Amulyam24 left a comment

Choose a reason for hiding this comment

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

minor nits, LGTM!

@Prajyot-Parab
Copy link
Contributor

@arshadd-b Please address the review comments and squash the commits.

Copy link

linux-foundation-easycla bot commented Aug 8, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 8, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 8, 2025
@arshadd-b arshadd-b requested a review from Amulyam24 August 8, 2025 10:42
Copy link
Contributor

@Amulyam24 Amulyam24 left a comment

Choose a reason for hiding this comment

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

/lgtm

@arshadd-b, please squash the commits.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 8, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Amulyam24, arshadd-b
Once this PR has been reviewed and has the lgtm label, please assign prajyot-parab for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link
Contributor

@dharaneeshvrd dharaneeshvrd left a comment

Choose a reason for hiding this comment

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

How do we handle existing resource which is created by controller in earlier runs which will have controllercreated tag?
E.g.
Due to some reason, resources created during earlier runs did nt get cleaned up properly, so when we process it, it would have the tag but it was nt created as part of current cluster's reconciliation. It would cause collision during destroy flow. We need to find a way to handle this situation too.

2. User tags


### Controller tag
Copy link
Contributor

Choose a reason for hiding this comment

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

How are we going to differentiate the vpc subnet or DHCP network tag for itself and TG connection when only TG connection is created by controller to use them during destroy flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

vpc subnet and DHCP network supports tagging, So when these resources are newly created and will be tagged.
For TG connection we will check either vpc subnet or DHCP network since TG connnection doesn't support tagging.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, my question is what are the labels you would use when TG connection is created by controller when vpc subnet and DHCP network also created by controller? Dont you need to add two label to the vpc subnet? one is to denote its own itself and another one for vpc TG connection. In that case dont you need to use a different tag format? I feel that also need to be documented properly here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand it like this

  1. Transit Gateway supports tagging but its connections does not support tagging

Deletion flow

Case 1: All TG and its connections created by controller

If TG has tag attached then it means TG and its connections are created by controller then we can directly delete all 3 resources(TG, PowerVS Connection, VPC Connections)

Case 2: Pre-existing TG but new connections

  1. TG tag does not match the cluster in deletion's tag means we are not suppose to delete it
  2. Now to delete PowerVS Connection, Get the network name of connection and check whether the network has the cluster in deletion's tag, If present delete
  3. Same for VPC.

Is my understanding correct or do you think is there any gap?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is one more scenario

case 3: What if only connections are created but TG and networks(vpc subnet and DHCP network) pre-existing.
In this case we have to delete only connections, to handle this case we need to add one tag to TG with below format
sigs.k8s.io/cluster-api-provider-ibmcloud/cluster/<cluster-name>/TG: connection1, connection2

Then before deleting we will check for this tag,
will be adding this in proposal

@arshadd-b
Copy link
Contributor Author

How do we handle existing resource which is created by controller in earlier runs which will have controllercreated tag? E.g. Due to some reason, resources created during earlier runs did nt get cleaned up properly, so when we process it, it would have the tag but it was nt created as part of current cluster's reconciliation. It would cause collision during destroy flow. We need to find a way to handle this situation too.

I was thinking since we are not removing controllercreated field completely
So first we will check the tag is there or not if not tagged , then we will check controllercreated field then delete the resource

@dharaneeshvrd
Copy link
Contributor

The final goal would be to remove that totally right, So depending on it won't be the right thing to do. We need to have clear plan on how to handle this if we are implementing tag based way of identifying the resources created by controller.

@Karthik-K-N
Copy link
Contributor

How do we handle existing resource which is created by controller in earlier runs which will have controllercreated tag? E.g. Due to some reason, resources created during earlier runs did nt get cleaned up properly, so when we process it, it would have the tag but it was nt created as part of current cluster's reconciliation. It would cause collision during destroy flow. We need to find a way to handle this situation too.

Good point, I think as a transition plan I think we should check whether the resource has controllerCreated is set to true, In that case we should go ahead and create the tag. In this case we can completely depend on the tag to delete.

@arshadd-b
Copy link
Contributor Author

How do we handle existing resource which is created by controller in earlier runs which will have controllercreated tag? E.g. Due to some reason, resources created during earlier runs did nt get cleaned up properly, so when we process it, it would have the tag but it was nt created as part of current cluster's reconciliation. It would cause collision during destroy flow. We need to find a way to handle this situation too.

Good point, I think as a transition plan I think we should check whether the resource has controllerCreated is set to true, In that case we should go ahead and create the tag. In this case we can completely depend on the tag to delete.

yeah makes sense, will add this trasition plan in proposal

@dharaneeshvrd
Copy link
Contributor

Good point, I think as a transition plan I think we should check whether the resource has controllerCreated is set to true, In that case we should go ahead and create the tag. In this case we can completely depend on the tag to delete.

With this design it feels like we would need the controllercreated status as a dependency for attaching tags. But I feel we should have some idea on how can we move away from controllercreated status in future. Because after implementing this, if we always dependant on controllercreated status to handle certain cases, then what's the point of implementing tags?

@Karthik-K-N
Copy link
Contributor

Good point, I think as a transition plan I think we should check whether the resource has controllerCreated is set to true, In that case we should go ahead and create the tag. In this case we can completely depend on the tag to delete.

With this design it feels like we would need the controllercreated status as a dependency for attaching tags. But I feel we should have some idea on how can we move away from controllercreated status in future. Because after implementing this, if we always dependant on controllercreated status to handle certain cases, then what's the point of implementing tags?

This is just a transition layer, The ultimate goal is to remove the controllerCreated field.

When we have the tagging support

  1. For already existing cluster if it has controllerCreated we will create a tag
  2. For new cluster we always create a tag.

This would help us in deletion flow to soley depend on the tag rather than the controllerCreated field and eventually we will remove the field in the later releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/ibmcloud Issues or PRs related to ibmcloud provider 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants