Skip to content

Commit

Permalink
Merge pull request #4295 from jimmidyson/machine-pool-descendants
Browse files Browse the repository at this point in the history
🐛  Include machinepools in descendant count
  • Loading branch information
k8s-ci-robot authored Mar 11, 2021
2 parents 1f07103 + 78ecded commit 18029d5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion controllers/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ func (c *clusterDescendants) length() int {
return len(c.machineDeployments.Items) +
len(c.machineSets.Items) +
len(c.controlPlaneMachines.Items) +
len(c.workerMachines.Items)
len(c.workerMachines.Items) +
len(c.machinePools.Items)
}

func (c *clusterDescendants) descendantNames() string {
Expand Down
44 changes: 44 additions & 0 deletions controllers/cluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,50 @@ func TestFilterOwnedDescendants(t *testing.T) {
g.Expect(actual).To(Equal(expected))
}

func TestDescendantsLength(t *testing.T) {
g := NewWithT(t)

d := clusterDescendants{
machineDeployments: clusterv1.MachineDeploymentList{
Items: []clusterv1.MachineDeployment{
newMachineDeploymentBuilder().named("md1").build(),
},
},
machineSets: clusterv1.MachineSetList{
Items: []clusterv1.MachineSet{
newMachineSetBuilder().named("ms1").build(),
newMachineSetBuilder().named("ms2").build(),
},
},
controlPlaneMachines: clusterv1.MachineList{
Items: []clusterv1.Machine{
newMachineBuilder().named("m1").build(),
newMachineBuilder().named("m2").build(),
newMachineBuilder().named("m3").build(),
},
},
workerMachines: clusterv1.MachineList{
Items: []clusterv1.Machine{
newMachineBuilder().named("m3").build(),
newMachineBuilder().named("m4").build(),
newMachineBuilder().named("m5").build(),
newMachineBuilder().named("m6").build(),
},
},
machinePools: expv1.MachinePoolList{
Items: []expv1.MachinePool{
newMachinePoolBuilder().named("mp1").build(),
newMachinePoolBuilder().named("mp2").build(),
newMachinePoolBuilder().named("mp3").build(),
newMachinePoolBuilder().named("mp4").build(),
newMachinePoolBuilder().named("mp5").build(),
},
},
}

g.Expect(d.length()).To(Equal(15))
}

func TestReconcileControlPlaneInitializedControlPlaneRef(t *testing.T) {
g := NewWithT(t)

Expand Down

0 comments on commit 18029d5

Please sign in to comment.