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

Improve error message of dsc/chectl if OpenShift version cannot be determined #23037

Closed
imphil opened this issue Jul 14, 2024 · 1 comment
Closed
Labels
area/chectl Issues related to chectl, the CLI of Che kind/enhancement A feature request - must adhere to the feature request template. team/A This team is responsible for the Che Operator and all its operands as well as chectl and Hosted Che

Comments

@imphil
Copy link

imphil commented Jul 14, 2024

Is your enhancement related to a problem? Please describe

I'm trying to get started with Eclipse Che and am using the chectl/dsc as follows:

$  dsc server:deploy --platform openshift
TypeError: Cannot read properties of undefined (reading 'match')
    at /home/philipp/swinstall/dsc/lib/context.js:261:60
    at Generator.next (<anonymous>)
    at fulfilled (/home/philipp/swinstall/dsc/node_modules/tslib/tslib.js:166:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The error message in itself is not telling much, and it would be nice if it would be more descriptive.

Root cause

  • The code calls oc version -o json and looks for a key openshiftVersion, which doesn't exist.

     const { stdout } = yield execa('oc', ['version', '-o', 'json'], { timeout: 60000 });
              const versionOutput = JSON.parse(stdout);
              const version = versionOutput.openshiftVersion.match(/^\d.\d+/);
  • The openshiftVersion key does not exist because my user does not have permissions to the necessary endpoint. That's only visible if I increase the log level, oc returns successfully otherwise and simply does not output the key.

     $ oc version -o json --loglevel=8
     I0714 14:40:14.835129 1101396 round_trippers.go:463] GET https://MY_CLUSTER/apis/config.openshift.io/v1/clusterversions/version
     I0714 14:40:14.835144 1101396 round_trippers.go:469] Request Headers:
     ...
     I0714 14:40:14.930986 1101396 request.go:1212] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"clusterversions.config.openshift.io \"version\" is forbidden: User \"MY_USER\" cannot get resource \"clusterversions\" in API group \"config.openshift.io\" at the cluster scope","reason":"Forbidden","details":{"name":"version","group":"config.openshift.io","kind":"clusterversions"},"code":403}
     I0714 14:40:14.931196 1101396 version.go:141] OpenShift Version not found (must be logged in to cluster as admin): clusterversions.config.openshift.io "version" is forbidden: User "MY_USER" cannot get resource "clusterversions" in API group "config.openshift.io" at the cluster scope
     {
       "clientVersion": {
         "major": "",
         "minor": "",
         "gitVersion": "4.16.0-202406200537.p0.ga245041.assembly.stream.el9-a245041",
         "gitCommit": "a2450418f7b12a71e8f3562a4e9aa8a976bbf85b",
         "gitTreeState": "clean",
         "buildDate": "2024-06-20T12:26:07Z",
         "goVersion": "go1.21.9 (Red Hat 1.21.9-1.module+el8.10.0+21671+b35c3b78) X:strictfipsruntime",
         "compiler": "gc",
         "platform": "linux/amd64"
       },
       "kustomizeVersion": "v5.0.4-0.20230601165947-6ce0bf390ce3",
       "serverVersion": {
         "major": "1",
         "minor": "25",
         "gitVersion": "v1.25.16+054f0ba",
         "gitCommit": "f5b7c3e8faedd51935d77828a5fc72c7540236f4",
         "gitTreeState": "clean",
         "buildDate": "2024-04-15T13:49:12Z",
         "goVersion": "go1.19.13 X:strictfipsruntime",
         "compiler": "gc",
         "platform": "linux/amd64"
       },
       "releaseClientVersion": "4.16.1"
     }
    

Describe the solution you'd like

Output something like "Unable to determine OpenShift version. Check with oc version -o json --loglevel=8 if you have the necessary permissions."

Describe alternatives you've considered

No response

Additional context

No response

@imphil imphil added the kind/enhancement A feature request - must adhere to the feature request template. label Jul 14, 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 Jul 14, 2024
@RomanNikitenko RomanNikitenko added area/chectl Issues related to chectl, the CLI of Che team/A This team is responsible for the Che Operator and all its operands as well as chectl and Hosted Che and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. labels Jul 15, 2024
@tolusha
Copy link
Contributor

tolusha commented Sep 5, 2024

Fixed by che-incubator/chectl#2929

@tolusha tolusha closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/chectl Issues related to chectl, the CLI of Che kind/enhancement A feature request - must adhere to the feature request template. team/A This team is responsible for the Che Operator and all its operands as well as chectl and Hosted Che
Projects
Status: No status
Development

No branches or pull requests

5 participants