Skip to content

Commit b0023c2

Browse files
authored
Deduplicate k0s args for control plane (#1127)
Signed-off-by: Alexey Makhov <[email protected]> Signed-off-by: makhov <[email protected]>
1 parent 026fffc commit b0023c2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

internal/controller/controlplane/helper.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,15 +605,18 @@ func normalizeK0sConfigSpec(kcp *cpv1beta1.K0sControlPlane, bootstrapConfig boot
605605
}
606606

607607
// Remove duplicated values generated bootstrap controller in order to compared it with kcp.
608+
bootstrapConfig.Spec.K0sConfigSpec.Args = uniqueArgs(kcp.Spec.K0sConfigSpec.Args)
609+
}
610+
611+
func uniqueArgs(args []string) []string {
608612
uniqueArgsSlice := []string{}
609613
uniqueArgsMap := make(map[string]struct{})
610-
for _, arg := range bootstrapConfig.Spec.K0sConfigSpec.Args {
614+
for _, arg := range args {
611615
if _, exists := uniqueArgsMap[arg]; !exists {
612616
uniqueArgsSlice = append(uniqueArgsSlice, arg)
613617
uniqueArgsMap[arg] = struct{}{}
614618
}
615619
}
616-
if len(uniqueArgsSlice) > 0 {
617-
bootstrapConfig.Spec.K0sConfigSpec.Args = uniqueArgsSlice
618-
}
620+
621+
return uniqueArgsSlice
619622
}

internal/controller/controlplane/k0s_controlplane_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@ func (c *K0sController) deleteK0sNodeResources(ctx context.Context, cluster *clu
588588
}
589589

590590
func (c *K0sController) createBootstrapConfig(ctx context.Context, name string, _ *clusterv1.Cluster, kcp *cpv1beta1.K0sControlPlane, machine *clusterv1.Machine, clusterName string) error {
591+
592+
kcp.Spec.K0sConfigSpec.Args = uniqueArgs(kcp.Spec.K0sConfigSpec.Args)
593+
591594
controllerConfig := bootstrapv1.K0sControllerConfig{
592595
TypeMeta: metav1.TypeMeta{
593596
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",

0 commit comments

Comments
 (0)