Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Prune more ContainerRequest data with new SanitizedContainerRequest type #815

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions pkg/repository/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,21 @@ func (t *TCPEventClientRepo) PushStubStateUnhealthy(workspaceId string, stubId s
)
}

func sanitizeContainerRequest(request *types.ContainerRequest) types.ContainerRequest {
requestCopy := *request
requestCopy.Env = nil
requestCopy.EntryPoint = nil
requestCopy.Stub = types.StubWithRelated{}
requestCopy.Mounts = nil
requestCopy.PoolSelector = ""
return requestCopy
func sanitizeContainerRequest(request *types.ContainerRequest) types.SanitizedContainerRequest {
return types.SanitizedContainerRequest{
ContainerId: request.ContainerId,
Cpu: request.Cpu,
Memory: request.Memory,
Gpu: request.Gpu,
GpuRequest: request.GpuRequest,
GpuCount: request.GpuCount,
ImageId: request.ImageId,
StubId: request.StubId,
WorkspaceId: request.WorkspaceId,
RetryCount: request.RetryCount,
PoolSelector: request.PoolSelector,
Preemptable: request.Preemptable,
CheckpointEnabled: request.CheckpointEnabled,
BuildOptions: request.BuildOptions,
}
}
35 changes: 26 additions & 9 deletions pkg/types/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,33 @@ var (
EventWorkerLifecycleStopped = "stopped"
)

type SanitizedContainerRequest struct {
ContainerId string `json:"container_id"`
Cpu int64 `json:"cpu"`
Memory int64 `json:"memory"`
Gpu string `json:"gpu"`
GpuRequest []string `json:"gpu_request"`
GpuCount uint32 `json:"gpu_count"`
ImageId string `json:"image_id"`
StubId string `json:"stub_id"`
WorkspaceId string `json:"workspace_id"`
RetryCount int `json:"retry_count"`
PoolSelector string `json:"pool_selector"`
Preemptable bool `json:"preemptable"`
CheckpointEnabled bool `json:"checkpoint_enabled"`
BuildOptions BuildOptions `json:"build_options"`
}

// Schema versions should be in ISO 8601 format

var EventContainerLifecycleSchemaVersion = "1.1"

type EventContainerLifecycleSchema struct {
ContainerID string `json:"container_id"`
WorkerID string `json:"worker_id"`
StubID string `json:"stub_id"`
Status string `json:"status"`
Request ContainerRequest `json:"request"`
ContainerID string `json:"container_id"`
WorkerID string `json:"worker_id"`
StubID string `json:"stub_id"`
Status string `json:"status"`
Request SanitizedContainerRequest `json:"request"`
}

var EventContainerMetricsSchemaVersion = "1.0"
Expand Down Expand Up @@ -99,10 +116,10 @@ type EventContainerMetricsData struct {
var EventContainerStatusRequestedSchemaVersion = "1.1"

type EventContainerStatusRequestedSchema struct {
ContainerID string `json:"container_id"`
Request ContainerRequest `json:"request"`
StubID string `json:"stub_id"`
Status string `json:"status"`
ContainerID string `json:"container_id"`
Request SanitizedContainerRequest `json:"request"`
StubID string `json:"stub_id"`
Status string `json:"status"`
}

var EventWorkerLifecycleSchemaVersion = "1.0"
Expand Down
Loading