Skip to content

Commit bea98c0

Browse files
Merge pull request #2967 from sdodson/OCPBUGS-83863-remove-rhel8-fallback
OCPBUGS-83863: Remove version-specific CNI binary copy logic
2 parents 7511132 + 5294721 commit bea98c0

2 files changed

Lines changed: 14 additions & 148 deletions

File tree

bindata/network/multus/multus.yaml

Lines changed: 12 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ data:
2121
DESTINATION_DIRECTORY=/host/opt/cni/bin/
2222
2323
# Perform validation of usage
24-
if [ -z "$RHEL8_SOURCE_DIRECTORY" ] ||
25-
[ -z "$RHEL9_SOURCE_DIRECTORY" ] ||
26-
[ -z "$DEFAULT_SOURCE_DIRECTORY" ]; then
27-
log "FATAL ERROR: You must set env variables: RHEL8_SOURCE_DIRECTORY, RHEL9_SOURCE_DIRECTORY, DEFAULT_SOURCE_DIRECTORY"
24+
if [ -z "$SOURCE_DIRECTORY" ]; then
25+
log "FATAL ERROR: You must set the SOURCE_DIRECTORY env variable"
2826
exit 1
2927
fi
3028
@@ -33,62 +31,15 @@ data:
3331
exit 1
3432
fi
3533
36-
# Collect host OS information
37-
. /host/etc/os-release
38-
rhelmajor=
39-
# detect which version we're using in order to copy the proper binaries
40-
case "${ID}" in
41-
rhcos|scos)
42-
RHEL_VERSION=$(echo "${CPE_NAME}" | cut -f 5 -d :)
43-
rhelmajor=$(echo $RHEL_VERSION | sed -E 's/([0-9]+)\.{1}[0-9]+(\.[0-9]+)?/\1/')
44-
;;
45-
rhel|centos) rhelmajor=$(echo "${VERSION_ID}" | cut -f 1 -d .)
46-
;;
47-
fedora)
48-
if [ "${VARIANT_ID}" == "coreos" ]; then
49-
rhelmajor=8
50-
else
51-
log "FATAL ERROR: Unsupported Fedora variant=${VARIANT_ID}"
52-
exit 1
53-
fi
54-
;;
55-
*) log "FATAL ERROR: Unsupported OS ID=${ID}"; exit 1
56-
;;
57-
esac
58-
59-
# Set which directory we'll copy from, detect if it exists
60-
sourcedir=
61-
founddir=false
62-
case "${rhelmajor}" in
63-
8)
64-
if [ -d "${RHEL8_SOURCE_DIRECTORY}" ]; then
65-
sourcedir=${RHEL8_SOURCE_DIRECTORY}
66-
founddir=true
67-
fi
68-
;;
69-
9)
70-
if [ -d "${RHEL9_SOURCE_DIRECTORY}" ]; then
71-
sourcedir=${RHEL9_SOURCE_DIRECTORY}
72-
founddir=true
73-
fi
74-
;;
75-
*)
76-
log "ERROR: RHEL Major Version Unsupported, rhelmajor=${rhelmajor}"
77-
;;
78-
esac
79-
80-
# When it doesn't exist, fall back to the original directory.
81-
if [ "$founddir" == false ]; then
82-
log "Source directory unavailable for OS version: ${rhelmajor}"
83-
sourcedir=$DEFAULT_SOURCE_DIRECTORY
84-
fi
34+
sourcedir="${SOURCE_DIRECTORY}"
35+
log "Copying binaries from ${sourcedir}"
8536
8637
# Use a subdirectory called "upgrade" so we can atomically move fully copied files.
8738
# We now use --remove-destination after running into an issue with -f not working over symlinks
8839
UPGRADE_DIRECTORY=${DESTINATION_DIRECTORY}upgrade_$(uuidgen)
8940
rm -Rf $UPGRADE_DIRECTORY
9041
mkdir -p $UPGRADE_DIRECTORY
91-
cp -r --remove-destination ${sourcedir}* $UPGRADE_DIRECTORY
42+
find "${sourcedir}" -maxdepth 1 -mindepth 1 ! -type d -exec cp --remove-destination {} "${UPGRADE_DIRECTORY}/" \;
9243
if [ $? -eq 0 ]; then
9344
log "Successfully copied files in ${sourcedir} to $UPGRADE_DIRECTORY"
9445
else
@@ -221,8 +172,6 @@ spec:
221172
volumeMounts:
222173
- mountPath: /entrypoint
223174
name: cni-binary-copy
224-
- mountPath: /host/etc/os-release
225-
name: os-release
226175
- name: system-cni-dir
227176
mountPath: /host/etc/cni/net.d
228177
- name: multus-cni-dir
@@ -260,11 +209,7 @@ spec:
260209
- name: etc-kubernetes
261210
mountPath: /etc/kubernetes
262211
env:
263-
- name: RHEL8_SOURCE_DIRECTORY
264-
value: "/usr/src/multus-cni/rhel8/bin/"
265-
- name: RHEL9_SOURCE_DIRECTORY
266-
value: "/usr/src/multus-cni/rhel9/bin/"
267-
- name: DEFAULT_SOURCE_DIRECTORY
212+
- name: SOURCE_DIRECTORY
268213
value: "/usr/src/multus-cni/bin/"
269214
- name: KUBERNETES_SERVICE_PORT
270215
value: "{{.KUBERNETES_SERVICE_PORT}}"
@@ -304,10 +249,6 @@ spec:
304249
hostPath:
305250
path: {{ .CNIBinDir }}
306251
type: Directory
307-
- name: os-release
308-
hostPath:
309-
path: /etc/os-release
310-
type: File
311252
- name: cni-binary-copy
312253
configMap:
313254
name: cni-copy-resources
@@ -399,15 +340,8 @@ spec:
399340
name: cni-binary-copy
400341
- mountPath: /host/opt/cni/bin
401342
name: cnibin
402-
- mountPath: /host/etc/os-release
403-
name: os-release
404-
readOnly: true
405343
env:
406-
- name: RHEL8_SOURCE_DIRECTORY
407-
value: "/usr/src/egress-router-cni/rhel8/bin/"
408-
- name: RHEL9_SOURCE_DIRECTORY
409-
value: "/usr/src/egress-router-cni/rhel9/bin/"
410-
- name: DEFAULT_SOURCE_DIRECTORY
344+
- name: SOURCE_DIRECTORY
411345
value: "/usr/src/egress-router-cni/bin/"
412346
- name: cni-plugins
413347
image: {{.CNIPluginsImage}}
@@ -418,20 +352,13 @@ spec:
418352
name: cni-binary-copy
419353
- mountPath: /host/opt/cni/bin
420354
name: cnibin
421-
- mountPath: /host/etc/os-release
422-
name: os-release
423-
readOnly: true
424355
- mountPath: /host/etc/cni/tuning/
425356
name: tuning-conf-dir
426357
readOnly: false
427358
- mountPath: /sysctls
428359
name: cni-sysctl-allowlist
429360
env:
430-
- name: RHEL8_SOURCE_DIRECTORY
431-
value: "/usr/src/plugins/rhel8/bin/"
432-
- name: RHEL9_SOURCE_DIRECTORY
433-
value: "/usr/src/plugins/rhel9/bin/"
434-
- name: DEFAULT_SOURCE_DIRECTORY
361+
- name: SOURCE_DIRECTORY
435362
value: "/usr/src/plugins/bin/"
436363
- name: bond-cni-plugin
437364
image: {{.BondCNIPluginImage}}
@@ -442,16 +369,9 @@ spec:
442369
name: cni-binary-copy
443370
- mountPath: /host/opt/cni/bin
444371
name: cnibin
445-
- mountPath: /host/etc/os-release
446-
name: os-release
447-
readOnly: true
448372
env:
449-
- name: RHEL8_SOURCE_DIRECTORY
450-
value: "/bondcni/rhel8/"
451-
- name: RHEL9_SOURCE_DIRECTORY
452-
value: "/bondcni/rhel9/"
453-
- name: DEFAULT_SOURCE_DIRECTORY
454-
value: "/bondcni/rhel9/"
373+
- name: SOURCE_DIRECTORY
374+
value: "/bondcni/"
455375
- name: routeoverride-cni
456376
image: {{.RouteOverrideImage}}
457377
command: ["/entrypoint/cnibincopy.sh"]
@@ -461,15 +381,8 @@ spec:
461381
name: cni-binary-copy
462382
- mountPath: /host/opt/cni/bin
463383
name: cnibin
464-
- mountPath: /host/etc/os-release
465-
name: os-release
466-
readOnly: true
467384
env:
468-
- name: RHEL8_SOURCE_DIRECTORY
469-
value: "/usr/src/route-override/rhel8/bin/"
470-
- name: RHEL9_SOURCE_DIRECTORY
471-
value: "/usr/src/route-override/rhel9/bin/"
472-
- name: DEFAULT_SOURCE_DIRECTORY
385+
- name: SOURCE_DIRECTORY
473386
value: "/usr/src/route-override/bin/"
474387
- name: whereabouts-cni-bincopy
475388
image: {{.WhereaboutsImage}}
@@ -484,15 +397,8 @@ spec:
484397
name: cni-binary-copy
485398
- mountPath: /host/opt/cni/bin
486399
name: cnibin
487-
- mountPath: /host/etc/os-release
488-
name: os-release
489-
readOnly: true
490400
env:
491-
- name: RHEL8_SOURCE_DIRECTORY
492-
value: "/usr/src/whereabouts/rhel8/bin/"
493-
- name: RHEL9_SOURCE_DIRECTORY
494-
value: "/usr/src/whereabouts/rhel9/bin/"
495-
- name: DEFAULT_SOURCE_DIRECTORY
401+
- name: SOURCE_DIRECTORY
496402
value: "/usr/src/whereabouts/bin/"
497403
- name: whereabouts-cni
498404
image: {{.WhereaboutsImage}}
@@ -697,10 +603,6 @@ spec:
697603
- name: cnibin
698604
hostPath:
699605
path: {{ .CNIBinDir }}
700-
- name: os-release
701-
hostPath:
702-
path: /etc/os-release
703-
type: File
704606
- name: cni-binary-copy
705607
configMap:
706608
name: cni-copy-resources

