Skip to content

Curl and wake up fix#196

Open
OliverTrautvetter wants to merge 16 commits intomainfrom
curl_and_wake_up_fix
Open

Curl and wake up fix#196
OliverTrautvetter wants to merge 16 commits intomainfrom
curl_and_wake_up_fix

Conversation

@OliverTrautvetter
Copy link
Member

(still testing)

@OliverTrautvetter OliverTrautvetter marked this pull request as ready for review March 2, 2026 08:20
@OliverTrautvetter OliverTrautvetter requested a review from a team as a code owner March 2, 2026 08:20
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')")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

}

// parseScaleServices parses a string like "web=1,api=2" into a map[string]int
func parseScaleServices(s string) (map[string]int, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment on lines +205 to +207
if replicas < 1 {
return nil, fmt.Errorf("replica count must be at least 1 for service '%s'", service)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is scaling to 0 not supported by Codesphere?

}

fmt.Printf("Waking up workspace %d (%s)...\n", wsId, workspace.Name)
if c.Opts.ScaleServices != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

OliverTrautvetter and others added 5 commits March 4, 2026 11:52
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants