Skip to content

Commit

Permalink
Ignore DELETE event, remove unused file
Browse files Browse the repository at this point in the history
This removes treatment of the DELETE event on the inotifywait subshell, which is a leftover from when we implemented an "interface" mode (see #242), and we no longer act on this event.

This also removes the file `cni-plugin/deployment/linkerd-cni.conf.default` that wasn't being used anymore.
  • Loading branch information
alpeb committed Dec 6, 2024
1 parent 4352229 commit 9e24048
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 37 deletions.
1 change: 0 additions & 1 deletion Dockerfile-cni-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ COPY --from=go /go/bin/linkerd-cni /opt/cni/bin/
COPY --from=cni-repair-controller /build/linkerd-cni-repair-controller /usr/lib/linkerd/
COPY LICENSE .
COPY cni-plugin/deployment/scripts/install-cni.sh .
COPY cni-plugin/deployment/linkerd-cni.conf.default .
COPY cni-plugin/deployment/scripts/filter.jq .
ENV PATH=/linkerd:/opt/cni/bin:$PATH
CMD ["install-cni.sh"]
24 changes: 0 additions & 24 deletions cni-plugin/deployment/linkerd-cni.conf.default

This file was deleted.

16 changes: 4 additions & 12 deletions cni-plugin/deployment/scripts/install-cni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,7 @@ sync() {

local config_file_count
local new_sha
if [ "$ev" = 'DELETE' ]; then
# When the event type is 'DELETE', we check to see if there are any `*conf` or `*conflist`
# files on the host's filesystem.
config_file_count=$(find "${HOST_CNI_NET}" -maxdepth 1 -type f \( -iname '*conflist' -o -iname '*conf' \) | sort | wc -l)
if [ "$config_file_count" -eq 0 ]; then
log "No active CNI configuration file found after $ev event"
fi
elif [ "$ev" = 'CREATE' ] || [ "$ev" = 'MOVED_TO' ] || [ "$ev" = 'MODIFY' ]; then
if [ "$ev" = 'CREATE' ] || [ "$ev" = 'MOVED_TO' ] || [ "$ev" = 'MODIFY' ]; then
# When the event type is 'CREATE', 'MOVED_TO' or 'MODIFY', we check the
# previously observed SHA (updated with each file watch) and compare it
# against the new file's SHA. If they differ, it means something has
Expand All @@ -287,14 +280,13 @@ sync() {
# Monitor will start a watch on host's CNI config directory
monitor() {
inotifywait -m "${HOST_CNI_NET}" -e create,delete,moved_to,modify |
inotifywait -m "${HOST_CNI_NET}" -e create,moved_to,modify |
while read -r directory action filename; do
if [[ "$filename" =~ .*.(conflist|conf)$ ]]; then
log "Detected change in $directory: $action $filename"
sync "$filename" "$action" "$cni_conf_sha"
# When file exists (i.e we didn't deal with a DELETE ev)
# then calculate its sha to be used the next turn.
if [[ -e "$directory/$filename" && "$action" != 'DELETE' ]]; then
# calculate file SHA to use in the next iteration
if [[ -e "$directory/$filename" ]]; then
cni_conf_sha="$(sha256sum "$directory/$filename" | while read -r s _; do echo "$s"; done)"
fi
fi
Expand Down

0 comments on commit 9e24048

Please sign in to comment.