bindata/network/ovn-kubernetes/common/008-script-lib.yaml

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -486,44 +486,8 @@ data:
486486
# /cni-bin-dir
487487
cni-bin-copy()
488488
{
489-
# collect host os information
490-
. /host/etc/os-release
491-
rhelmajor=
492-
# detect which version we're using in order to copy the proper binaries
493-
case "${ID}" in
494-
rhcos|scos)
495-
RHEL_VERSION=$(echo "${CPE_NAME}" | cut -f 5 -d :)
496-
rhelmajor=$(echo $RHEL_VERSION | sed -E 's/([0-9]+)\.{1}[0-9]+(\.[0-9]+)?/\1/')
497-
;;
498-
rhel|centos) rhelmajor=$(echo "${VERSION_ID}" | cut -f 1 -d .)
499-
;;
500-
fedora)
501-
if [ "${VARIANT_ID}" == "coreos" ]; then
502-
rhelmajor=8
503-
else
504-
log "cnibincopy" "FATAL ERROR: Unsupported Fedora variant=${VARIANT_ID}"
505-
exit 1
506-
fi
507-
;;
508-
*) log "cnibincopy" "FATAL ERROR: Unsupported OS ID=${ID}"; exit 1
509-
;;
510-
esac
511-
512-
# Set which directory we'll copy from, detect if it exists
513-
sourcedir=/usr/libexec/cni/
514-
case "${rhelmajor}" in
515-
8)
516-
sourcedir=/usr/libexec/cni/rhel8
517-
;;
518-
9)
519-
sourcedir=/usr/libexec/cni/rhel9
520-
;;
521-
*)
522-
log "cnibincopy" "ERROR: RHEL Major Version Unsupported, rhelmajor=${rhelmajor}"
523-
;;
524-
esac
525-
526-
cp -f "$sourcedir/ovn-k8s-cni-overlay" /cni-bin-dir/
489+
log "cnibincopy" "Copying /usr/libexec/cni/ovn-k8s-cni-overlay to /cni-bin-dir/"
490+
cp -f "/usr/libexec/cni/ovn-k8s-cni-overlay" /cni-bin-dir/
527491
}
528492

529493
# start-ovnkube-node starts the ovnkube-node process. This function does not

0 commit comments

Comments
 (0)