mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: implement oom/ood processing component (#16436)
Implements the processing logic as set out in the OOM/OOD RFC.
This commit is contained in:
@@ -1981,10 +1981,13 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
if prAgent.ResourcesMonitoring != nil {
|
||||
if prAgent.ResourcesMonitoring.Memory != nil {
|
||||
_, err = db.InsertMemoryResourceMonitor(ctx, database.InsertMemoryResourceMonitorParams{
|
||||
AgentID: agentID,
|
||||
Enabled: prAgent.ResourcesMonitoring.Memory.Enabled,
|
||||
Threshold: prAgent.ResourcesMonitoring.Memory.Threshold,
|
||||
CreatedAt: dbtime.Now(),
|
||||
AgentID: agentID,
|
||||
Enabled: prAgent.ResourcesMonitoring.Memory.Enabled,
|
||||
Threshold: prAgent.ResourcesMonitoring.Memory.Threshold,
|
||||
State: database.WorkspaceAgentMonitorStateOK,
|
||||
CreatedAt: dbtime.Now(),
|
||||
UpdatedAt: dbtime.Now(),
|
||||
DebouncedUntil: time.Time{},
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to insert agent memory resource monitor into db: %w", err)
|
||||
@@ -1992,11 +1995,14 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
}
|
||||
for _, volume := range prAgent.ResourcesMonitoring.Volumes {
|
||||
_, err = db.InsertVolumeResourceMonitor(ctx, database.InsertVolumeResourceMonitorParams{
|
||||
AgentID: agentID,
|
||||
Path: volume.Path,
|
||||
Enabled: volume.Enabled,
|
||||
Threshold: volume.Threshold,
|
||||
CreatedAt: dbtime.Now(),
|
||||
AgentID: agentID,
|
||||
Path: volume.Path,
|
||||
Enabled: volume.Enabled,
|
||||
Threshold: volume.Threshold,
|
||||
State: database.WorkspaceAgentMonitorStateOK,
|
||||
CreatedAt: dbtime.Now(),
|
||||
UpdatedAt: dbtime.Now(),
|
||||
DebouncedUntil: time.Time{},
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to insert agent volume resource monitor into db: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user