From 5d01bde3104e41292ecd57c751e4fe34fdc7fe5a Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Tue, 8 Oct 2024 14:40:39 +0800 Subject: [PATCH] Fix the default stages repeatedly --- pkg/kwokctl/runtime/cluster.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/pkg/kwokctl/runtime/cluster.go b/pkg/kwokctl/runtime/cluster.go index 771cacc0b..cf2eb96d5 100644 --- a/pkg/kwokctl/runtime/cluster.go +++ b/pkg/kwokctl/runtime/cluster.go @@ -177,34 +177,20 @@ func (c *Cluster) Save(ctx context.Context) error { kwokConfigs := config.FilterWithTypeFromContext[*internalversion.KwokConfiguration](ctx) objs = appendIntoInternalObjects(objs, kwokConfigs...) - if !slices.Contains(conf.Options.EnableCRDs, v1alpha1.StageKind) && - conf.Options.Runtime != consts.RuntimeTypeKind && - conf.Options.Runtime != consts.RuntimeTypeKindPodman && - conf.Options.Runtime != consts.RuntimeTypeKindNerdctl && - conf.Options.Runtime != consts.RuntimeTypeKindLima && - conf.Options.Runtime != consts.RuntimeTypeKindFinch && - len(config.FilterWithTypeFromContext[*internalversion.Stage](ctx)) == 0 { - defaultStages, err := c.getDefaultStages(conf.Options.NodeStatusUpdateFrequencyMilliseconds, conf.Options.NodeLeaseDurationSeconds != 0) - if err != nil { - return err - } - objs = appendIntoInternalObjects(objs, defaultStages...) - } - if !slices.Contains(conf.Options.EnableCRDs, v1alpha1.StageKind) { - if conf.Options.Runtime != consts.RuntimeTypeKind && + stages := config.FilterWithTypeFromContext[*internalversion.Stage](ctx) + if len(stages) == 0 && + conf.Options.Runtime != consts.RuntimeTypeKind && conf.Options.Runtime != consts.RuntimeTypeKindPodman && conf.Options.Runtime != consts.RuntimeTypeKindNerdctl && conf.Options.Runtime != consts.RuntimeTypeKindLima && - conf.Options.Runtime != consts.RuntimeTypeKindFinch && - len(config.FilterWithTypeFromContext[*internalversion.Stage](ctx)) == 0 { + conf.Options.Runtime != consts.RuntimeTypeKindFinch { defaultStages, err := c.getDefaultStages(conf.Options.NodeStatusUpdateFrequencyMilliseconds, conf.Options.NodeLeaseDurationSeconds != 0) if err != nil { return err } objs = appendIntoInternalObjects(objs, defaultStages...) } else { - stages := config.FilterWithTypeFromContext[*internalversion.Stage](ctx) objs = appendIntoInternalObjects(objs, stages...) } }