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

Remove all the deployments in the older version #257

Closed
wants to merge 1 commit into from

Conversation

houshengbo
Copy link

@houshengbo houshengbo commented Jan 20, 2020

Fixes #256

Proposed Changes

  • We can know if there is an older version of operator CR, by checking Status.Version. This PR add the support to delete the old resources with the label "serving.knative.dev/release=<oldVersion>", If it is not empty and not equal to the current version.

Release Note


We can know if there is an older version of operator CR, by checking
Status.Version. If it is not empty and not equal to the current version,
we can delete the old resources with the label
"serving.knative.dev/release=<oldVersion>".
@googlebot googlebot added the cla: yes Author(s) signed a CLA. label Jan 20, 2020
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@houshengbo: 0 warnings.

In response to this:

We can know if there is an older version of operator CR, by checking
Status.Version. If it is not empty and not equal to the current version,
we can delete the old resources with the label
"serving.knative.dev/release=".

Fixes #256

Proposed Changes

Release Note


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.

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: houshengbo

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

@markusthoemmes
Copy link
Contributor

What is the expected behavior? Is this supposed to remove „outdated“ deployments i.e. those that are no longer used in the new version?

@houshengbo
Copy link
Author

@markusthoemmes Correct. I am also seeking to remove some other older resources, which are not used any more in the new version, like service, configmaps, gateway, etc, but I did not find the solution to remove all of them will a single call.

Copy link
Contributor

@jcrossley3 jcrossley3 left a comment

Choose a reason for hiding this comment

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

/hold

deploymentList, err := r.KubeClientSet.AppsV1().Deployments(instance.GetNamespace()).List(listOptions)
if err == nil {
for _, dep := range deploymentList.Items {
if e := r.KubeClientSet.AppsV1().Deployments(instance.GetNamespace()).Delete(dep.Name,
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes me nervous. Deleting a deployment instead of updating it introduces the potential for losing requests, I think. Besides, I prefer seeing in this function exactly which resources are obsolete and need to be deleted.

Copy link
Author

Choose a reason for hiding this comment

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

@jcrossley3 To find out all the resources to be removed, I can think of using the manifestival package to read the manifest of the older version, and compare to the manifest of the new version, to see if they still exist in the new version. Do you have any other suggestions?

@houshengbo
Copy link
Author

We can use an alternative way to delete the obsolete resources with the existing deleteObsoleteResources function: when there is a new release of knative serving, check if there are resources deleted in the new release. If so, we add delete calls to those resources in the function deleteObsoleteResources.

Based on the nature of the low frequency that a resource is deleted, we can do easy diff to find out the missing resource and maintain deleteObsoleteResources. It is ideal to delete all resources that don‘t match the current version, but that brings in too much overhead.

@houshengbo houshengbo closed this Jan 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the resources of the older version, if a new version of knative is installed.
5 participants