Skip to content

Commit 30f5c28

Browse files
authored
Make envd required (it should be already always present) (#986)
1 parent 1c23d09 commit 30f5c28

File tree

5 files changed

+148
-102
lines changed

5 files changed

+148
-102
lines changed

packages/api/internal/api/spec.gen.go

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

packages/api/internal/api/types.gen.go

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

packages/api/internal/handlers/sandbox_get.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (a *APIStore) GetSandboxesSandboxID(c *gin.Context, id string) {
6161
DiskSizeMB: api.DiskSizeMB(info.TotalDiskSizeMB),
6262
EndAt: info.GetEndTime(),
6363
State: api.Running,
64-
EnvdVersion: &info.EnvdVersion,
64+
EnvdVersion: info.EnvdVersion,
6565
EnvdAccessToken: info.EnvdAccessToken,
6666
Domain: sbxDomain,
6767
}
@@ -93,6 +93,15 @@ func (a *APIStore) GetSandboxesSandboxID(c *gin.Context, id string) {
9393
zap.L().Error("disk size is not set for the sandbox", logger.WithSandboxID(id))
9494
}
9595

96+
// This shouldn't happen - if yes, the data are in corrupted state,
97+
// still adding fallback to envd version v1.0.0 (should behave as if there are no features)
98+
envdVersion := "v1.0.0"
99+
if lastSnapshot.EnvBuild.EnvdVersion != nil {
100+
envdVersion = *lastSnapshot.EnvBuild.EnvdVersion
101+
} else {
102+
zap.L().Error("envd version is not set for the sandbox", logger.WithSandboxID(id))
103+
}
104+
96105
var sbxAccessToken *string = nil
97106
if lastSnapshot.Snapshot.EnvSecure {
98107
key, err := a.envdAccessTokenGenerator.GenerateAccessToken(lastSnapshot.Snapshot.SandboxID)
@@ -115,7 +124,7 @@ func (a *APIStore) GetSandboxesSandboxID(c *gin.Context, id string) {
115124
DiskSizeMB: diskSize,
116125
EndAt: lastSnapshot.Snapshot.CreatedAt.Time, // Snapshot is created when sandbox is paused
117126
State: api.Paused,
118-
EnvdVersion: lastSnapshot.EnvBuild.EnvdVersion,
127+
EnvdVersion: envdVersion,
119128
EnvdAccessToken: sbxAccessToken,
120129
Domain: nil,
121130
}

spec/openapi.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,7 @@ components:
293293
deprecated: true
294294
description: Identifier of the client
295295
envdVersion:
296-
type: string
297-
description: Version of the envd running in the sandbox
296+
$ref: "#/components/schemas/EnvdVersion"
298297
envdAccessToken:
299298
type: string
300299
description: Access token used for envd communication
@@ -314,6 +313,7 @@ components:
314313
- diskSizeMB
315314
- endAt
316315
- state
316+
- envdVersion
317317
properties:
318318
templateID:
319319
type: string
@@ -337,8 +337,7 @@ components:
337337
format: date-time
338338
description: Time when the sandbox will expire
339339
envdVersion:
340-
type: string
341-
description: Version of the envd running in the sandbox
340+
$ref: "#/components/schemas/EnvdVersion"
342341
envdAccessToken:
343342
type: string
344343
description: Access token used for envd communication

0 commit comments

Comments
 (0)