Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Delete replicaSet for app #107

Closed
wants to merge 1 commit into from
Closed

Delete replicaSet for app #107

wants to merge 1 commit into from

Conversation

linemos
Copy link
Contributor

@linemos linemos commented Apr 16, 2018

No description provided.

appLabel := "app=" + deployName
replicaSets, err := k8sClient.AppsV1().ReplicaSets(namespace).List(k8smeta.ListOptions{LabelSelector: appLabel})
if err != nil {
return filterNotFound(fmt.Sprintf("could not delete replicaset: %s in namespace: %s: %s", deployName, namespace, err), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

kunne feilmeldingen heller vært at den ikke fant et replicaset? Siden den ikke prøver å slette den enda.


for _, replicaSet := range replicaSets.Items {
if err := k8sClient.AppsV1().ReplicaSets(namespace).Delete(replicaSet.Name, &k8smeta.DeleteOptions{}); err != nil {
return filterNotFound(fmt.Sprintf("could not delete replicaset: %s in namespace: %s: %s", deployName, namespace, err), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Skulle den prøvd å slette de andre i listen, eller bare fastFail?

replicaSetDef := &k8sapps.ReplicaSet{
TypeMeta: k8smeta.TypeMeta{
Kind: "ReplicaSet",
APIVersion: "v1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Kunne vi hentet APIVersion fra k8sapps?

@gtcno
Copy link
Collaborator

gtcno commented Apr 16, 2018

Why is this necessary? Does a delete of a deployment not trigger a cascading delete of rs?

@linemos
Copy link
Contributor Author

linemos commented Apr 16, 2018

@gtcno It should, but it does not. I have not found out why.

@linemos
Copy link
Contributor Author

linemos commented Apr 16, 2018

Cannot reproduce the problem right now. Perhaps the bug was somewhere else... 🤔

@linemos linemos closed this Apr 16, 2018
@gtcno
Copy link
Collaborator

gtcno commented Apr 16, 2018

This is a wormhole. But i thought this was fixed here
kubernetes/kubernetes#44058.

I do think we should be careful with deleting resources that we dont explicitly create.
Are we sure the deployment controller doesnt recreate a replicaset if you delete one that is created by a deployment?
And yeah we do delete the deployment. But kubernetes controllers are asyn so race conditions might occur.

@Kyrremann Kyrremann deleted the delete-replicaset branch April 23, 2018 15:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants