Skip to content
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

[QUESTION/HELP] k3d script k3d-entrypoint-dns.sh might have a problem #1445

Open
2fxprogeeme opened this issue May 29, 2024 · 1 comment
Open
Labels
question Further information is requested

Comments

@2fxprogeeme
Copy link

2fxprogeeme commented May 29, 2024

Hi,

I use k3d version 5.6.3 with rootless podman, version 4.6.1, and I had no problems creating k3d clusters for the last months but now suddenly during cluster creation the startup of the k3d containers fail.

I found out that startup of software in container is with script k3d-entrypoint.sh which first searches for additional scripts k3d-entrypoint-*.sh and executes them.
The problem I have is in script k3d-entrypoint-dns.sh. First part of the problem is the line

set -o errexit

This will end script execution immediately if a command returns with exit code not equal 0.
The second part of my problem are the lines

grep -q "${docker_dns}" /etc/resolv.conf
grepstatus=$?

Here if ${docker_dns} is not found in /etc/resolv.conf the grep command terminates with 1. This case is handled in the next lines. But this next line is never executed due to set -o errexit and so the script terminates and as a result the complete startup terminates.

My question: Is that as expected or should the startup script k3d-entrypoint-dns.sh be modified to be able to handle the result of the grepcommand?

Btw, set -o errexit is set in nearly every kde-entrypoint-*.sh script. Maybe there are additional code lines with similar behavior?

Best regards
Ulrich.

@2fxprogeeme 2fxprogeeme added the question Further information is requested label May 29, 2024
@2fxprogeeme
Copy link
Author

Additional information.
In my last post I wrote that start of cluster members failed suddenly. In the meantime I found the reason for that. Cluster member startup only fails if I have the official installation installed on my system (installed using curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash). If I build from branch main everything works fine. There is a difference in file k3d-entrypoint-dns.sh between branch main and main-v5.

From branch main (working in my case)

.
# Update resolv.conf to use the Gateway IP if needed: this will also make CoreDNS use it via k3s' default `forward . /etc/resolv.conf` rule in the CoreDNS config
if grep -q "${docker_dns}" /etc/resolv.conf; then
  echo "[$(date -Iseconds)] [DNS Fix] > Replacing IP in /etc/resolv.conf ..."
.

From branch main-v5

.
# Update resolv.conf to use the Gateway IP if needed: this will also make CoreDNS use it via k3s' default `forward . /etc/resolv.conf` rule in the CoreDNS config
grep -q "${docker_dns}" /etc/resolv.conf
grepstatus=$?
if test $grepstatus -eq 0; then
.

In the working case (call of grep within "if") the exit code of the grep is handled by the if and so set -o errexit has no impact.

Please consider to at least merge the content of entrypoint-dns.sh from branch main to main-v5.

Best regards
Ulrich

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant