mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat: improve resources_monitoring for OOM & OOD monitoring (#16241)
As requested for [this issue](https://github.com/coder/internal/issues/245) we need to have a new resource `resources_monitoring` in the agent. It needs to be parsed from the provisioner and inserted into a new db table.
This commit is contained in:
@ -66,6 +66,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -83,6 +84,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}, {
|
||||
Name: "second",
|
||||
@ -101,6 +103,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_InstanceId{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -117,6 +120,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
ModulePath: "module.module",
|
||||
}},
|
||||
@ -134,6 +138,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}, {
|
||||
Name: "dev2",
|
||||
OperatingSystem: "darwin",
|
||||
@ -142,6 +147,7 @@ func TestConvertResources(t *testing.T) {
|
||||
ConnectionTimeoutSeconds: 1,
|
||||
MotdFile: "/etc/motd",
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
Scripts: []*proto.Script{{
|
||||
Icon: "/emojis/25c0.png",
|
||||
DisplayName: "Shutdown Script",
|
||||
@ -157,6 +163,7 @@ func TestConvertResources(t *testing.T) {
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
TroubleshootingUrl: "https://coder.com/troubleshoot",
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}, {
|
||||
Name: "dev4",
|
||||
OperatingSystem: "linux",
|
||||
@ -164,6 +171,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -205,6 +213,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -231,6 +240,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -265,6 +275,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}, {
|
||||
Name: "dev2",
|
||||
@ -284,6 +295,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -308,6 +320,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}, {
|
||||
Name: "dev2",
|
||||
@ -325,6 +338,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}, {
|
||||
Name: "env1",
|
||||
@ -337,6 +351,75 @@ func TestConvertResources(t *testing.T) {
|
||||
Type: "coder_env",
|
||||
}},
|
||||
},
|
||||
"multiple-agents-multiple-monitors": {
|
||||
resources: []*proto.Resource{{
|
||||
Name: "dev",
|
||||
Type: "null_resource",
|
||||
Agents: []*proto.Agent{
|
||||
{
|
||||
Name: "dev1",
|
||||
OperatingSystem: "linux",
|
||||
Architecture: "amd64",
|
||||
Apps: []*proto.App{
|
||||
{
|
||||
Slug: "app1",
|
||||
DisplayName: "app1",
|
||||
// Subdomain defaults to false if unspecified.
|
||||
Subdomain: false,
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
{
|
||||
Slug: "app2",
|
||||
DisplayName: "app2",
|
||||
Subdomain: true,
|
||||
Healthcheck: &proto.Healthcheck{
|
||||
Url: "http://localhost:13337/healthz",
|
||||
Interval: 5,
|
||||
Threshold: 6,
|
||||
},
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
},
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{
|
||||
Memory: &proto.MemoryResourceMonitor{
|
||||
Enabled: true,
|
||||
Threshold: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "dev2",
|
||||
OperatingSystem: "linux",
|
||||
Architecture: "amd64",
|
||||
Apps: []*proto.App{},
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{
|
||||
Memory: &proto.MemoryResourceMonitor{
|
||||
Enabled: true,
|
||||
Threshold: 99,
|
||||
},
|
||||
Volumes: []*proto.VolumeResourceMonitor{
|
||||
{
|
||||
Path: "volume2",
|
||||
Enabled: false,
|
||||
Threshold: 50,
|
||||
},
|
||||
{
|
||||
Path: "volume1",
|
||||
Enabled: true,
|
||||
Threshold: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
"multiple-agents-multiple-scripts": {
|
||||
resources: []*proto.Resource{{
|
||||
Name: "dev1",
|
||||
@ -360,6 +443,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}, {
|
||||
Name: "dev2",
|
||||
@ -378,6 +462,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -417,6 +502,7 @@ func TestConvertResources(t *testing.T) {
|
||||
}},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -468,6 +554,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
Scripts: []*proto.Script{{
|
||||
DisplayName: "Startup Script",
|
||||
RunOnStart: true,
|
||||
@ -490,6 +577,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
parameters: []*proto.RichParameter{{
|
||||
@ -569,6 +657,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
parameters: []*proto.RichParameter{{
|
||||
@ -595,6 +684,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
parameters: []*proto.RichParameter{{
|
||||
@ -648,6 +738,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &displayApps,
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
externalAuthProviders: []*proto.ExternalAuthProviderResource{{Id: "github"}, {Id: "gitlab", Optional: true}},
|
||||
@ -666,6 +757,7 @@ func TestConvertResources(t *testing.T) {
|
||||
VscodeInsiders: true,
|
||||
WebTerminal: true,
|
||||
},
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@ -680,6 +772,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Auth: &proto.Agent_Token{},
|
||||
ConnectionTimeoutSeconds: 120,
|
||||
DisplayApps: &proto.DisplayApps{},
|
||||
ResourcesMonitoring: &proto.ResourcesMonitoring{},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
|
Reference in New Issue
Block a user