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
4 changes: 2 additions & 2 deletions pkg/config/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,9 +1172,9 @@ const templateStringCrioRuntimeWorkloads = `# The workloads table defines ways t
{{ $.Comment }}[crio.runtime.workloads.{{ $workload_type }}]
{{ $.Comment }}activation_annotation = "{{ $workload_config.ActivationAnnotation }}"
{{ $.Comment }}annotation_prefix = "{{ $workload_config.AnnotationPrefix }}"
{{ $.Comment }}[crio.runtime.workloads.{{ $workload_type }}.resources]
{{ if $workload_config.Resources }}{{ $.Comment }}[crio.runtime.workloads.{{ $workload_type }}.resources]
{{ $.Comment }}cpuset = "{{ $workload_config.Resources.CPUSet }}"
{{ $.Comment }}cpushares = {{ $workload_config.Resources.CPUShares }}
{{ $.Comment }}cpushares = {{ $workload_config.Resources.CPUShares }}{{ end }}
{{ end }}
`

Expand Down
13 changes: 13 additions & 0 deletions test/config.bats
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,16 @@ EOF
[[ "$RES" == *"monitor_cgroup = \"pod\""* ]]
[[ "$RES" == *"monitor_path = \"/bin/true\""* ]]
}

@test "handle nil workloads" {
# when
unset CONTAINER_DEFAULT_RUNTIME
cat << EOF >> "$TESTDIR"/workload.conf
[crio.runtime.workloads.userns]
activation_annotation = "io.kubernetes.cri-o.userns-mode"
allowed_annotations = ["io.kubernetes.cri-o.userns-mode"]
EOF

# then
"$CRIO_BINARY_PATH" -c "$TESTDIR"/workload.conf -d "" config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kata-jenkins job fails here, because it cannot find the definition for the default runtime we've set.

# level=fatal msg="validating runtime config: default_runtime set to \"containerd-shim-kata-v2\", but no runtime entry table [crio.runtime.runtimes.containerd-shim-kata-v2] was found"

Maybe need to customize the conf file you use with an entry for the default runtime?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another (maybe simpler) suggestion: if the test doesn't imply the runtime, maybe you can unset the CONTAINER_RUNTIMES env variable for this test, like it's done in another test above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea! trying that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it didn't help :-(
I just tried locally. The problem is the default runtime, not the list of runtimes.
You need to unset CONTAINER_DEFAULT_RUNTIME for it to work.
I think it's ok to do that in this context, as the runtime is not involved - we're testing the config engine.

}