This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
upgrade_cni_plugin upgrades symlinks which are already in the correct form #3337
Labels
Milestone
What you expected to happen?
What happened?
The weave script function "upgrade_cni_plugin" will attempt to upgrade symlinks even if they exist already in the correct form due to buggy use of readlink: https://github.com/weaveworks/weave/blob/master/weave#L710 and https://github.com/weaveworks/weave/blob/master/weave#L713.
The comparison should probably be something like
because readlink will return an absolute path e.g. /host/opt/cni/bin/$CNI_PLUGIN_NAME.
I think this would go unnoticed if /opt/cni/bin has write permissions (most use cases, probably). I have a read-only root-filesystem with all the moving parts of weave pre-installed. I run "kubectl apply..." to setup weave. Fails due to script "weave" attempting to update the symlinks weave-ipam etc although they already exist.
How to reproduce it?
The problem lies with how "readlink" is used in upgrade_cni_plugin. Here's a minimal example with the relevant functions copied into a test script:
test.sh
Symlinks are created at /tmp/weave-ipam and /tmp/weave-net, as expected. Run the script again:
The symlinks are recreated erroneously. With a slight modification, things behave better:
Running the script:
Symlinks created as expected. Run again:
Symlinks are detected correctly.
Anything else we need to know?
Versions:
Latest
Logs:
n/a
Network:
n/a
The text was updated successfully, but these errors were encountered: