Repository navigation
Fix kubeadmin password printed with trailing newline in openshift and hypershift flows (fixes #891) - #896
Open
shivampwm2020 wants to merge 2 commits into
Conversation
added 2 commits
October 15, 2026 00:52
… and add tests kcli writes <clusterdir>/auth/kubeadmin-password from 'oc extract' stdout, which ends with a newline, so openshift-install --dir=<clusterdir> later prints the password with a literal \n (karmab#891). Strip it when extracting the secret, and cover both openshift read sites plus the hypershift write with a regression test.
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.
Problem
When creating a hypershift cluster (see the linked Actions run in the issue), the final log shows the kubeadmin password with a literal
\nappended:Same behavior for standard openshift clusters (
kcli create cluster --type openshift), because kcli prints the same password withinfo2.Root cause
kvirt/cluster/openshift/__init__.pyreads<clusterdir>/auth/kubeadmin-passwordwithopen(...).read()and no stripping, at both the normal (line ~1588) andasync_install(line ~1783) paths. The openshift-installer writes that file with a trailing newline, so every message kcli prints carries it.kvirt/cluster/hypershift/__init__.py), kcli itself creates<clusterdir>/auth/kubeadmin-passwordfrom the stdout ofoc extract -n <ns> secret/<cluster>-kubeadmin-password --to=-, which also ends with a newline. Whenopenshift-install wait-for install-completelater reads it from that clusterdir, the password is rendered with a trailing\n.Fix
kvirt/cluster/openshift/__init__.py: strip both reads (.read().strip()).kvirt/cluster/hypershift/__init__.py: strip the secret output before writingkubeadmin-passwordto disk.Testing
tests/test_kubeadmin_password.py(stdlib-only, runs withpython3 -m unittest): asserts both openshift reads use.strip(), asserts the hypershift secret write strips, and an end-to-end content test.C5337-...\n(simulatedoc extractstdout) to the file and reading it reproduces the trailing\n; after the fix the value is clean.python3 -m unittest tests.test_kubeadmin_password→ 3 tests, OK.