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

bug: kflex fails when kflex-initial-ctx-name is invalid #202

Open
francostellari opened this issue Feb 14, 2024 · 2 comments
Open

bug: kflex fails when kflex-initial-ctx-name is invalid #202

francostellari opened this issue Feb 14, 2024 · 2 comments
Labels
bug Something isn't working priority/high #e11d21

Comments

@francostellari
Copy link
Contributor

Describe the bug

kflex create cp1 fails when the kubeconfig contains a kflex-initial-ctx-name pointing to an invalid contexts

kflex create cp1
✔ Checking for saved initial context...
✔ Switching to initial context...
Error getting client: error building kubeconfig: invalid configuration: [context was not found for specified context: kind-kubeflex, cluster has no server defined]

Steps To Reproduce

  1. kflex init -c
  2. kind delete clusters --all
  3. oc login ....
  4. helm upgrade --install kubeflex-operator chart/ --namespace kubeflex-system --set isOpenShift=true

the kubeconfig still contains something like:

preferences:
  extensions:
  - extension:
      data:
        kflex-initial-ctx-name: kind-kubeflex
      metadata:
        creationTimestamp: null
        name: kflex-config-extension-name
    name: kflex-config-extension-name

Then

kflex create cp1
✔ Checking for saved initial context...
✔ Switching to initial context...
Error getting client: error building kubeconfig: invalid configuration: [context was not found for specified context: kind-kubeflex, cluster has no server defined]

Expected Behavior

kflex should check on the validity of kflex-initial-ctx-name before using it.
If it is not valid, ignore it, assume that it was not enetered before

Additional Context

No response

@pdettori pdettori added bug Something isn't working ks-0.20 and removed ks-0.20 labels Feb 15, 2024
@pdettori pdettori added the priority/low Higher priority than priority/awaiting-more-evidence. label Apr 25, 2024
@MikeSpreitzer
Copy link
Contributor

MikeSpreitzer commented Oct 7, 2024

I find that with KubeFlex 0.6.3, if the extension stores the name of a context that exists but is not working, this is an unrecoverable state: no kflex ctx command will fix it. For example, I set the extension to say the hosting context is "kscore-stage" at a time when that context exists but is unusable. Then:

mspreitz@mjs13 kubestellar % kubectl config use-context kind-kubeflex
Switched to context "kind-kubeflex".

mspreitz@mjs13 kubestellar % kflex ctx wds1
kubeconfig context wds1 not found (context wds1 not found), trying to load from server...
◐ Switching to context wds1...Error getting kf client: error creating NewDiscoveryRESTMapper: Get "https://c115-e.us-south.containers.cloud.ibm.com:30486/api": dial tcp 50.22.129.34:30486: connect: connection refused

mspreitz@mjs13 kubestellar % kflex ctx
✔ Checking for saved hosting cluster context...
✔ Switching to hosting cluster context...

mspreitz@mjs13 kubestellar % kubectl config current-context
kscore-stage

mspreitz@mjs13 kubestellar % yq .preferences ${KUBECONFIG:-$HOME/.kube/config}
extensions:
  - extension:
      data:
        kflex-initial-ctx-name: kscore-stage
      metadata:
        creationTimestamp: null
        name: kflex-config-extension-name
    name: kflex-config-extension-name

@MikeSpreitzer MikeSpreitzer added priority/high #e11d21 and removed priority/low Higher priority than priority/awaiting-more-evidence. labels Oct 7, 2024
@MikeSpreitzer
Copy link
Contributor

Note also that https://docs.kubestellar.io/release-0.24.0/direct/get-started/ does not invoke kflex init or kflex create, it only has kflex ctx commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority/high #e11d21
Projects
Status: No status
Development

No branches or pull requests

4 participants