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

Skip to content
Merged
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
6 changes: 6 additions & 0 deletions pkg/config/workloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func resourcesFromAnnotation(prefix, ctrName string, annotations map[string]stri
}

func (r *Resources) ValidateDefaults() error {
if r == nil {
return nil
}
if r.CPUSet == "" {
return nil
}
Expand All @@ -104,6 +107,9 @@ func (r *Resources) ValidateDefaults() error {
}

func (r *Resources) MutateSpec(specgen *generate.Generator) {
if r == nil {
return
}
if r.CPUSet != "" {
specgen.SetLinuxResourcesCPUCpus(r.CPUSet)
}
Expand Down
17 changes: 17 additions & 0 deletions test/workloads.bats
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,20 @@ function check_conmon_fields() {
ctr_id=$(crictl run "$ctrconfig" "$sboxconfig")
check_conmon_fields "$ctr_id" "$shares" "$set"
}

@test "should succeed to create workload with empty resources" {
cat << EOF > "$CRIO_CONFIG_DIR/01-workload.conf"
[crio.runtime.workloads.management]
activation_annotation = "$activation"
annotation_prefix = "$prefix"
EOF
start_crio

jq --arg act "$activation" ' .annotations[$act] = "true"' \
"$TESTDATA"/sandbox_config.json > "$sboxconfig"

jq --arg act "$activation" ' .annotations[$act] = "true"' \
"$TESTDATA"/container_sleep.json > "$ctrconfig"

ctr_id=$(crictl run "$ctrconfig" "$sboxconfig")
}