From d45227467e564cd87e4055cee4648a2012578e6c Mon Sep 17 00:00:00 2001 From: crgisch Date: Fri, 10 Nov 2023 15:04:41 -0300 Subject: [PATCH 1/6] feat: scheduled autoscale --- go.mod | 1 + go.sum | 2 ++ tsuru/client/apps.go | 58 +++++++++++++++++++++++++++++++++------ tsuru/client/autoscale.go | 34 +++++++++++++++++++++-- 4 files changed, 83 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index babb702eb..79568e22b 100644 --- a/go.mod +++ b/go.mod @@ -49,6 +49,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/kr/pretty v0.3.0 // indirect github.com/kr/text v0.2.0 // indirect + github.com/lnquy/cron v1.1.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/moby/sys/mount v0.3.0 // indirect github.com/moby/sys/mountinfo v0.6.0 // indirect diff --git a/go.sum b/go.sum index 44d507253..6e3f8510c 100644 --- a/go.sum +++ b/go.sum @@ -502,6 +502,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo= +github.com/lnquy/cron v1.1.1 h1:iaDX1ublgQ9LBhA8l9BVU+FrTE1PPSPAuvAdhgdnXgA= +github.com/lnquy/cron v1.1.1/go.mod h1:hu2Y7H68/8oKk6T4+K4qdbopbnaP4rGltK3ylWiiDss= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= diff --git a/tsuru/client/apps.go b/tsuru/client/apps.go index c12f32b6d..f8e192fb8 100644 --- a/tsuru/client/apps.go +++ b/tsuru/client/apps.go @@ -22,6 +22,7 @@ import ( "time" "github.com/ajg/form" + "github.com/lnquy/cron" "github.com/tsuru/gnuflag" "github.com/tsuru/go-tsuruclient/pkg/client" "github.com/tsuru/go-tsuruclient/pkg/tsuru" @@ -744,22 +745,49 @@ func (a *app) String(simplified bool) string { renderServiceInstanceBinds(&buf, a.ServiceInstanceBinds) } - autoScaleTable := tablecli.NewTable() - autoScaleTable.Headers = tablecli.Row([]string{"Process", "Min", "Max", "Target CPU"}) + var autoScaleTables []*tablecli.Table + processes := []string{} + for _, as := range a.AutoScale { - cpu := cpuValue(as.AverageCPU) + autoScaleTable := tablecli.NewTable() + autoScaleTable.LineSeparator = true + + processString := fmt.Sprintf( + "Process: %s (v%d), Min Units: %d, Max Units: %d", + as.Process, as.Version, int(as.MinUnits), int(as.MaxUnits), + ) + processes = append(processes, processString) + + autoScaleTable.Headers = tablecli.Row([]string{ + "Triggers", + "Trigger details", + }) + autoScaleTable.AddRow(tablecli.Row([]string{ - fmt.Sprintf("%s (v%d)", as.Process, as.Version), - strconv.Itoa(int(as.MinUnits)), - strconv.Itoa(int(as.MaxUnits)), - cpu, + "CPU", + "Target: 20%", })) + + for _, schedule := range as.Schedules { + scheduleInfo := buildScheduleInfo(schedule) + autoScaleTable.AddRow(tablecli.Row([]string{ + "Schedule", + scheduleInfo, + })) + } + + autoScaleTables = append(autoScaleTables, autoScaleTable) } - if autoScaleTable.Rows() > 0 { + if len(processes) > 0 { buf.WriteString("\n") buf.WriteString("Auto Scale:\n") - buf.WriteString(autoScaleTable.String()) + for i, asTable := range autoScaleTables { + buf.WriteString("\n") + buf.WriteString(processes[i]) + buf.WriteString("\n") + buf.WriteString(asTable.String()) + } } if !simplified && (a.Plan.Memory != 0 || a.Plan.CPUMilli != 0) { @@ -790,6 +818,18 @@ func (a *app) String(simplified bool) string { return tplBuffer.String() + buf.String() } +func buildScheduleInfo(schedule tsuru.AutoScaleSchedule) string { + // Init with default EN locale + exprDesc, _ := cron.NewDescriptor() + + startTimeHuman, _ := exprDesc.ToDescription(schedule.Start, cron.Locale_en) + endTimeHuman, _ := exprDesc.ToDescription(schedule.End, cron.Locale_en) + + return fmt.Sprintf("Start: %s (%s)\nEnd: %s (%s)\nUnits: %d", + startTimeHuman, schedule.Start, endTimeHuman, schedule.End, schedule.MinReplicas, + ) +} + func (a *app) SimpleServicesView() string { sibs := make([]tsuru.AppServiceInstanceBinds, len(a.ServiceInstanceBinds)) copy(sibs, a.ServiceInstanceBinds) diff --git a/tsuru/client/autoscale.go b/tsuru/client/autoscale.go index 67e89a776..19e176358 100644 --- a/tsuru/client/autoscale.go +++ b/tsuru/client/autoscale.go @@ -6,6 +6,7 @@ package client import ( "context" + "encoding/json" "fmt" "strconv" @@ -29,13 +30,26 @@ type AutoScaleSet struct { cmd.AppNameMixIn fs *gnuflag.FlagSet autoscale tsuru.AutoScaleSpec + schedules cmd.StringSliceFlag } func (c *AutoScaleSet) Info() *cmd.Info { return &cmd.Info{ - Name: "unit-autoscale-set", - Usage: "unit autoscale set [-a/--app appname] [-p/--process processname] [--cpu targetCPU] [--min minUnits] [--max maxUnits]", - Desc: `Sets a unit auto scale configuration.`, + Name: "unit-autoscale-set", + Usage: "unit autoscale set [-a/--app appname] [-p/--process processname] [--cpu targetCPU] [--min minUnits] [--max maxUnits] [--schedule scheduleWindow]", + Desc: ` +# Sets an autoscale configuration: +# Based on 50% of CPU utilization with min units 1 and max units 3 +unit autoscale set -a my-app --cpu 50% --min 1 --max 3 + +# Based on a schedule window everyday from 6AM to 6PM UTC +unit autoscale set -a my-app --min 1 --max 3 --schedule '{"minReplicas": 2, "start": "0 6 * * *", "end": "0 18 * * *"}' + +# Combining both +unit autoscale set -a my-app --cpu 50% --min 1 --max 3 --schedule '{"minReplicas": 2, "start": "0 6 * * *", "end": "0 18 * * *"}' + +# When using more than one trigger (CPU + Schedule as an exemple), the number of units will be determined by the highest value +`, MinArgs: 0, MaxArgs: 0, } @@ -54,6 +68,8 @@ func (c *AutoScaleSet) Flags() *gnuflag.FlagSet { c.fs.Var((*int32Value)(&c.autoscale.MinUnits), "min", "Minimum Units") c.fs.Var((*int32Value)(&c.autoscale.MaxUnits), "max", "Maximum Units") + + c.fs.Var(&c.schedules, "schedule", "Schedule window to up/down scale. Example: {\"minReplicas\": 2, \"start\": \"0 6 * * *\", \"end\": \"0 18 * * *\"}") } return c.fs } @@ -70,6 +86,18 @@ func (c *AutoScaleSet) Run(ctx *cmd.Context, cli *cmd.Client) error { return err } + schedules := []tsuru.AutoScaleSchedule{} + for _, scheduleString := range c.schedules { + var autoScaleSchedule tsuru.AutoScaleSchedule + if err := json.Unmarshal([]byte(scheduleString), &autoScaleSchedule); err != nil { + return err + } + + schedules = append(schedules, autoScaleSchedule) + } + + c.autoscale.Schedules = schedules + _, err = apiClient.AppApi.AutoScaleAdd(context.TODO(), appName, c.autoscale) if err != nil { return err From 4e0816e0a6f3a2d1bc08640b00e5f04cad79ebda Mon Sep 17 00:00:00 2001 From: crgisch Date: Fri, 10 Nov 2023 15:05:15 -0300 Subject: [PATCH 2/6] test: scheduled autoscale --- tsuru/client/apps_test.go | 154 +++++++++++++++++++++++++++++++-- tsuru/client/autoscale_test.go | 53 ++++++++++++ 2 files changed, 201 insertions(+), 6 deletions(-) diff --git a/tsuru/client/apps_test.go b/tsuru/client/apps_test.go index 371c05d53..2d2e8e786 100644 --- a/tsuru/client/apps_test.go +++ b/tsuru/client/apps_test.go @@ -1606,12 +1606,154 @@ Units [process worker]: 1 +--------+---------+------+------+ Auto Scale: -+--------------+-----+-----+------------+ -| Process | Min | Max | Target CPU | -+--------------+-----+-----+------------+ -| web (v10) | 1 | 10 | 50% | -| worker (v10) | 2 | 5 | 200% | -+--------------+-----+-----+------------+ + +Process: web (v10), Min Units: 1, Max Units: 10 ++----------+-----------------+ +| Triggers | Trigger details | ++----------+-----------------+ +| CPU | Target: 20% | ++----------+-----------------+ + +Process: worker (v10), Min Units: 2, Max Units: 5 ++----------+-----------------+ +| Triggers | Trigger details | ++----------+-----------------+ +| CPU | Target: 20% | ++----------+-----------------+ + +` + context := cmd.Context{ + Stdout: &stdout, + Stderr: &stderr, + } + client := cmd.NewClient(&http.Client{Transport: &cmdtest.Transport{Message: result, Status: http.StatusOK}}, nil, manager) + command := AppInfo{} + command.Flags().Parse(true, []string{"--app", "app1"}) + err := command.Run(&context, client) + c.Assert(err, check.IsNil) + c.Assert(stdout.String(), check.Equals, expected) +} + +func (s *S) TestAppInfoWithKEDAAutoScale(c *check.C) { + var stdout, stderr bytes.Buffer + result := `{ + "name": "app1", + "teamowner": "myteam", + "cname": [ + "" + ], + "ip": "myapp.tsuru.io", + "platform": "php", + "repository": "git@git.com:php.git", + "state": "dead", + "units": [ + { + "ID": "app1/0", + "Status": "started", + "ProcessName": "web" + }, + { + "ID": "app1/1", + "Status": "started", + "ProcessName": "worker" + } + ], + "teams": [ + "tsuruteam", + "crane" + ], + "owner": "myapp_owner", + "deploys": 7, + "router": "planb", + "autoscale": [ + { + "process":"web", + "minUnits":1, + "maxUnits":10, + "averageCPU":"500m", + "version":10, + "schedules": [ + { + "minReplicas":2, + "start":"0 6 * * *", + "end":"0 18 * * *", + "timezone":"UTC" + },{ + "minReplicas":3, + "start":"0 12 * * *", + "end":"0 15 * * *", + "timezone":"UTC" + } + ] + }, + { + "process":"worker", + "minUnits":2, + "maxUnits":5, + "averageCPU":"2", + "version":10, + "schedules": [ + { + "minReplicas":1, + "start":"0 0 * * *", + "end":"0 6 * * *", + "timezone":"UTC" + } + ] + } + ] +}` + expected := `Application: app1 +Platform: php +Router: planb +Teams: myteam (owner), tsuruteam, crane +External Addresses: myapp.tsuru.io +Created by: myapp_owner +Deploys: 7 +Pool: +Quota: 0/0 units + +Units [process web]: 1 ++--------+---------+------+------+ +| Name | Status | Host | Port | ++--------+---------+------+------+ +| app1/0 | started | | | ++--------+---------+------+------+ + +Units [process worker]: 1 ++--------+---------+------+------+ +| Name | Status | Host | Port | ++--------+---------+------+------+ +| app1/1 | started | | | ++--------+---------+------+------+ + +Auto Scale: + +Process: web (v10), Min Units: 1, Max Units: 10 ++----------+---------------------------------+ +| Triggers | Trigger details | ++----------+---------------------------------+ +| CPU | Target: 20% | ++----------+---------------------------------+ +| Schedule | Start: At 06:00 AM (0 6 * * *) | +| | End: At 06:00 PM (0 18 * * *) | +| | Units: 2 | ++----------+---------------------------------+ +| Schedule | Start: At 12:00 PM (0 12 * * *) | +| | End: At 03:00 PM (0 15 * * *) | +| | Units: 3 | ++----------+---------------------------------+ + +Process: worker (v10), Min Units: 2, Max Units: 5 ++----------+--------------------------------+ +| Triggers | Trigger details | ++----------+--------------------------------+ +| CPU | Target: 20% | ++----------+--------------------------------+ +| Schedule | Start: At 12:00 AM (0 0 * * *) | +| | End: At 06:00 AM (0 6 * * *) | +| | Units: 1 | ++----------+--------------------------------+ ` context := cmd.Context{ diff --git a/tsuru/client/autoscale_test.go b/tsuru/client/autoscale_test.go index 7cf94d64f..2aca98a52 100644 --- a/tsuru/client/autoscale_test.go +++ b/tsuru/client/autoscale_test.go @@ -53,6 +53,59 @@ func (s *S) TestAutoScaleSet(c *check.C) { c.Assert(stdout.String(), check.Equals, expected) } +func (s *S) TestKEDAAutoScaleSet(c *check.C) { + var stdout, stderr bytes.Buffer + expected := "Unit auto scale successfully set.\n" + context := cmd.Context{ + Stdout: &stdout, + Stderr: &stderr, + Args: []string{}, + } + trans := cmdtest.ConditionalTransport{ + Transport: cmdtest.Transport{Message: "", Status: http.StatusOK}, + CondFunc: func(r *http.Request) bool { + c.Assert(r.URL.Path, check.Equals, "/1.9/apps/myapp/units/autoscale") + c.Assert(r.Method, check.Equals, "POST") + var ret tsuru.AutoScaleSpec + c.Assert(r.Header.Get("Content-Type"), check.Equals, "application/json") + data, err := io.ReadAll(r.Body) + c.Assert(err, check.IsNil) + err = json.Unmarshal(data, &ret) + c.Assert(err, check.IsNil) + c.Assert(ret, check.DeepEquals, tsuru.AutoScaleSpec{ + AverageCPU: "30%", + MinUnits: 2, + MaxUnits: 5, + Process: "proc1", + Schedules: []tsuru.AutoScaleSchedule{ + { + MinReplicas: 2, + Start: "0 6 * * *", + End: "0 18 * * *", + }, + { + MinReplicas: 1, + Start: "0 18 * * *", + End: "0 0 * * *", + }, + }, + }) + return true + }, + } + client := cmd.NewClient(&http.Client{Transport: &trans}, nil, manager) + command := AutoScaleSet{} + command.Info() + command.Flags().Parse(true, []string{ + "-a", "myapp", "-p", "proc1", "--min", "2", "--max", "5", "--cpu", "30%", + "--schedule", "{\"minReplicas\": 2, \"start\": \"0 6 * * *\", \"end\": \"0 18 * * *\"}", + "--schedule", "{\"minReplicas\": 1, \"start\": \"0 18 * * *\", \"end\": \"0 0 * * *\"}", + }) + err := command.Run(&context, client) + c.Assert(err, check.IsNil) + c.Assert(stdout.String(), check.Equals, expected) +} + func (s *S) TestAutoScaleUnset(c *check.C) { var stdout, stderr bytes.Buffer expected := "Unit auto scale successfully unset.\n" From 70eefe31a3f5d3df0336bac81920612f25e3bda8 Mon Sep 17 00:00:00 2001 From: crgisch Date: Wed, 22 Nov 2023 14:06:19 -0300 Subject: [PATCH 3/6] fix: autoscale cpu trigger info --- tsuru/client/apps.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tsuru/client/apps.go b/tsuru/client/apps.go index f8e192fb8..02067803b 100644 --- a/tsuru/client/apps.go +++ b/tsuru/client/apps.go @@ -763,10 +763,13 @@ func (a *app) String(simplified bool) string { "Trigger details", }) - autoScaleTable.AddRow(tablecli.Row([]string{ - "CPU", - "Target: 20%", - })) + if as.AverageCPU != "" { + cpu := cpuValue(as.AverageCPU) + autoScaleTable.AddRow(tablecli.Row([]string{ + "CPU", + fmt.Sprintf("Target: %s", cpu), + })) + } for _, schedule := range as.Schedules { scheduleInfo := buildScheduleInfo(schedule) From 0df4464b1ae351e071ebd6b34c6870b528a97b74 Mon Sep 17 00:00:00 2001 From: crgisch Date: Fri, 24 Nov 2023 11:36:43 -0300 Subject: [PATCH 4/6] feat: add Timezone info to Autoscale --- tsuru/client/apps.go | 4 ++-- tsuru/client/apps_test.go | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tsuru/client/apps.go b/tsuru/client/apps.go index 02067803b..3210391ab 100644 --- a/tsuru/client/apps.go +++ b/tsuru/client/apps.go @@ -828,8 +828,8 @@ func buildScheduleInfo(schedule tsuru.AutoScaleSchedule) string { startTimeHuman, _ := exprDesc.ToDescription(schedule.Start, cron.Locale_en) endTimeHuman, _ := exprDesc.ToDescription(schedule.End, cron.Locale_en) - return fmt.Sprintf("Start: %s (%s)\nEnd: %s (%s)\nUnits: %d", - startTimeHuman, schedule.Start, endTimeHuman, schedule.End, schedule.MinReplicas, + return fmt.Sprintf("Start: %s (%s)\nEnd: %s (%s)\nUnits: %d\nTimezone: %s", + startTimeHuman, schedule.Start, endTimeHuman, schedule.End, schedule.MinReplicas, schedule.Timezone, ) } diff --git a/tsuru/client/apps_test.go b/tsuru/client/apps_test.go index 2d2e8e786..2eb9ec723 100644 --- a/tsuru/client/apps_test.go +++ b/tsuru/client/apps_test.go @@ -1611,14 +1611,14 @@ Process: web (v10), Min Units: 1, Max Units: 10 +----------+-----------------+ | Triggers | Trigger details | +----------+-----------------+ -| CPU | Target: 20% | +| CPU | Target: 50% | +----------+-----------------+ Process: worker (v10), Min Units: 2, Max Units: 5 +----------+-----------------+ | Triggers | Trigger details | +----------+-----------------+ -| CPU | Target: 20% | +| CPU | Target: 200% | +----------+-----------------+ ` @@ -1697,7 +1697,7 @@ func (s *S) TestAppInfoWithKEDAAutoScale(c *check.C) { "minReplicas":1, "start":"0 0 * * *", "end":"0 6 * * *", - "timezone":"UTC" + "timezone":"America/Sao_Paulo" } ] } @@ -1733,26 +1733,29 @@ Process: web (v10), Min Units: 1, Max Units: 10 +----------+---------------------------------+ | Triggers | Trigger details | +----------+---------------------------------+ -| CPU | Target: 20% | +| CPU | Target: 50% | +----------+---------------------------------+ | Schedule | Start: At 06:00 AM (0 6 * * *) | | | End: At 06:00 PM (0 18 * * *) | | | Units: 2 | +| | Timezone: UTC | +----------+---------------------------------+ | Schedule | Start: At 12:00 PM (0 12 * * *) | | | End: At 03:00 PM (0 15 * * *) | | | Units: 3 | +| | Timezone: UTC | +----------+---------------------------------+ Process: worker (v10), Min Units: 2, Max Units: 5 +----------+--------------------------------+ | Triggers | Trigger details | +----------+--------------------------------+ -| CPU | Target: 20% | +| CPU | Target: 200% | +----------+--------------------------------+ | Schedule | Start: At 12:00 AM (0 0 * * *) | | | End: At 06:00 AM (0 6 * * *) | | | Units: 1 | +| | Timezone: America/Sao_Paulo | +----------+--------------------------------+ ` From 77d97b1f080c9283ae29fe768aa706b405d4a5f5 Mon Sep 17 00:00:00 2001 From: crgisch Date: Fri, 24 Nov 2023 15:56:34 -0300 Subject: [PATCH 5/6] chore: update go-tsuruclient package --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 79568e22b..3a9c76d4f 100644 --- a/go.mod +++ b/go.mod @@ -8,13 +8,14 @@ require ( github.com/antihax/optional v1.0.0 github.com/ghodss/yaml v1.0.0 github.com/iancoleman/orderedmap v0.2.0 + github.com/lnquy/cron v1.1.1 github.com/mattn/go-shellwords v1.0.12 github.com/mitchellh/go-wordwrap v1.0.1 github.com/pkg/errors v0.9.1 github.com/pmorie/go-open-service-broker-client v0.0.0-20180330214919-dca737037ce6 github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa - github.com/tsuru/go-tsuruclient v0.0.0-20231031185823-b0abac462f59 + github.com/tsuru/go-tsuruclient v0.0.0-20231124151049-7b8d8ea2ee30 github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6 github.com/tsuru/tsuru v0.0.0-20231009130140-65592312e508 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c @@ -49,7 +50,6 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/kr/pretty v0.3.0 // indirect github.com/kr/text v0.2.0 // indirect - github.com/lnquy/cron v1.1.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/moby/sys/mount v0.3.0 // indirect github.com/moby/sys/mountinfo v0.6.0 // indirect diff --git a/go.sum b/go.sum index 6e3f8510c..6a2b2fe26 100644 --- a/go.sum +++ b/go.sum @@ -735,8 +735,8 @@ github.com/tsuru/config v0.0.0-20201023175036-375aaee8b560 h1:fniQ/BmYAHdnNmY333 github.com/tsuru/config v0.0.0-20201023175036-375aaee8b560/go.mod h1:mj6t8JKWU51GScTT50XRmDj65T5XhTyNvO5FUNV5zS4= github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa h1:JlLQP1xa13a994p/Aau2e3K9xXYaHNoNvTDVIMHSUa4= github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa/go.mod h1:UibOSvkMFKRe/eiwktAPAvQG8L+p8nYsECJvu3Dgw7I= -github.com/tsuru/go-tsuruclient v0.0.0-20231031185823-b0abac462f59 h1:RgFlupHEAJvIXH6FgtzGQqG8pS6ck3miqEXZN+a4dLs= -github.com/tsuru/go-tsuruclient v0.0.0-20231031185823-b0abac462f59/go.mod h1:BmePxHey9hxrxk0kzTMHFFr7aJWXSxtlrUx6FIeV0Ic= +github.com/tsuru/go-tsuruclient v0.0.0-20231124151049-7b8d8ea2ee30 h1:lPzNgSgTz+27YI5vCwEAGENgzNYb0gNtYcke0WuQsbk= +github.com/tsuru/go-tsuruclient v0.0.0-20231124151049-7b8d8ea2ee30/go.mod h1:BmePxHey9hxrxk0kzTMHFFr7aJWXSxtlrUx6FIeV0Ic= github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6 h1:1XDdWFAjIbCSG1OjN9v9KdWhuM8UtYlFcfHe/Ldkchk= github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6/go.mod h1:ztYpOhW+u1k21FEqp7nZNgpWbr0dUKok5lgGCZi+1AQ= github.com/tsuru/tsuru v0.0.0-20231009130140-65592312e508 h1:eaMg/uBeTv6B7O+AMTq3OKqNsiA0/kB5Zkgy7ipXgcI= From fdef0223bfaecd68112611699112a1ad6ae5d3f4 Mon Sep 17 00:00:00 2001 From: crgisch Date: Fri, 24 Nov 2023 16:00:59 -0300 Subject: [PATCH 6/6] fix: lint --- tsuru/client/autoscale.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsuru/client/autoscale.go b/tsuru/client/autoscale.go index 19e176358..8d9aaf4cd 100644 --- a/tsuru/client/autoscale.go +++ b/tsuru/client/autoscale.go @@ -48,7 +48,7 @@ unit autoscale set -a my-app --min 1 --max 3 --schedule '{"minReplicas": 2, "sta # Combining both unit autoscale set -a my-app --cpu 50% --min 1 --max 3 --schedule '{"minReplicas": 2, "start": "0 6 * * *", "end": "0 18 * * *"}' -# When using more than one trigger (CPU + Schedule as an exemple), the number of units will be determined by the highest value +# When using more than one trigger (CPU + Schedule as an example), the number of units will be determined by the highest value `, MinArgs: 0, MaxArgs: 0, @@ -89,7 +89,7 @@ func (c *AutoScaleSet) Run(ctx *cmd.Context, cli *cmd.Client) error { schedules := []tsuru.AutoScaleSchedule{} for _, scheduleString := range c.schedules { var autoScaleSchedule tsuru.AutoScaleSchedule - if err := json.Unmarshal([]byte(scheduleString), &autoScaleSchedule); err != nil { + if err = json.Unmarshal([]byte(scheduleString), &autoScaleSchedule); err != nil { return err }