-
Notifications
You must be signed in to change notification settings - Fork 110
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
452: handle delete strategy for inoperable resources #468
Conversation
…InoperableResource
i think this list should also include the namespaces: these are all default namespaces in a cluster and as such should be treated i believe the same as the default namespace in terms of deletion strategy behavior |
…, kube-public, kube-system
Updated the list as suggested. Thanks @vrabbi |
res := c.change.ExistingResource() | ||
|
||
for _, r := range inoperableResourceList { | ||
strings.EqualFold(r.Name, res.Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EqualFold do the non case-sensitive comparison of two strings. Which I found better than converting strings in one case and then compare.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have decide3d to go ahead with matching Group and Kind. We can change the values to have capital case (i.e. "Namespace") as that is always the case and go ahead with simply checking for equality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some thoughts 🤔
will take a closer look at the test as it is slightly diferent for what we have for the orphaning test.
res := c.change.ExistingResource() | ||
|
||
for _, r := range inoperableResourceList { | ||
strings.EqualFold(r.Name, res.Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have decide3d to go ahead with matching Group and Kind. We can change the values to have capital case (i.e. "Namespace") as that is always the case and go ahead with simply checking for equality
Name string | ||
} | ||
|
||
// if any new reource will encountered which kapp can not delete and required to orphaned then resource info will be added here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: (just trying to make it a bit clearer)
// if any new reource will encountered which kapp can not delete and required to orphaned then resource info will be added here. | |
// List of resources use the "orphan" delete strategy implicitly as they cannot be deleted by end users |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -32,10 +33,40 @@ type DeleteChange struct { | |||
identifiedResources ctlres.IdentifiedResources | |||
} | |||
|
|||
type uniqueResourceRef struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we change this to "inoperableResourceRef" as we are loosely matching it without being strict about versions now? It is also not being used anywhere else.
(Others might have other ideas as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with the suggestion and updated the same. thanks
|
||
for _, r := range inoperableResourceList { | ||
strings.EqualFold(r.Name, res.Name()) | ||
if strings.EqualFold(r.Name, res.Name()) && strings.EqualFold(r.Kind, res.GroupKind().Kind) && strings.EqualFold(r.Group, res.GroupKind().Group) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As renu pointed out, I do not think we should do a match which ignores cases here if we have decided on using Group-Kinds to match as they are always the same.
test/e2e/delete_inoperable_test.go
Outdated
kind: Namespace | ||
metadata: | ||
name: default | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we do not need this empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it
The failing lint should be fixed by #470 |
@@ -122,3 +157,14 @@ func descMessage(res ctlres.Resource) []string { | |||
} | |||
return []string{} | |||
} | |||
|
|||
func (c DeleteChange) isInoperableResource() bool { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: No need of new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I see that there is an extra case (one more the orphaned test)
But I believe it addresses two cases, one where the GVR of the resource being deleted is available and the other when it is not.
I am fine with having this 🚀
|
||
res := c.change.ExistingResource() | ||
for _, r := range inoperableResourceList { | ||
if r.Name == res.Name() && r.Kind == res.GroupKind().Kind && r.Group == res.GroupKind().Group { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is a trick:
if r == inoperableResourceRef{Name: res.Name(), GroupKind: res.GroupKind()} {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
LGTM |
Why this PR and what it is doing
Issue was: Inoperable resources like default namespace are not allowed to delete which was throwing error on kapp delete.
Solution: For all inoperable resources kapp will orphaned the requested resource instead of trying to delete.
TODO:
NOTE: If you feel there should be more resources in the list please suggest.