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

MachineDeployment loses track of MachineSet when labels change #1341

Closed
sethp-nr opened this issue Aug 29, 2019 · 1 comment · Fixed by #1358
Closed

MachineDeployment loses track of MachineSet when labels change #1341

sethp-nr opened this issue Aug 29, 2019 · 1 comment · Fixed by #1358
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Milestone

Comments

@sethp-nr
Copy link
Contributor

/kind bug

What steps did you take and what happened:

Given a MachineDeployment:

apiVersion: cluster.x-k8s.io/v1alpha2
kind: MachineDeployment
metadata:
  annotations:
    machinedeployment.clusters.k8s.io/revision: "1"
  name: nodes-0
spec:
  replicas: 1
  selector:
    matchLabels:
      set: node
  template:
    metadata:
      labels:
        cluster.x-k8s.io/cluster-name: cluster
        set: node
    spec:
      ...

I added (via kubectl edit) a label to both the selector and the template:

apiVersion: cluster.x-k8s.io/v1alpha2
kind: MachineDeployment
metadata:
  annotations:
    machinedeployment.clusters.k8s.io/revision: "1"
  name: nodes-0
spec:
  replicas: 1
  selector:
    matchLabels:
      set: node
      someLabel: foo
  template:
    metadata:
      labels:
        cluster.x-k8s.io/cluster-name: cluster
        set: node
        someLabel: foo
    spec:
      ...

The MachineDeployment controller created a new MachineSet matching the new template and scaled it up to the appropriate number of replicas, but never scaled down the old MachineSet.

What did you expect to happen:

waves hands the deploy to have completed successfully, respecting whatever rolling update strategy is configured (I was testing with a single replica, but I would be surprised if it followed the strategy).

I think the way the Deployment controller works is to use the owner ref to infer that the old ReplicaSet is still part of the same "deployment": https://github.com/kubernetes/kubernetes/blob/06dc8cf4cb0d3bdc7b718392a66ca82678d9982f/pkg/controller/deployment/deployment_controller.go#L498-L499

Anything else you would like to add:

I haven't done a thorough look yet, but it seems like we might be able to add a "is controlled by this machinedeployment -> append to filtered" block before we check the label selector here:

if !selector.Matches(labels.Set(ms.Labels)) {
?

Environment:

  • Cluster-api version: recent v1alpha2 (and v1alpha1)
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 29, 2019
@detiber
Copy link
Member

detiber commented Aug 30, 2019

/priority important-soon

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Aug 30, 2019
@detiber detiber added this to the v0.2.x (v1alpha2) milestone Aug 30, 2019
@ncdc ncdc added the lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. label Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants