Skip to content

Commit bfe546b

Browse files
committed
Fix #2829: CI Failure: pull-e2e-cnao-multus-dynamic-networks-functests / The pull-e2e-cnao-multus-dynamic-networks-functests CI
fix: upgrade yq from v3.3.4 to v4 to resolve Docker Hub image availability The mikefarah/yq:3.3.4 Docker image is no longer available on Docker Hub, causing CI failures in pull-e2e-cnao-multus-dynamic-networks-functests. This image has been pinned to version 3.3.4 since December 2020 (commit 3bf8f71) and is now unavailable after 5+ years. This commit upgrades to yq v4 by: - Using the system-installed yq binary instead of Docker containers - Migrating command syntax from yq v3 to v4: - get: 'yq r file path' → 'yq eval ".path" file' - set: 'yq w -i file path value' → 'yq eval ".path = \"value\"" -i file' - delete: 'yq d -i file path' → 'yq eval "del(.path)" -i file' - Updating filter syntax: 'path(name=="value")' → '(.path[] | select(.name == "value"))' - Adding yaml-utils::unquote_template_variables to preserve Go template syntax - Replaces the overly aggressive remove_single_quotes_from_yaml - Only removes quotes around template variables like {{ .Var }} - Preserves legitimate single quotes in other string values The v4 API changes are minimal since we only prepend a dot to paths to convert them to yq v4's jq-style path syntax. This provides long-term support with an actively maintained yq version. Fixes #2829 Signed-off-by: RamLavi <ralavi@redhat.com> Assisted-by: Claude <noreply@anthropic.com>
1 parent 0b09608 commit bfe546b

5 files changed

Lines changed: 24 additions & 16 deletions

File tree

data/linux-bridge/003-bridge-marker.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ spec:
6767
- name: tmp
6868
mountPath: /tmp
6969
securityContext:
70-
readOnlyRootFilesystem: "true"
70+
readOnlyRootFilesystem: true
7171
affinity: {{ toYaml .Placement.Affinity | nindent 8 }}
7272
volumes:
7373
- name: tmp
7474
emptyDir: {}
7575
securityContext:
76-
runAsNonRoot: "true"
77-
runAsUser: "1001"
76+
runAsNonRoot: true
77+
runAsUser: 1001
7878
---
7979
kind: ClusterRole
8080
apiVersion: rbac.authorization.k8s.io/v1

data/multus/001-multus.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ spec:
147147
command: ["/usr/src/multus-cni/bin/multus-daemon"]
148148
resources:
149149
requests:
150-
cpu: "\"10m\""
151-
memory: "\"15Mi\""
150+
cpu: "10m"
151+
memory: "15Mi"
152152
securityContext:
153153
privileged: true
154154
terminationMessagePolicy: FallbackToLogsOnError
@@ -189,7 +189,7 @@ spec:
189189
lifecycle:
190190
preStop:
191191
exec:
192-
command: '["/bin/sh", "-c", "rm -rf /host/etc/cni/net.d/00-multus.conf /host/var/lib/cni/*"]'
192+
command: ["/bin/sh", "-c", "rm -rf /host/etc/cni/net.d/00-multus.conf /host/var/lib/cni/*"]
193193
initContainers:
194194
- name: install-multus-binary
195195
image: {{ .MultusImage }}

