Skip to content

Commit 5e5378c

Browse files
authored
Supporting pretty print time.Duration (#33)
1 parent 4557d66 commit 5e5378c

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

cmd/autoscaler/app/autoscaler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func Run(kubeconfigPath string,
2121
metricsGroupKind string) error {
2222
autoScalerOptions := scaler_types.AutoScalerOptions{
2323
Namespace: namespace,
24-
ScaleInterval: scaleInterval,
24+
ScaleInterval: scaler_types.Duration{Duration: scaleInterval},
2525
GroupKind: metricsGroupKind,
2626
}
2727

cmd/dlx/app/dlx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func Run(kubeconfigPath string,
4040
TargetPort: targetPort,
4141
ListenAddress: listenAddress,
4242
Namespace: namespace,
43-
ResourceReadinessTimeout: resourceReadinessTimeoutDuration,
43+
ResourceReadinessTimeout: scaler_types.Duration{Duration: resourceReadinessTimeoutDuration},
4444
}
4545

4646
// see if resource scaler wants to override the arguments

pkg/autoscaler/autoscaler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Autoscaler struct {
1818
logger logger.Logger
1919
namespace string
2020
resourceScaler scaler_types.ResourceScaler
21-
scaleInterval time.Duration
21+
scaleInterval scaler_types.Duration
2222
inScaleToZeroProcessMap map[string]bool
2323
groupKind string
2424
customMetricsClientSet custommetricsv1.CustomMetricsClient
@@ -46,7 +46,7 @@ func NewAutoScaler(parentLogger logger.Logger,
4646
func (as *Autoscaler) Start() error {
4747
as.logger.DebugWith("Starting",
4848
"scaleInterval", as.scaleInterval)
49-
ticker := time.NewTicker(as.scaleInterval)
49+
ticker := time.NewTicker(as.scaleInterval.Duration)
5050

5151
go func() {
5252
for range ticker.C {
@@ -154,8 +154,8 @@ func (as *Autoscaler) checkResourceToScale(resource scaler_types.Resource, resou
154154
func (as *Autoscaler) getMaxScaleResourceWindowSize(resource scaler_types.Resource) time.Duration {
155155
maxWindow := 0 * time.Second
156156
for _, scaleResource := range resource.ScaleResources {
157-
if scaleResource.WindowSize > maxWindow {
158-
maxWindow = scaleResource.WindowSize
157+
if scaleResource.WindowSize.Duration > maxWindow {
158+
maxWindow = scaleResource.WindowSize.Duration
159159
}
160160
}
161161
return maxWindow

pkg/dlx/dlx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func NewDLX(parentLogger logger.Logger,
1919
options scaler_types.DLXOptions) (*DLX, error) {
2020
childLogger := parentLogger.GetChild("dlx")
2121
childLogger.InfoWith("Creating DLX", "options", options)
22-
resourceStarter, err := NewResourceStarter(childLogger, resourceScaler, options.Namespace, options.ResourceReadinessTimeout)
22+
resourceStarter, err := NewResourceStarter(childLogger, resourceScaler, options.Namespace, options.ResourceReadinessTimeout.Duration)
2323
if err != nil {
2424
return nil, errors.Wrap(err, "Failed to create function starter")
2525
}

0 commit comments

Comments
 (0)