Skip to content

Commit 7449728

Browse files
Improve wait logic
1 parent 6fb1109 commit 7449728

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

internal/tiger/api/client.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/tiger/cmd/service.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,7 @@ Note: You can specify both CPU and memory together, or specify only one (the oth
14351435
return common.ExitWithErrorFromStatusCode(resp.StatusCode(), resp.JSON4XX)
14361436
}
14371437

1438+
service := *resp.JSON202
14381439
fmt.Fprintf(statusOutput, "✅ Resize request accepted for service '%s'!\n", serviceID)
14391440

14401441
// Handle wait behavior
@@ -1446,12 +1447,14 @@ Note: You can specify both CPU and memory together, or specify only one (the oth
14461447
// Wait for resize to complete
14471448
fmt.Fprintf(statusOutput, "⏳ Waiting for resize to complete (timeout: %v)...\n", resizeWaitTimeout)
14481449

1449-
var dummyService api.Service
14501450
if err := common.WaitForService(cmd.Context(), common.WaitForServiceArgs{
1451-
Client: cfg.Client,
1452-
ProjectID: cfg.ProjectID,
1453-
ServiceID: serviceID,
1454-
Handler: &common.StatusWaitHandler{TargetStatus: "READY", Service: &dummyService},
1451+
Client: cfg.Client,
1452+
ProjectID: cfg.ProjectID,
1453+
ServiceID: serviceID,
1454+
Handler: &common.StatusWaitHandler{
1455+
TargetStatus: "READY",
1456+
Service: &service,
1457+
},
14551458
Output: statusOutput,
14561459
Timeout: resizeWaitTimeout,
14571460
TimeoutMsg: "resize may still be in progress",
@@ -1468,10 +1471,10 @@ Note: You can specify both CPU and memory together, or specify only one (the oth
14681471
}
14691472

14701473
// Add flags
1471-
cmd.Flags().StringVar(&resizeCPU, "cpu", "", "CPU allocation in millicores or 'shared'")
1472-
cmd.Flags().StringVar(&resizeMemory, "memory", "", "Memory allocation in gigabytes or 'shared'")
1474+
cmd.Flags().StringVar(&resizeCPU, "cpu", "", "CPU allocation in millicores")
1475+
cmd.Flags().StringVar(&resizeMemory, "memory", "", "Memory allocation in gigabytes")
14731476
cmd.Flags().BoolVar(&resizeNoWait, "no-wait", false, "Don't wait for resize operation to complete")
1474-
cmd.Flags().DurationVar(&resizeWaitTimeout, "wait-timeout", 30*time.Minute, "Wait timeout duration (e.g., 30m, 1h30m, 90s)")
1477+
cmd.Flags().DurationVar(&resizeWaitTimeout, "wait-timeout", 10*time.Minute, "Maximum time to wait for operation to complete")
14751478

14761479
return cmd
14771480
}

openapi.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ paths:
434434
tags:
435435
- Services
436436
summary: Resize a Service
437-
description: Changes the CPU and memory allocation for a specific service within a project.
437+
description: Changes the CPU and memory allocation for a specific service within a project. This is an asynchronous operation.
438438
parameters:
439439
- $ref: '#/components/parameters/ProjectId'
440440
- $ref: '#/components/parameters/ServiceId'
@@ -447,6 +447,10 @@ paths:
447447
responses:
448448
'202':
449449
description: Resize request has been accepted and is in progress.
450+
content:
451+
application/json:
452+
schema:
453+
$ref: '#/components/schemas/Service'
450454
'4XX':
451455
$ref: '#/components/responses/ClientError'
452456

0 commit comments

Comments
 (0)