Fixes #513: [Improvement] friendly message when kind cluster is in bad state#529
Merged
punkwalker merged 1 commit intocnoe-io:mainfrom Jun 10, 2025
Conversation
… when the container already exists Signed-off-by: Jesse Sanford <108698+jessesanford@users.noreply.github.com>
cmoulliard
reviewed
Jun 10, 2025
punkwalker
approved these changes
Jun 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will allow for kind cluster which are in a bad state to not block users trying to start idpbuidler again. It will print a friendly message so they can debug without having to scour the internet.
Proof:
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ make test
test -s /home/vscode/idpbuilder/bin/controller-gen && /home/vscode/idpbuilder/bin/controller-gen --version | grep -q v0.15.0 ||
GOBIN=/home/vscode/idpbuilder/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0
/home/vscode/idpbuilder/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=pkg/controllers/resources
/home/vscode/idpbuilder/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
go fmt ./...
go vet ./...
test -s /home/vscode/idpbuilder/bin/setup-envtest || GOBIN=/home/vscode/idpbuilder/bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
go: downloading sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20250604165838-d6126d850224
go: downloading sigs.k8s.io/controller-runtime v0.21.0
go: sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20250604165838-d6126d850224 requires go >= 1.24.0; switching to go1.24.4
go: downloading go1.24.4 (linux/arm64)
go: downloading github.com/go-logr/zapr v1.3.0
go: downloading github.com/spf13/pflag v1.0.6
go: downloading go.uber.org/zap v1.27.0
go: downloading github.com/spf13/afero v1.12.0
go: downloading golang.org/x/text v0.23.0
go: downloading go.uber.org/multierr v1.10.0
KUBEBUILDER_ASSETS="/home/vscode/idpbuilder/bin/k8s/1.29.1-linux-arm64" go test -p 1 --tags=integration ./... -coverprofile cover.out
github.com/cnoe-io/idpbuilder coverage: 0.0% of statements
github.com/cnoe-io/idpbuilder/api/v1alpha1 coverage: 0.0% of statements
github.com/cnoe-io/idpbuilder/globals coverage: 0.0% of statements
ok github.com/cnoe-io/idpbuilder/pkg/build 0.020s coverage: 10.5% of statements
github.com/cnoe-io/idpbuilder/pkg/cmd coverage: 0.0% of statements
github.com/cnoe-io/idpbuilder/pkg/cmd/create coverage: 0.0% of statements
github.com/cnoe-io/idpbuilder/pkg/cmd/delete coverage: 0.0% of statements
ok github.com/cnoe-io/idpbuilder/pkg/cmd/get 0.024s coverage: 12.3% of statements
ok github.com/cnoe-io/idpbuilder/pkg/cmd/helpers 0.018s coverage: 8.4% of statements
github.com/cnoe-io/idpbuilder/pkg/cmd/version coverage: 0.0% of statements
github.com/cnoe-io/idpbuilder/pkg/controllers coverage: 0.0% of statements
ok github.com/cnoe-io/idpbuilder/pkg/controllers/custompackage 24.367s coverage: 31.1% of statements
ok github.com/cnoe-io/idpbuilder/pkg/controllers/gitrepository 0.066s coverage: 27.7% of statements
ok github.com/cnoe-io/idpbuilder/pkg/controllers/localbuild 35.100s coverage: 4.0% of statements
ok github.com/cnoe-io/idpbuilder/pkg/k8s 0.347s coverage: 18.1% of statements
ok github.com/cnoe-io/idpbuilder/pkg/kind 0.077s coverage: 21.2% of statements
github.com/cnoe-io/idpbuilder/pkg/logger coverage: 0.0% of statements
github.com/cnoe-io/idpbuilder/pkg/printer coverage: 0.0% of statements
? github.com/cnoe-io/idpbuilder/pkg/printer/types [no test files]
github.com/cnoe-io/idpbuilder/pkg/resources/localbuild coverage: 0.0% of statements
ok github.com/cnoe-io/idpbuilder/pkg/util 2.709s coverage: 24.8% of statements
github.com/cnoe-io/idpbuilder/pkg/util/files coverage: 0.0% of statements
ok github.com/cnoe-io/idpbuilder/pkg/util/fs 0.002s coverage: 25.7% of statements
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ ./idpbuilder create
Jun 10 03:21:40 INFO Creating kind cluster logger=setup
########################### Our kind config ############################
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- containerPort: 443
- containerPort: 32222
- |-
... Jun 10 03:23:17 INFO All workers finished controller=custompackage controllerGroup=idpbuilder.cnoe.io controllerKind=CustomPackage Jun 10 03:23:17 INFO All workers finished controller=gitrepository controllerGroup=idpbuilder.cnoe.io controllerKind=GitRepository Jun 10 03:23:17 INFO Stopping and waiting for cachesimage: "kindest/node:v1.31.4"
labels:
ingress-ready: "true"
extraPortMappings:
hostPort: 8443
protocol: TCP
hostPort: 32222
protocol: TCP
containerdConfigPatches:
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gitea.cnoe.localtest.me:8443"]
endpoint = ["https://gitea.cnoe.localtest.me"]
[plugins."io.containerd.grpc.v1.cri".registry.configs."gitea.cnoe.localtest.me".tls]
insecure_skip_verify = true
######################### config end ############################
Jun 10 03:21:40 INFO Creating kind cluster logger=setup cluster=localdev
Jun 10 03:22:11 INFO Done creating cluster logger=setup cluster=localdev
Jun 10 03:22:11 INFO Adding CRDs to the cluster logger=setup
Jun 10 03:22:12 INFO Setting up CoreDNS logger=setup
Jun 10 03:22:12 INFO Setting up TLS certificate logger=setup
Jun 10 03:22:12 INFO Creating localbuild resource logger=setup
...
########################### Finished Creating IDP Successfully! ############################
Can Access ArgoCD at https://argocd.cnoe.localtest.me:8443/
Username: admin
Password can be retrieved by running: idpbuilder get secrets -p argocd
Jun 10 03:23:17 INFO Stopping and waiting for webhooks
Jun 10 03:23:17 INFO Stopping and waiting for HTTP servers
Jun 10 03:23:17 INFO Wait completed, proceeding to shutdown the manager
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ kind get clusters
localdev
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ ls
api CONTRIBUTING.md docs go.mod hack LICENSE Makefile README.md
bin cover.out globals go.sum idpbuilder main.go pkg tests
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9707da748bbf kindest/node:v1.31.4 "/usr/local/bin/entr…" 3 minutes ago Up 3 minutes 0.0.0.0:32222->32222/tcp, 0.0.0.0:8443->443/tcp, 127.0.0.1:36489->6443/tcp localdev-control-plane
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9707da748bbf kindest/node:v1.31.4 "/usr/local/bin/entr…" 3 minutes ago Up 3 minutes 0.0.0.0:32222->32222/tcp, 0.0.0.0:8443->443/tcp, 127.0.0.1:36489->6443/tcp localdev-control-plane
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ docker stop 9707da748bbf
9707da748bbf
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ kind get clusters
localdev
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ ./idpbuilder create
vscode ➜ ~/idpbuilder (Issue-513-IMP-show-friendly-msg-for-existing-cluster-err) $ ./idpbuilder create
Jun 10 03:26:55 INFO Creating kind cluster logger=setup
Jun 10 03:26:55 INFO Cluster already exists logger=setup cluster=localdev
Jun 10 03:26:55 ERROR Error exporting kubeconfig from kind cluster logger=setup err=failed to get cluster internal kubeconfig: command "docker exec --privileged localdev-control-plane cat /etc/kubernetes/admin.conf" failed with error: exit status 1
Failed to export kubeconfig: cluster localdev is not healthy.
To fix this:
For more options, run: idpbuilder create --help
If the problem persists, check the cluster logs with: kind export logs --name localdev
Error: failed to get cluster internal kubeconfig: command "docker exec --privileged localdev-control-plane cat /etc/kubernetes/admin.conf" failed with error: exit status 1