Skip to content

Commit

Permalink
Hide ConfigMap support behing flag
Browse files Browse the repository at this point in the history
  • Loading branch information
katyanna committed Oct 17, 2023
1 parent e38f779 commit ac2dda4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cmd/stackset-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
RouteGroupSupportEnabled bool
IngressSourceSwitchTTL time.Duration
ReconcileWorkers int
ConfigMapSupportEnabled bool
}
)

Expand All @@ -59,6 +60,7 @@ func main() {
kingpin.Flag("enable-routegroup-support", "Enable support for RouteGroups on StackSets.").Default("false").BoolVar(&config.RouteGroupSupportEnabled)
kingpin.Flag("ingress-source-switch-ttl", "The ttl before an ingress source is deleted when replaced with another one e.g. switching from RouteGroup to Ingress or vice versa.").
Default(defaultIngressSourceSwitchTTL).DurationVar(&config.IngressSourceSwitchTTL)
kingpin.Flag("enable-configmap-support", "Enable support for ConfigMaps on StackSets.").Default("false").BoolVar(&config.ConfigMapSupportEnabled)
kingpin.Parse()

if config.Debug {
Expand Down Expand Up @@ -86,6 +88,7 @@ func main() {
config.Interval,
config.RouteGroupSupportEnabled,
config.IngressSourceSwitchTTL,
config.ConfigMapSupportEnabled,
)
if err != nil {
log.Fatalf("Failed to create Stackset controller: %v", err)
Expand Down
25 changes: 20 additions & 5 deletions controller/stackset.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type StackSetController struct {
ingressSourceSwitchTTL time.Duration
now func() string
reconcileWorkers int
configMapSupportEnabled bool
sync.Mutex
}

Expand All @@ -85,7 +86,18 @@ func now() string {
}

// NewStackSetController initializes a new StackSetController.
func NewStackSetController(client clientset.Interface, controllerID string, parallelWork int, backendWeightsAnnotationKey string, clusterDomains []string, registry prometheus.Registerer, interval time.Duration, routeGroupSupportEnabled bool, ingressSourceSwitchTTL time.Duration) (*StackSetController, error) {
func NewStackSetController(
client clientset.Interface,
controllerID string,
parallelWork int,
backendWeightsAnnotationKey string,
clusterDomains []string,
registry prometheus.Registerer,
interval time.Duration,
routeGroupSupportEnabled bool,
ingressSourceSwitchTTL time.Duration,
configMapSupportEnabled bool,
) (*StackSetController, error) {
metricsReporter, err := core.NewMetricsReporter(registry)
if err != nil {
return nil, err
Expand All @@ -105,6 +117,7 @@ func NewStackSetController(client clientset.Interface, controllerID string, para
HealthReporter: healthcheck.NewHandler(),
routeGroupSupportEnabled: routeGroupSupportEnabled,
ingressSourceSwitchTTL: ingressSourceSwitchTTL,
configMapSupportEnabled: configMapSupportEnabled,
now: now,
reconcileWorkers: parallelWork,
}, nil
Expand Down Expand Up @@ -990,12 +1003,14 @@ func (c *StackSetController) ReconcileStackSetDesiredTraffic(ctx context.Context
}

func (c *StackSetController) ReconcileStackResources(ctx context.Context, ssc *core.StackSetContainer, sc *core.StackContainer) error {
err := c.ReconcileStackConfigMap(ctx, sc.Stack, sc.Resources.ConfigMaps, sc.GenerateConfigMap)
if err != nil {
return c.errorEventf(sc.Stack, "FailedManageConfigMap", err)
if c.configMapSupportEnabled {
err := c.ReconcileStackConfigMap(ctx, sc.Stack, sc.Resources.ConfigMaps, sc.GenerateConfigMap)
if err != nil {
return c.errorEventf(sc.Stack, "FailedManageConfigMap", err)
}
}

err = c.ReconcileStackDeployment(ctx, sc.Stack, sc.Resources.Deployment, sc.GenerateDeployment)
err := c.ReconcileStackDeployment(ctx, sc.Stack, sc.Resources.Deployment, sc.GenerateDeployment)
if err != nil {
return c.errorEventf(sc.Stack, "FailedManageDeployment", err)
}
Expand Down

0 comments on commit ac2dda4

Please sign in to comment.