Skip to content

Commit

Permalink
Supporting pretty print time.Duration (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber authored Dec 29, 2019
1 parent 4557d66 commit 5e5378c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/autoscaler/app/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func Run(kubeconfigPath string,
metricsGroupKind string) error {
autoScalerOptions := scaler_types.AutoScalerOptions{
Namespace: namespace,
ScaleInterval: scaleInterval,
ScaleInterval: scaler_types.Duration{Duration: scaleInterval},
GroupKind: metricsGroupKind,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/dlx/app/dlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Run(kubeconfigPath string,
TargetPort: targetPort,
ListenAddress: listenAddress,
Namespace: namespace,
ResourceReadinessTimeout: resourceReadinessTimeoutDuration,
ResourceReadinessTimeout: scaler_types.Duration{Duration: resourceReadinessTimeoutDuration},
}

// see if resource scaler wants to override the arguments
Expand Down
8 changes: 4 additions & 4 deletions pkg/autoscaler/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Autoscaler struct {
logger logger.Logger
namespace string
resourceScaler scaler_types.ResourceScaler
scaleInterval time.Duration
scaleInterval scaler_types.Duration
inScaleToZeroProcessMap map[string]bool
groupKind string
customMetricsClientSet custommetricsv1.CustomMetricsClient
Expand Down Expand Up @@ -46,7 +46,7 @@ func NewAutoScaler(parentLogger logger.Logger,
func (as *Autoscaler) Start() error {
as.logger.DebugWith("Starting",
"scaleInterval", as.scaleInterval)
ticker := time.NewTicker(as.scaleInterval)
ticker := time.NewTicker(as.scaleInterval.Duration)

go func() {
for range ticker.C {
Expand Down Expand Up @@ -154,8 +154,8 @@ func (as *Autoscaler) checkResourceToScale(resource scaler_types.Resource, resou
func (as *Autoscaler) getMaxScaleResourceWindowSize(resource scaler_types.Resource) time.Duration {
maxWindow := 0 * time.Second
for _, scaleResource := range resource.ScaleResources {
if scaleResource.WindowSize > maxWindow {
maxWindow = scaleResource.WindowSize
if scaleResource.WindowSize.Duration > maxWindow {
maxWindow = scaleResource.WindowSize.Duration
}
}
return maxWindow
Expand Down
2 changes: 1 addition & 1 deletion pkg/dlx/dlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewDLX(parentLogger logger.Logger,
options scaler_types.DLXOptions) (*DLX, error) {
childLogger := parentLogger.GetChild("dlx")
childLogger.InfoWith("Creating DLX", "options", options)
resourceStarter, err := NewResourceStarter(childLogger, resourceScaler, options.Namespace, options.ResourceReadinessTimeout)
resourceStarter, err := NewResourceStarter(childLogger, resourceScaler, options.Namespace, options.ResourceReadinessTimeout.Duration)
if err != nil {
return nil, errors.Wrap(err, "Failed to create function starter")
}
Expand Down

0 comments on commit 5e5378c

Please sign in to comment.