Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4715f52

Browse files
committed
Move to in tx and ignore new fields in audit diff
1 parent 5225991 commit 4715f52

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

enterprise/audit/table.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ var auditableResourcesTypes = map[any]map[string]Action{
7171
"icon": ActionTrack,
7272
"default_ttl": ActionTrack,
7373
"created_by": ActionTrack,
74-
"created_by_username": ActionTrack,
75-
"created_by_avatar_url": ActionTrack,
74+
"created_by_username": ActionIgnore,
75+
"created_by_avatar_url": ActionIgnore,
7676
"group_acl": ActionTrack,
7777
"user_acl": ActionTrack,
7878
"allow_user_autostart": ActionTrack,

enterprise/coderd/provisionerdaemons.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,26 @@ func (*EnterpriseTemplateScheduleStore) SetTemplateScheduleOptions(ctx context.C
360360
return xerrors.Errorf("update template schedule: %w", err)
361361
}
362362

363+
// Update all workspaces using the template to set the user defined schedule
364+
// to be within the new bounds. This essentially does the following for each
365+
// workspace using the template.
366+
// if (template.ttl != NULL) {
367+
// workspace.ttl = min(workspace.ttl, template.ttl)
368+
// }
369+
//
370+
// NOTE: this does not apply to currently running workspaces as their
371+
// schedule information is committed to the workspace_build during start.
372+
// This limitation is displayed to the user while editing the template.
373+
if opts.MaxTTL > 0 {
374+
err = db.UpdateWorkspaceTTLToBeWithinTemplateMax(ctx, database.UpdateWorkspaceTTLToBeWithinTemplateMaxParams{
375+
TemplateID: template.ID,
376+
TemplateMaxTTL: int64(opts.MaxTTL),
377+
})
378+
if err != nil {
379+
return xerrors.Errorf("update TTL of all workspaces on template to be within new template max TTL: %w", err)
380+
}
381+
}
382+
363383
template, err = db.GetTemplateByID(ctx, tpl.ID)
364384
if err != nil {
365385
return xerrors.Errorf("get updated template schedule: %w", err)
@@ -371,25 +391,5 @@ func (*EnterpriseTemplateScheduleStore) SetTemplateScheduleOptions(ctx context.C
371391
return database.Template{}, err
372392
}
373393

374-
// Update all workspaces using the template to set the user defined schedule
375-
// to be within the new bounds. This essentially does the following for each
376-
// workspace using the template.
377-
// if (template.ttl != NULL) {
378-
// workspace.ttl = min(workspace.ttl, template.ttl)
379-
// }
380-
//
381-
// NOTE: this does not apply to currently running workspaces as their
382-
// schedule information is committed to the workspace_build during start.
383-
// This limitation is displayed to the user while editing the template.
384-
if opts.MaxTTL > 0 {
385-
err = db.UpdateWorkspaceTTLToBeWithinTemplateMax(ctx, database.UpdateWorkspaceTTLToBeWithinTemplateMaxParams{
386-
TemplateID: template.ID,
387-
TemplateMaxTTL: int64(opts.MaxTTL),
388-
})
389-
if err != nil {
390-
return database.Template{}, xerrors.Errorf("update TTL of all workspaces on template to be within new template max TTL: %w", err)
391-
}
392-
}
393-
394394
return template, nil
395395
}

0 commit comments

Comments
 (0)