Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Add owner e-mail and job type labels for consumption by the cpu predi…
Browse files Browse the repository at this point in the history
…ction model
  • Loading branch information
gabrielhartmann committed Mar 12, 2019
1 parent 7dc969e commit ed2e2a9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
24 changes: 17 additions & 7 deletions executor/runtime/container.go
Expand Up @@ -9,13 +9,17 @@ import (
)

const (
appNameLabelKey = "com.netflix.titus.appName"
cpuLabelKey = "com.netflix.titus.cpu"
memLabelKey = "com.netflix.titus.mem"
diskLabelKey = "com.netflix.titus.disk"
networkLabelKey = "com.netflix.titus.network"
workloadTypeLabelKey = "com.netflix.titus.workload.type"
titusTaskInstanceIDKey = "TITUS_TASK_INSTANCE_ID"
appNameLabelKey = "com.netflix.titus.appName"
cpuLabelKey = "com.netflix.titus.cpu"
memLabelKey = "com.netflix.titus.mem"
diskLabelKey = "com.netflix.titus.disk"
networkLabelKey = "com.netflix.titus.network"
workloadTypeLabelKey = "com.netflix.titus.workload.type"
ownerEmailLabelKey = "com.netflix.titus.owner.email"
ownerEmailPassThroughKey = "titus.agent.ownerEmail"
jobTypeLabelKey = "com.netflix.titus.job.type"
jobTypePassThroughKey = "titus.agent.jobType"
titusTaskInstanceIDKey = "TITUS_TASK_INSTANCE_ID"
)

// WorkloadType classifies isolation behaviors on resources (e.g. CPU). The exact implementation details of the
Expand Down Expand Up @@ -51,6 +55,12 @@ func NewContainer(taskID string, titusInfo *titus.ContainerInfo, resources *runt
labels[diskLabelKey] = strDisk
labels[networkLabelKey] = strNetwork

passthroughAttributes := titusInfo.GetPassthroughAttributes()
if passthroughAttributes != nil {
labels[ownerEmailLabelKey] = passthroughAttributes[ownerEmailPassThroughKey]
labels[jobTypeLabelKey] = passthroughAttributes[jobTypePassThroughKey]
}

workloadType := StaticWorkloadType
if titusInfo.GetAllowCpuBursting() {
workloadType = BurstWorkloadType
Expand Down
27 changes: 20 additions & 7 deletions executor/runtime/container_test.go
Expand Up @@ -99,6 +99,12 @@ func TestNewContainer(t *testing.T) {
expectedJobStack := "stack"
expectedJobSeq := "seq"
expectedDigest := "abcd0123"
expectedOwnerEmail := "user@email.org"
expectedJobType := "SERVICE"

expectedPassthroughAttributes := make(map[string]string)
expectedPassthroughAttributes[ownerEmailPassThroughKey] = expectedOwnerEmail
expectedPassthroughAttributes[jobTypePassThroughKey] = expectedJobType

containerInfo := &titus.ContainerInfo{
AppName: &expectedAppName,
Expand All @@ -107,13 +113,14 @@ func TestNewContainer(t *testing.T) {
NetworkConfigInfo: &titus.ContainerInfo_NetworkConfigInfo{
BandwidthLimitMbps: &expectedNetwork,
},
AllowCpuBursting: &batch,
Command: &expectedCmd,
UserProvidedEnv: expectedUserEnv,
JobGroupDetail: &expectedJobDetail,
JobGroupStack: &expectedJobStack,
JobGroupSequence: &expectedJobSeq,
ImageDigest: &expectedDigest,
AllowCpuBursting: &batch,
Command: &expectedCmd,
UserProvidedEnv: expectedUserEnv,
JobGroupDetail: &expectedJobDetail,
JobGroupStack: &expectedJobStack,
JobGroupSequence: &expectedJobSeq,
ImageDigest: &expectedDigest,
PassthroughAttributes: expectedPassthroughAttributes,
}

resources := &runtimeTypes.Resources{
Expand All @@ -130,6 +137,12 @@ func TestNewContainer(t *testing.T) {
actualAppName := container.Labels[appNameLabelKey]
assert.Equal(t, expectedAppName, actualAppName)

actualOwnerEmail := container.Labels[ownerEmailLabelKey]
assert.Equal(t, expectedOwnerEmail, actualOwnerEmail)

actualJobType := container.Labels[jobTypeLabelKey]
assert.Equal(t, expectedJobType, actualJobType)

actualCPU, _ := strconv.ParseInt(container.Labels[cpuLabelKey], 10, 64)
assert.Equal(t, expectedCPU, actualCPU)

Expand Down

0 comments on commit ed2e2a9

Please sign in to comment.