Conversation
… support scaling specific services
… waitForWorkspaceHealthy to accept token
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
…cloud/cs-go into curl_and_wake_up_fix
cli/cmd/wakeup.go
Outdated
| wakeup.cmd.Flags().DurationVar(&wakeup.Opts.Timeout, "timeout", 120*time.Second, "Timeout for waking up the workspace") | ||
| wakeup.cmd.Flags().BoolVar(&wakeup.Opts.SyncLandscape, "sync-landscape", false, "Deploy landscape from CI profile after waking up") | ||
| wakeup.cmd.Flags().StringVarP(&wakeup.Opts.Profile, "profile", "p", "", "CI profile to use for landscape deploy (e.g. 'prod' for ci.prod.yml)") | ||
| wakeup.cmd.Flags().StringVar(&wakeup.Opts.ScaleServices, "scale-services", "", "Scale specific landscape services (format: 'service=replicas,service2=replicas')") |
There was a problem hiding this comment.
if you turn ScaleServices into an array, you don't need to care for the split at , as you will get an array directly wit h values like sevice-1=2
There was a problem hiding this comment.
thinking about this, I'm not sure we even need this as input here, or if we'd rather want to move that into a dedicated command and just preserve what's already configured for the wake-up.
E.g.
cs scale workspace --service frontend=2 --service backend=3
cli/cmd/wakeup.go
Outdated
| } | ||
|
|
||
| // parseScaleServices parses a string like "web=1,api=2" into a map[string]int | ||
| func parseScaleServices(s string) (map[string]int, error) { |
There was a problem hiding this comment.
| func parseScaleServices(s string) (map[string]int, error) { | |
| func parseScaleServices(s []string) (map[string]int, error) { |
if the argument was a string array this function could probably get a bit simplified
cli/cmd/wakeup.go
Outdated
| if replicas < 1 { | ||
| return nil, fmt.Errorf("replica count must be at least 1 for service '%s'", service) | ||
| } |
There was a problem hiding this comment.
is scaling to 0 not supported by Codesphere?
cli/cmd/wakeup.go
Outdated
| } | ||
|
|
||
| fmt.Printf("Waking up workspace %d (%s)...\n", wsId, workspace.Name) | ||
| if c.Opts.ScaleServices != "" { |
There was a problem hiding this comment.
I think we always need to do this right? Otherwise we expect the wake-up command to specify all services, even if we just want to scale them to what is currently configured
|
|
||
| req.Header.Set("X-CS-Authorization", fmt.Sprintf("Bearer %s", token)) | ||
|
|
||
| resp, err := httpClient.Do(req) |
There was a problem hiding this comment.
In theory, this request should already be enough to wake-up a sleeping workspace. Do we really need all the scaling code in addition?
I like having the scale-up and scale-down as feature, but I'm wondering if it's really relevant for the wake-up.
Co-authored-by: Manuel Dewald <manuel.dewald@codesphere.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
(still testing)