gmeghnag / omc

OpenShift Must-Gather Client
Apache License 2.0
146 stars 62 forks source link

Multiple directory support #92

Open tonyskapunk opened 1 year ago

tonyskapunk commented 1 year ago

It would be nice that omc supported using (reading from) multiple directories.

must-gather can use multiple images[1] to gather data about more than one feature by running a single command.

When multiple images are used, a directory is created for each image, for example:

❯ ls -t many/must_gather/
event-filter.html
timestamp
registry.lan-openshift4-ose-must-gather-sha256-e9601b492cbb375f0a05310efa6025691f8bba6a97667976cd4baf4adf0f244c/
registry.lan-container-native-virtualization-cnv-must-gather-rhel8-sha256-28d78a3ee2e818e2619b10b33b308984dbebe66e302c2f5a7dbd6f527d3b4806/

Currently when a single image is used, a single directory is created and omc can use the top level directory without problems:

❯ ls -t single/must_gather
event-filter.html
timestamp
registry.lan-openshift4-ose-must-gather-sha256-e9601b492cbb375f0a05310efa6025691f8bba6a97667976cd4baf4adf0f244c/

❯ omc use single/must_gather

❯ omc get clusterversion
NAME      VERSION                              AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.12.0-0.nightly-2023-05-18-160444   True        False         54m     Cluster version is 4.12.0-0.nightly-2023-05-18-160444

But when must-gather used multiple images, omc needs to specify the directory to use and switching between directories is very inconvenient, mostly when there are many directories

❯ omc use many/must_gather
Expected one directory in path: "/home/user/many/must_gather", found: 2.

## 😰 have to be specific

❯  omc use many/must_gather/registry.lan-container-native-virtualization-cnv-must-gather-rhel8-sha256-28d78a3ee2e818e2619b10b33b308984dbebe66e302c2f5a7dbd6f527d3b4806/

❯ omc get vmi -A
NAMESPACE   NAME     AGE   PHASE     IP   NODENAME
my-lb       lb-0     17m   Running        worker-0
my-lb       lb-1     20m   Running        worker-2

❯ omc get clusterversion
NAME   VERSION   AVAILABLE   PROGRESSING   SINCE   STATUS

## 😰 have to switch

❯ omc use many/must_gather/registry.lan-openshift4-ose-must-gather-sha256-e9601b492cbb375f0a05310efa6025691f8bba6a97667976cd4baf4adf0f244c/

❯ omc get clusterversion
NAME      VERSION   AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.7.55    True        False         2h3m    Cluster version is 4.7.55

It would be awesome if omc could use mutliple directories to look for the requested data.

[1] https://docs.openshift.com/container-platform/4.13/support/gathering-cluster-data.html#gathering-data-specific-features_gathering-cluster-data

oarribas commented 6 months ago

Probably the more tricky thing will be to decide which directory use when the resources are in both (like pods in namespaces collected by both must-gather images, cluster-scoped-resources, etc..).

oarribas commented 1 month ago

In some cases, not sure how it happens and if can be reproducible, a must-gather directory contains two sub-directories and one of them is called inspect. In those cases, none of the sub-directories contains all the info, and it's needed to change from one to the other. A functionality like this one will be really helpful in those cases, but as already commented above, not sure how to decide from which sub-directory the info should be provided if both contains it (and there could be even few differences between them).