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
0 commit comments