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

Fix: change sg finalizer suffix to sgID #60

Merged
merged 3 commits into from
Jun 11, 2024
Merged

Conversation

Rdpaula
Copy link
Collaborator

@Rdpaula Rdpaula commented Jun 7, 2024

We need these changes because our controller throws reconciler errors when our sgName is bigger than 63 characters. So we decided to change the finalizer suffix from sgName to sgID because it is smaller and still references which security group put that finalizer.

failed to add finalizer in xxxxx-xxxxxx: KopsMachinePool.infrastructure.cluster.x-k8s.io "xxxxxx-xxxxxx" is invalid: metadata.finalizers: Invalid value: "securitygroup.wildlife.infrastructure.io/xxxxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx': name part must be no more than 63 characters

@Rdpaula Rdpaula changed the title Fix: Change sg finalizer suffix to sgID Fix: change sg finalizer suffix to sgID Jun 7, 2024
@rsafonseca
Copy link
Contributor

Why are we overcomplicating this? The finalizer should be a static string like kcio or something like that, indicating which platform has pending actions ahead of the object being permanently removed. The sg name and Id should already be present in the object being reconciled.

@Rdpaula
Copy link
Collaborator Author

Rdpaula commented Jun 10, 2024

Why are we overcomplicating this? The finalizer should be a static string like kcio or something like that, indicating which platform has pending actions ahead of the object being permanently removed. The sg name and Id should already be present in the object being reconciled.

I'm not sure If I understand well. But this decision was made because if you have two SG's associated with a KMP for example, you can't have a unique finalizer. How do you know that all security groups of one kmp are detached/disassociated with only one finalizer?

@rsafonseca
Copy link
Contributor

The finaliser is a property on the SG CR. If you have 2 SGs, you have 2 CRs. The finaliser is generally just a string that generally has the name of the controller which needs to perform additional actions on the object before it is deleted in kubernetes. KCIO will never add two finalisers to the same SG CR, as it would make no sense.

@Rdpaula
Copy link
Collaborator Author

Rdpaula commented Jun 10, 2024

The finaliser is a property on the SG CR. If you have 2 SGs, you have 2 CRs. The finaliser is generally just a string that generally has the name of the controller which needs to perform additional actions on the object before it is deleted in kubernetes. KCIO will never add two finalisers to the same SG CR, as it would make no sense.

These two finalizers are added to KMP CR, not SG CR.

@rsafonseca
Copy link
Contributor

oh, this was confusing because it's in the security group controller, and thus the failure events are being attached to the securitygroup CR.
Still, the correct way to do this would be to create an owner/dependent relationship and just have a static name for the finaliser IMO, see https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/

@Rdpaula
Copy link
Collaborator Author

Rdpaula commented Jun 10, 2024

oh, this was confusing because it's in the security group controller, and thus the failure events are being attached to the securitygroup CR. Still, the correct way to do this would be to create an owner/dependent relationship and just have a static name for the finaliser IMO, see https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/

I agree with you, but we can't do this solution because A valid owner reference consists of the object name and a UID within the same namespace as the dependent object. SGs aren't namespaced and KMPs are. 😢

@Rdpaula
Copy link
Collaborator Author

Rdpaula commented Jun 10, 2024

We still thought of another solution that was an intermediary resource, like PV and PVC. But we would have to do another controller and code its lifecycle, we didn't because it requires much more time to do it.

@rsafonseca
Copy link
Contributor

Well, i guess this solves the bigger issue for now, we can think about further improvement later when we have the cycles for it :)
Thanks for taking the time to discuss it
LGTM

@Rdpaula Rdpaula merged commit 3f5230b into main Jun 11, 2024
3 checks passed
@Rdpaula Rdpaula deleted the fix/big-sg-finalizer-name branch June 11, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants