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
122 changes: 12 additions & 110 deletions bindata/network/multus/multus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ data:
DESTINATION_DIRECTORY=/host/opt/cni/bin/

# Perform validation of usage
if [ -z "$RHEL8_SOURCE_DIRECTORY" ] ||
[ -z "$RHEL9_SOURCE_DIRECTORY" ] ||
[ -z "$DEFAULT_SOURCE_DIRECTORY" ]; then
log "FATAL ERROR: You must set env variables: RHEL8_SOURCE_DIRECTORY, RHEL9_SOURCE_DIRECTORY, DEFAULT_SOURCE_DIRECTORY"
if [ -z "$SOURCE_DIRECTORY" ]; then
log "FATAL ERROR: You must set the SOURCE_DIRECTORY env variable"
exit 1
fi

Expand All @@ -33,62 +31,15 @@ data:
exit 1
fi

# Collect host OS information
. /host/etc/os-release
rhelmajor=
# detect which version we're using in order to copy the proper binaries
case "${ID}" in
rhcos|scos)
RHEL_VERSION=$(echo "${CPE_NAME}" | cut -f 5 -d :)
rhelmajor=$(echo $RHEL_VERSION | sed -E 's/([0-9]+)\.{1}[0-9]+(\.[0-9]+)?/\1/')
;;
rhel|centos) rhelmajor=$(echo "${VERSION_ID}" | cut -f 1 -d .)
;;
fedora)
if [ "${VARIANT_ID}" == "coreos" ]; then
rhelmajor=8
else
log "FATAL ERROR: Unsupported Fedora variant=${VARIANT_ID}"
exit 1
fi
;;
*) log "FATAL ERROR: Unsupported OS ID=${ID}"; exit 1
;;
esac

# Set which directory we'll copy from, detect if it exists
sourcedir=
founddir=false
case "${rhelmajor}" in
8)
if [ -d "${RHEL8_SOURCE_DIRECTORY}" ]; then
sourcedir=${RHEL8_SOURCE_DIRECTORY}
founddir=true
fi
;;
9)
if [ -d "${RHEL9_SOURCE_DIRECTORY}" ]; then
sourcedir=${RHEL9_SOURCE_DIRECTORY}
founddir=true
fi
;;
*)
log "ERROR: RHEL Major Version Unsupported, rhelmajor=${rhelmajor}"
;;
esac

# When it doesn't exist, fall back to the original directory.
if [ "$founddir" == false ]; then
log "Source directory unavailable for OS version: ${rhelmajor}"
sourcedir=$DEFAULT_SOURCE_DIRECTORY
fi
sourcedir="${SOURCE_DIRECTORY}"
log "Copying binaries from ${sourcedir}"

# Use a subdirectory called "upgrade" so we can atomically move fully copied files.
# We now use --remove-destination after running into an issue with -f not working over symlinks
UPGRADE_DIRECTORY=${DESTINATION_DIRECTORY}upgrade_$(uuidgen)
rm -Rf $UPGRADE_DIRECTORY
mkdir -p $UPGRADE_DIRECTORY
cp -r --remove-destination ${sourcedir}* $UPGRADE_DIRECTORY
find "${sourcedir}" -maxdepth 1 -mindepth 1 ! -type d -exec cp --remove-destination {} "${UPGRADE_DIRECTORY}/" \;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This command is pretty non-obvious, and also very specific to right now, where we know that ${sourcedir} contains subdirectories that we don't care about. Once we update the other modules to stop building the versioned binaries, this fix will be unnecessary. Can we just leave it out?

if [ $? -eq 0 ]; then
log "Successfully copied files in ${sourcedir} to $UPGRADE_DIRECTORY"
else
Expand Down Expand Up @@ -221,8 +172,6 @@ spec:
volumeMounts:
- mountPath: /entrypoint
name: cni-binary-copy
- mountPath: /host/etc/os-release
name: os-release
- name: system-cni-dir
mountPath: /host/etc/cni/net.d
- name: multus-cni-dir
Expand Down Expand Up @@ -260,11 +209,7 @@ spec:
- name: etc-kubernetes
mountPath: /etc/kubernetes
env:
- name: RHEL8_SOURCE_DIRECTORY
value: "/usr/src/multus-cni/rhel8/bin/"
- name: RHEL9_SOURCE_DIRECTORY
value: "/usr/src/multus-cni/rhel9/bin/"
- name: DEFAULT_SOURCE_DIRECTORY
- name: SOURCE_DIRECTORY
value: "/usr/src/multus-cni/bin/"
- name: KUBERNETES_SERVICE_PORT
value: "{{.KUBERNETES_SERVICE_PORT}}"
Expand Down Expand Up @@ -304,10 +249,6 @@ spec:
hostPath:
path: {{ .CNIBinDir }}
type: Directory
- name: os-release
hostPath:
path: /etc/os-release
type: File
- name: cni-binary-copy
configMap:
name: cni-copy-resources
Expand Down Expand Up @@ -399,15 +340,8 @@ spec:
name: cni-binary-copy
- mountPath: /host/opt/cni/bin
name: cnibin
- mountPath: /host/etc/os-release
name: os-release
readOnly: true
env:
- name: RHEL8_SOURCE_DIRECTORY
value: "/usr/src/egress-router-cni/rhel8/bin/"
- name: RHEL9_SOURCE_DIRECTORY
value: "/usr/src/egress-router-cni/rhel9/bin/"
- name: DEFAULT_SOURCE_DIRECTORY
- name: SOURCE_DIRECTORY
value: "/usr/src/egress-router-cni/bin/"
- name: cni-plugins
image: {{.CNIPluginsImage}}
Expand All @@ -418,20 +352,13 @@ spec:
name: cni-binary-copy
- mountPath: /host/opt/cni/bin
name: cnibin
- mountPath: /host/etc/os-release
name: os-release
readOnly: true
- mountPath: /host/etc/cni/tuning/
name: tuning-conf-dir
readOnly: false
- mountPath: /sysctls
name: cni-sysctl-allowlist
env:
- name: RHEL8_SOURCE_DIRECTORY
value: "/usr/src/plugins/rhel8/bin/"
- name: RHEL9_SOURCE_DIRECTORY
value: "/usr/src/plugins/rhel9/bin/"
- name: DEFAULT_SOURCE_DIRECTORY
- name: SOURCE_DIRECTORY
value: "/usr/src/plugins/bin/"
- name: bond-cni-plugin
image: {{.BondCNIPluginImage}}
Expand All @@ -442,16 +369,9 @@ spec:
name: cni-binary-copy
- mountPath: /host/opt/cni/bin
name: cnibin
- mountPath: /host/etc/os-release
name: os-release
readOnly: true
env:
- name: RHEL8_SOURCE_DIRECTORY
value: "/bondcni/rhel8/"
- name: RHEL9_SOURCE_DIRECTORY
value: "/bondcni/rhel9/"
- name: DEFAULT_SOURCE_DIRECTORY
value: "/bondcni/rhel9/"
- name: SOURCE_DIRECTORY
value: "/bondcni/"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

right, ok, although we weren't using it before, the bond-cni image does include a "default" build at the top level

- name: routeoverride-cni
image: {{.RouteOverrideImage}}
command: ["/entrypoint/cnibincopy.sh"]
Expand All @@ -461,15 +381,8 @@ spec:
name: cni-binary-copy
- mountPath: /host/opt/cni/bin
name: cnibin
- mountPath: /host/etc/os-release
name: os-release
readOnly: true
env:
- name: RHEL8_SOURCE_DIRECTORY
value: "/usr/src/route-override/rhel8/bin/"
- name: RHEL9_SOURCE_DIRECTORY
value: "/usr/src/route-override/rhel9/bin/"
- name: DEFAULT_SOURCE_DIRECTORY
- name: SOURCE_DIRECTORY
value: "/usr/src/route-override/bin/"
- name: whereabouts-cni-bincopy
image: {{.WhereaboutsImage}}
Expand All @@ -484,15 +397,8 @@ spec:
name: cni-binary-copy
- mountPath: /host/opt/cni/bin
name: cnibin
- mountPath: /host/etc/os-release
name: os-release
readOnly: true
env:
- name: RHEL8_SOURCE_DIRECTORY
value: "/usr/src/whereabouts/rhel8/bin/"
- name: RHEL9_SOURCE_DIRECTORY
value: "/usr/src/whereabouts/rhel9/bin/"
- name: DEFAULT_SOURCE_DIRECTORY
- name: SOURCE_DIRECTORY
value: "/usr/src/whereabouts/bin/"
- name: whereabouts-cni
image: {{.WhereaboutsImage}}
Expand Down Expand Up @@ -697,10 +603,6 @@ spec:
- name: cnibin
hostPath:
path: {{ .CNIBinDir }}
- name: os-release
hostPath:
path: /etc/os-release
type: File
- name: cni-binary-copy
configMap:
name: cni-copy-resources
Expand Down
40 changes: 2 additions & 38 deletions bindata/network/ovn-kubernetes/common/008-script-lib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -486,44 +486,8 @@ data:
# /cni-bin-dir
cni-bin-copy()
{
# collect host os information
. /host/etc/os-release
rhelmajor=
# detect which version we're using in order to copy the proper binaries
case "${ID}" in
rhcos|scos)
RHEL_VERSION=$(echo "${CPE_NAME}" | cut -f 5 -d :)
rhelmajor=$(echo $RHEL_VERSION | sed -E 's/([0-9]+)\.{1}[0-9]+(\.[0-9]+)?/\1/')
;;
rhel|centos) rhelmajor=$(echo "${VERSION_ID}" | cut -f 1 -d .)
;;
fedora)
if [ "${VARIANT_ID}" == "coreos" ]; then
rhelmajor=8
else
log "cnibincopy" "FATAL ERROR: Unsupported Fedora variant=${VARIANT_ID}"
exit 1
fi
;;
*) log "cnibincopy" "FATAL ERROR: Unsupported OS ID=${ID}"; exit 1
;;
esac

# Set which directory we'll copy from, detect if it exists
sourcedir=/usr/libexec/cni/
case "${rhelmajor}" in
8)
sourcedir=/usr/libexec/cni/rhel8
;;
9)
sourcedir=/usr/libexec/cni/rhel9
;;
*)
log "cnibincopy" "ERROR: RHEL Major Version Unsupported, rhelmajor=${rhelmajor}"
;;
esac

cp -f "$sourcedir/ovn-k8s-cni-overlay" /cni-bin-dir/
log "cnibincopy" "Copying /usr/libexec/cni/ovn-k8s-cni-overlay to /cni-bin-dir/"
cp -f "/usr/libexec/cni/ovn-k8s-cni-overlay" /cni-bin-dir/
}

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