Skip to content

Commit

Permalink
Merge pull request #53 from bison/autoscaler-verbosity
Browse files Browse the repository at this point in the history
Add configuration option for autoscaler logging verbosity
  • Loading branch information
openshift-merge-robot committed Feb 25, 2019
2 parents 13d320f + c8d87ee commit da772db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/controller/clusterautoscaler/clusterautoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
CoresTotalArg AutoscalerArg = "--cores-total"
MemoryTotalArg AutoscalerArg = "--memory-total"
GPUTotalArg AutoscalerArg = "--gpu-total"
VerbosityArg AutoscalerArg = "--v"
)

// AutoscalerArgs returns a slice of strings representing command line arguments
Expand All @@ -57,6 +58,7 @@ func AutoscalerArgs(ca *v1alpha1.ClusterAutoscaler, cfg *Config) []string {

args := []string{
LogToStderrArg.String(),
VerbosityArg.Value(cfg.Verbosity),
CloudProviderArg.Value(cfg.CloudProvider),
NamespaceArg.Value(cfg.Namespace),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ type Config struct {
Replicas int32
// The name of the CloudProvider.
CloudProvider string
// The log verbosity level for the cluster-autoscaler.
Verbosity int
}

var _ reconcile.Reconciler = &Reconciler{}
Expand Down
19 changes: 19 additions & 0 deletions pkg/operator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const (
// DefaultClusterAutoscalerCloudProvider is the default name for
// the CloudProvider beeing used.
DefaultClusterAutoscalerCloudProvider = "openshift-machine-api"

// DefaultClusterAutoscalerVerbosity is the default logging
// verbosity level for ClusterAutoscaler deployments.
DefaultClusterAutoscalerVerbosity = 1
)

// Config represents the runtime configuration for the operator.
Expand Down Expand Up @@ -80,6 +84,10 @@ type Config struct {
// ClusterAutoscalerCloudProvider is the name for the
// CloudProvider beeing used.
ClusterAutoscalerCloudProvider string

// ClusterAutoscalerVerbosity is the logging verbosity level for
// ClusterAutoscaler deployments.
ClusterAutoscalerVerbosity int
}

// NewConfig returns a new Config object with defaults set.
Expand All @@ -94,6 +102,7 @@ func NewConfig() *Config {
ClusterAutoscalerImage: DefaultClusterAutoscalerImage,
ClusterAutoscalerReplicas: DefaultClusterAutoscalerReplicas,
ClusterAutoscalerCloudProvider: DefaultClusterAutoscalerCloudProvider,
ClusterAutoscalerVerbosity: DefaultClusterAutoscalerVerbosity,
}
}

Expand Down Expand Up @@ -140,5 +149,15 @@ func ConfigFromEnvironment() *Config {
config.ClusterAutoscalerNamespace = caNamespace
}

if caVerbosity, ok := os.LookupEnv("CLUSTER_AUTOSCALER_VERBOSITY"); ok {
v, err := strconv.Atoi(caVerbosity)
if err != nil {
v = DefaultClusterAutoscalerVerbosity
glog.Errorf("Error parsing CLUSTER_AUTOSCALER_VERBOSITY environment variable: %v", err)
}

config.ClusterAutoscalerVerbosity = v
}

return config
}
1 change: 1 addition & 0 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (o *Operator) AddControllers() error {
Replicas: o.config.ClusterAutoscalerReplicas,
Namespace: o.config.ClusterAutoscalerNamespace,
CloudProvider: o.config.ClusterAutoscalerCloudProvider,
Verbosity: o.config.ClusterAutoscalerVerbosity,
})

if err := ca.AddToManager(o.manager); err != nil {
Expand Down

0 comments on commit da772db

Please sign in to comment.