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

🐛 Include machinepools in descendant count #4295

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a unit test we can add to validate this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah can do, didn't notice any existing ones but I'm happy to add one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a simple unit test.

}

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 @@ -667,6 +667,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