Skip to content

Commit

Permalink
plugin: Fix view of schedule of autoscale
Browse files Browse the repository at this point in the history
Co-authored-by: Claudio Gisch <claudio.gisch@hotmail.com>
  • Loading branch information
wpjunior and crgisch committed Jan 30, 2024
1 parent bd559c0 commit faf2433
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
7 changes: 6 additions & 1 deletion cmd/plugin/rpaasv2/cmd/autoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,13 @@ func writeAutoscale(w io.Writer, autoscale *autogenerated.Autoscale) {
human, _ := exprDesc.ToDescription(s.Start, cron.Locale_en)
fmt.Fprintf(&schedules, " Start: %s (%s)\n", human, s.Start)

human, _ = exprDesc.ToDescription(s.Start, cron.Locale_en)
human, _ = exprDesc.ToDescription(s.End, cron.Locale_en)
fmt.Fprintf(&schedules, " End: %s (%s)", human, s.End)

timezone := s.GetTimezone()
if timezone != "" {
fmt.Fprintf(&schedules, "\n Timezone: %s", timezone)
}
}

if text := schedules.String(); text != "" {
Expand Down
10 changes: 6 additions & 4 deletions cmd/plugin/rpaasv2/cmd/autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/utils/pointer"

"github.com/tsuru/rpaas-operator/pkg/rpaas/client/autogenerated"
)
Expand Down Expand Up @@ -70,7 +71,7 @@ max replicas: 5
Schedules: []autogenerated.ScheduledWindow{
{MinReplicas: 1, Start: "00 08 * * 1-5", End: "00 20 * * 1-5"},
{MinReplicas: 5, Start: "00 20 * * 2", End: "00 01 * * 3"},
{MinReplicas: 5, Start: "00 22 * * 0", End: "00 02 * * 1"},
{MinReplicas: 5, Start: "00 22 * * 0", End: "00 02 * * 1", Timezone: pointer.String("America/Chile")},
},
})
}),
Expand All @@ -82,17 +83,18 @@ max replicas: 100
| Schedule(s) | Window 1: |
| | Min replicas: 1 |
| | Start: At 08:00 AM, Monday through Friday (00 08 * * 1-5) |
| | End: At 08:00 AM, Monday through Friday (00 20 * * 1-5) |
| | End: At 08:00 PM, Monday through Friday (00 20 * * 1-5) |
| | |
| | Window 2: |
| | Min replicas: 5 |
| | Start: At 08:00 PM, only on Tuesday (00 20 * * 2) |
| | End: At 08:00 PM, only on Tuesday (00 01 * * 3) |
| | End: At 01:00 AM, only on Wednesday (00 01 * * 3) |
| | |
| | Window 3: |
| | Min replicas: 5 |
| | Start: At 10:00 PM, only on Sunday (00 22 * * 0) |
| | End: At 10:00 PM, only on Sunday (00 02 * * 1) |
| | End: At 02:00 AM, only on Monday (00 02 * * 1) |
| | Timezone: America/Chile |
+-------------+-------------------------------------------------------------+
`,
},
Expand Down
4 changes: 4 additions & 0 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,10 @@ components:
type: string
description: An Cron expression defining the end of the scheduled window.
example: "00 00 * * * 1-5"
timezone:
type: string
description: Timezone is a zone name registered on IANA time zone database, default is UTC.
example: "America/Sao_Paulo"
required:
- minReplicas
- start
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
k8s.io/client-go v0.26.2
k8s.io/kubectl v0.26.2
k8s.io/metrics v0.26.2
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5
sigs.k8s.io/controller-runtime v0.14.5
sigs.k8s.io/go-open-service-broker-client/v2 v2.0.0-20200925085050-ae25e62aaf10
)
Expand Down Expand Up @@ -158,7 +159,6 @@ require (
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-aggregator v0.24.2 // indirect
k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d // indirect
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 // indirect
knative.dev/pkg v0.0.0-20230306194819-b77a78c6c0ad // indirect
sigs.k8s.io/gateway-api v0.4.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
37 changes: 37 additions & 0 deletions pkg/rpaas/client/autogenerated/model_scheduled_window.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit faf2433

Please sign in to comment.