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

Kubeconfig Format Corruption After Switching Clusters and Restarting Workspace #23238

Open
eye0fra opened this issue Nov 7, 2024 · 4 comments
Assignees
Labels
area/devworkspace-operator kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system.

Comments

@eye0fra
Copy link

eye0fra commented Nov 7, 2024

Describe the bug

Hello,
I've encountered an issue with Kubernetes context renewal/injection. Initially, the kubeconfig is in JSON format. However, when I use the oc command line to log into a different cluster for testing, the format switches to YAML.
Upon restarting the workspace, the injection process disrupts the YAML file, causing it to become a single inline entry. Consequently, the kubeconfig becomes unusable, affecting all related dependencies, such as kubedock.
The current workaround is to delete the kubeconfig and restart the workspace to restore the correct kubeconfig format.

Che version

7.94@latest

Steps to reproduce

  1. Initial Setup:

    • Ensure you have a kubeconfing in JSON format at the start of the workspaces
    • Verify that your workspace is configured to use this kubeconfig. (kubedock is working)
  2. Switch Cluster:

    • Use the oc command line tool to log into a different OpenShift cluster:
      oc login <cluster-url> --token=<your-token>
    • Note that the kubeconfig format changes to YAML.
    • I believe is not necessary to use a different cluster, but run oc login command to override the config.
  3. Restart Workspace:

    • Restart your development workspace.
  4. Observe the Issue:

    • Check the kubeconfig file. It should now be a single inline YAML entry.
    • Attempt to use Kubernetes-related commands or dependencies like kubedock and observe failures due to the malformed kubeconfig.
  5. Workaround:

    • Delete the kubeconfig.
    • Restart the workspace to restore the correct kubeconfig format.

Expected behavior

The kubeconfig should maintain its format and functionality after switching context.

Runtime

OpenShift

Screenshots

Screenshot 2024-11-07 at 11 36 35 Screenshot 2024-11-07 at 10 21 35 Screenshot 2024-11-06 at 17 01 43 Screenshot 2024-11-06 at 16 59 55

Installation method

OperatorHub

Environment

other (please specify in additional context)

Eclipse Che Logs

No response

Additional context

OpenShift DevSpaces 3.16.1

@eye0fra eye0fra added the kind/bug Outline of a bug - must adhere to the bug report template. label Nov 7, 2024
@che-bot che-bot added the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Nov 7, 2024
@dkwon17 dkwon17 added severity/P2 Has a minor but important impact to the usage or development of the system. area/devworkspace-operator severity/P1 Has a major impact to usage or development of the system. and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. severity/P2 Has a minor but important impact to the usage or development of the system. labels Nov 12, 2024
@vinokurig vinokurig self-assigned this Nov 14, 2024
@vinokurig vinokurig moved this to Unplanned Tasks in Eclipse Che Team A Backlog Nov 14, 2024
@vinokurig
Copy link
Contributor

vinokurig commented Nov 14, 2024

Hello @eye0fra, could you please elaborate more on:

  • workspace you started, can you provide the devfile you used?
  • Verify that your workspace is configured to use this kubeconfig. (kubedock is working), could you please provide some description related to kubedoc.
  • Where did you launch the oc whoami command? was it your local machine terminal, or workspace pod's terminal?
    Currently I was able to reproduce the case where the config file changes from JSON to YAML in the workspace dev container terminal, but that did not affect the oc commands.

@vinokurig vinokurig moved this from Unplanned Tasks to Pending Customer Input in Eclipse Che Team A Backlog Nov 15, 2024
@vinokurig vinokurig moved this from Pending Customer Input to Analyzing in Eclipse Che Team A Backlog Nov 15, 2024
@ibuziuk ibuziuk moved this from Analyzing to 📅 Planned in Eclipse Che Team A Backlog Nov 18, 2024
@eye0fra
Copy link
Author

eye0fra commented Nov 19, 2024

  1. The workspace can be empty and is not dependent on the devfile definition.
  2. If the kubedock process is running without errors, it indicates that the kube config file is intact and not corrupted.
  3. What do you mean "my local machine," all the tests are on the workspace terminal. If you can execute the command afterwards, is the YAML formatted correctly? Based on the attached picture, I have doubts about its functionality.

@vinokurig vinokurig moved this from 📅 Planned to 🚧 In Progress in Eclipse Che Team A Backlog Nov 21, 2024
@vinokurig
Copy link
Contributor

@eye0fra According to the error this is a formatting issue, can you provide the content of the /home/.kube/config file after the new oc login. You can hide the sensitive data with ***.

@vinokurig
Copy link
Contributor

@eye0fra Could you please provide the cluster's kubernetes version as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devworkspace-operator kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system.
Projects
Status: 🚧 In Progress
Development

No branches or pull requests

4 participants