Skip to content

Commit 147c937

Browse files
authored
Merge pull request #940 from Vafilor/feat/full.node.resources
feat: add optional logic to capture the entire node
2 parents 0021249 + e0f3f81 commit 147c937

File tree

7 files changed

+270
-244
lines changed

7 files changed

+270
-244
lines changed

api/api.swagger.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,6 +3305,9 @@
33053305
"items": {
33063306
"$ref": "#/definitions/KeyValue"
33073307
}
3308+
},
3309+
"captureNode": {
3310+
"type": "boolean"
33083311
}
33093312
}
33103313
},

api/gen/workspace.pb.go

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

api/proto/workspace.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ message CreateWorkspaceBody {
121121

122122
repeated Parameter parameters = 3;
123123
repeated KeyValue labels = 4;
124+
bool captureNode = 5;
124125
}
125126

126127
message CreateWorkspaceRequest {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- +goose Up
2+
-- SQL in this section is executed when the migration is applied.
3+
ALTER TABLE workspaces ADD COLUMN capture_node boolean;
4+
UPDATE workspaces SET capture_node = false;
5+
6+
-- +goose Down
7+
ALTER TABLE workspaces DROP COLUMN capture_node;

pkg/workspace.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ func (c *Client) createWorkspace(namespace string, parameters []byte, workspace
275275
"workspace_template_id": workspace.WorkspaceTemplate.ID,
276276
"workspace_template_version": workspace.WorkspaceTemplate.Version,
277277
"labels": workspace.Labels,
278+
"capture_node": workspace.CaptureNode,
278279
}).
279280
Suffix("RETURNING id, created_at").
280281
RunWith(c.DB).
@@ -311,9 +312,9 @@ func (c *Client) addRuntimeFieldsToWorkspaceTemplate(t wfv1.Template, workspace
311312
if !ok {
312313
return nil, errors.New("unable to type check statefulset manifest")
313314
}
314-
extraContainer := generateNodeCaptureContainer(workspace, config)
315315

316-
if extraContainer != nil {
316+
if workspace.CaptureNode {
317+
extraContainer := generateNodeCaptureContainer(workspace, config)
317318
containers, ok := templateSpec["containers"].([]interface{})
318319
if !ok {
319320
return nil, errors.New("unable to type check statefulset manifest")

pkg/workspace_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type Workspace struct {
5252
WorkspaceTemplateID uint64 `db:"workspace_template_id"`
5353
WorkspaceTemplateVersion uint64 `db:"workspace_template_version"`
5454
WorkflowTemplateVersion *WorkflowTemplateVersion `db:"workflow_template_version"` // helper to store data from workflow template version
55+
CaptureNode bool `db:"capture_node"`
5556
}
5657

5758
type WorkspaceSpec struct {
@@ -102,7 +103,7 @@ func GenerateWorkspaceUID(name string) (string, error) {
102103
// getWorkspaceColumns returns all of the columns for workspace modified by alias, destination.
103104
// see formatColumnSelect
104105
func getWorkspaceColumns(aliasAndDestination ...string) []string {
105-
columns := []string{"id", "created_at", "modified_at", "uid", "name", "namespace", "parameters", "workspace_template_id", "workspace_template_version", "labels"}
106+
columns := []string{"id", "created_at", "modified_at", "uid", "name", "namespace", "parameters", "workspace_template_id", "workspace_template_version", "labels", "capture_node"}
106107
return sql.FormatColumnSelect(columns, aliasAndDestination...)
107108
}
108109

@@ -145,9 +146,11 @@ func getWorkspaceColumnsMap(camelCase bool) map[string]string {
145146
if camelCase {
146147
result["createdAt"] = "created_at"
147148
result["modifiedAt"] = "modified_at"
149+
result["captureNode"] = "capture_node"
148150
} else {
149151
result["created_at"] = "created_at"
150152
result["modified_at"] = "modified_at"
153+
result["capture_node"] = "capture_node"
151154
}
152155

153156
return result

server/workspace_server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ func (s *WorkspaceServer) CreateWorkspace(ctx context.Context, req *api.CreateWo
138138
UID: req.Body.WorkspaceTemplateUid,
139139
Version: req.Body.WorkspaceTemplateVersion,
140140
},
141-
Labels: converter.APIKeyValueToLabel(req.Body.Labels),
141+
Labels: converter.APIKeyValueToLabel(req.Body.Labels),
142+
CaptureNode: req.Body.CaptureNode,
142143
}
143144

144145
for _, param := range req.Body.Parameters {

0 commit comments

Comments
 (0)