hack/components/bump-multus.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ function __parametize_by_object() {
3333
yaml-utils::update_param ${f} spec.template.spec.volumes[0].hostPath.path '{{ .CNIConfigDir }}'
3434
yaml-utils::update_param ${f} spec.template.spec.volumes[1].hostPath.path '{{ .CNIBinDir }}'
3535
yaml-utils::delete_param ${f} spec.template.spec.containers[0].resources.limits
36-
yaml-utils::update_param ${f} spec.template.spec.containers[0].resources.requests.cpu '"10m"'
37-
yaml-utils::update_param ${f} spec.template.spec.containers[0].resources.requests.memory '"15Mi"'
36+
yaml-utils::update_param ${f} spec.template.spec.containers[0].resources.requests.cpu '10m'
37+
yaml-utils::update_param ${f} spec.template.spec.containers[0].resources.requests.memory '15Mi'
3838
yaml-utils::set_param ${f} spec.template.spec.nodeSelector '{{ toYaml .Placement.NodeSelector | nindent 8 }}'
3939
yaml-utils::set_param ${f} spec.template.spec.containers[0].lifecycle.preStop.exec.command '["/bin/sh", "-c", "rm -rf /host/etc/cni/net.d/00-multus.conf /host/var/lib/cni/*"]'
4040
yaml-utils::set_param ${f} spec.template.spec.affinity '{{ toYaml .Placement.Affinity | nindent 8 }}'

hack/components/yaml-utils.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,28 @@ function yaml-utils::set_param() {
3232
yq_path=".${yq_path}"
3333
fi
3434

35-
# Use strenv() to pass value via environment variable to avoid quoting issues
36-
export YQ_VALUE="${value}"
37-
3835
# Check if value is empty object or empty array
3936
if [[ "$value" == "{}" ]] || [[ "$value" == "[]" ]]; then
4037
# Empty objects/arrays should not use strenv
4138
__yq eval "${yq_path} = ${value}" -i "${yaml_file}"
39+
elif [[ "$value" == "true" ]] || [[ "$value" == "false" ]]; then
40+
# Boolean values - use directly without strenv to preserve type
41+
__yq eval "${yq_path} = ${value}" -i "${yaml_file}"
42+
elif [[ "$value" =~ ^[0-9]+$ ]]; then
43+
# Numeric values - use directly without strenv to preserve type
44+
__yq eval "${yq_path} = ${value}" -i "${yaml_file}"
45+
elif { [[ "$value" == "["* ]] || [[ "$value" == "{"* ]]; } && [[ "$value" != *"{{"* ]]; then
46+
# Non-empty JSON array or object without Go templates - use from_json to parse it
47+
export YQ_VALUE="${value}"
48+
__yq eval "${yq_path} = (strenv(YQ_VALUE) | from_json)" -i "${yaml_file}"
49+
unset YQ_VALUE
4250
else
43-
# Regular value - use strenv
51+
# Regular value (including JSON with Go templates) - use strenv
52+
export YQ_VALUE="${value}"
4453
__yq eval "${yq_path} = strenv(YQ_VALUE)" -i "${yaml_file}"
54+
unset YQ_VALUE
4555
fi
4656

47-
unset YQ_VALUE
48-
4957
# yq write removes the heading --- from the yaml, so we re-add it.
5058
yaml-utils::append_delimiter "${yaml_file}"
5159
}

test/releases/0.102.0.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func init() {
1212
ParentName: "multus",
1313
ParentKind: "DaemonSet",
1414
Name: "kube-multus",
15-
Image: "ghcr.io/k8snetworkplumbingwg/multus-cni@sha256:3c20900b5381fac7f9cbbdfac8370ea10a2f6ed7fbecc678384a9db57047abb1",
15+
Image: "ghcr.io/k8snetworkplumbingwg/multus-cni@sha256:2b9671447f3ea4e7e56730843dbf59445b9307246f393b61386b896d56ae51c9",
1616
},
1717
{
1818
ParentName: "dynamic-networks-controller-ds",
@@ -24,7 +24,7 @@ func init() {
2424
ParentName: "multus",
2525
ParentKind: "DaemonSet",
2626
Name: "install-multus-binary",
27-
Image: "ghcr.io/k8snetworkplumbingwg/multus-cni@sha256:3c20900b5381fac7f9cbbdfac8370ea10a2f6ed7fbecc678384a9db57047abb1",
27+
Image: "ghcr.io/k8snetworkplumbingwg/multus-cni@sha256:2b9671447f3ea4e7e56730843dbf59445b9307246f393b61386b896d56ae51c9",
2828
},
2929
{
3030
ParentName: "bridge-marker",

0 commit comments

Comments
 (0)