Skip to content

fixes: add retry to apply original.yaml after crd is installed #4066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion scripts/common/yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function apply_installer_crd() {
cat > $ORIGINAL_INSTALLER_SPEC <<EOL
${INSTALLER_YAML}
EOL
kubectl apply -f "$ORIGINAL_INSTALLER_SPEC"
try_1m kubectl apply -f "$ORIGINAL_INSTALLER_SPEC"
Copy link
Contributor

Choose a reason for hiding this comment

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

The line just apply the manifest.
The try will be re-doing the same command each 2 seconds :

# try a command every 2 seconds until it succeeds, up to 30 tries max; useful for kubectl commands
# where the Kubernetes API could be restarting
function try_1m() {
local fn="$1"
local args=${@:2}
n=0
while ! $fn $args 2>/dev/null ; do
n="$(( $n + 1 ))"
if [ "$n" -ge "30" ]; then
# for the final try print the error and let it exit
echo ""
try_output="$($fn $args 2>&1)" || true
echo "$try_output"
bail "spent 1m attempting to run \"$fn $args\" without success"
fi
sleep 2
done
}

So, why would need to be required to re-duo kubectl apply many times?
What would be solved with that?

+1 to the @emosbaugh comments. That would be great if you could share the problem, and all logs of the issue that you are facing so we can better check it out and see how we can help.

fi

try_1m kubectl apply -f "$MERGED_YAML_SPEC"
Expand Down