gmeghnag / omc

OpenShift Must-Gather Client
Apache License 2.0
153 stars 63 forks source link

The `omc` fails to get all namespaces #157

Closed jianzhangbjz closed 6 months ago

jianzhangbjz commented 6 months ago

When checking the must-gather from https://access.redhat.com/support/cases/#/case/03798085, the omc only gets 5 projects.

jiazha-mac:~ jiazha$ omc use ~/Downloads/must-gather.local.7235806614755410709
jiazha-mac:~ jiazha$ omc get ns 
NAME                        STATUS   AGE
default                     Active   1y
kube-system                 Active   1y
openshift                   Active   1y
openshift-cluster-version   Active   1y
openshift-etcd              Active   1y
jiazha-mac:~ jiazha$ omc get ns |wc -l 
       6

However, the omg can get 431 projects, as follows,

jiazha-mac:~ jiazha$ omg use ~/Downloads/must-gather.local.7235806614755410709
Selected must-gather: /Users/jiazha/Downloads/must-gather.local.7235806614755410709/quay-io-openshift-release-dev-ocp-v4-0-art-dev-sha256*
            Projects: 431

     Current Project: openshift-storage

jiazha-mac:~ jiazha$ omg get ns 
NAME                                              AGE
hunter                                            Unknown
openshift-ingress                                 Unknown
usaa                                              Unknown
openshift-osd-metrics                             Unknown
trb766ecc0402                                     Unknown
...
...
jiazha-mac:~ jiazha$ omg get ns |wc -l 
     432
jianzhangbjz commented 6 months ago

/assign @gmeghnag

jianzhangbjz commented 6 months ago

This omc binary was build with the latest code.

jiazha-mac:omc jiazha$ git log 
commit 4dcebdc397740a11030cc6458d9ef33aa4127d37 (HEAD -> main, origin/main, origin/HEAD)
Author: gmeghnag <gmeghnag@redhat.com>
Date:   Mon May 6 22:20:13 2024 +0200

    fix #156
...
jiazha-mac:omc jiazha$ go install 
jiazha-mac:omc jiazha$ ls -l /Users/jiazha/golang/go1.21/bin/omc
-rwxr-xr-x  1 jiazha  staff  101573666  5  9 11:01 /Users/jiazha/golang/go1.21/bin/omc
gmeghnag commented 6 months ago

Hi @jianzhangbjz when you run omc get namespaces it only return the namespaces where the <namespace>.yaml file is present so you can do omc get ns <namespace> -o yaml.

If you want to check all the projects present in the must-gather you can execute:

omc projects

But you will see that executing omc get <namespace> -o yaml for all of them (except the ones listed as namespace) will fail because the namespace resource yaml file is not present for them.

cchen666 commented 6 months ago

I am wondering whether we could add a warning message to the user that the actual collected namespace number is larger than the ones that contain \<namespace>.yaml? This might reduce any unnecessary confusion or back and forth MG collection request to the customer.

Something like:

$ omc get ns 
Warning: the actual project number is 431, which is larger than the following listed. Check must-gather.local.7235806614755410709/quay-XXXXXX/namespaces instead!

NAME                        STATUS   AGE
default                     Active   1y
kube-system                 Active   1y
openshift                   Active   1y
openshift-cluster-version   Active   1y
openshift-etcd              Active   1y
gmeghnag commented 6 months ago

@cchen666 I don't want the output of omc get ns to be different from that of oc get ns (mostly because of automation that can be done using omc), so we won't implement any warning messages at the moment.