Skip to content

Commit

Permalink
handle the introduction of instancetypes (#190)
Browse files Browse the repository at this point in the history
Signed-off-by: assafad <[email protected]>
  • Loading branch information
assafad authored Sep 18, 2023
1 parent 823e6ce commit a61e3cc
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WORKDIR /go/src/github.com/kubevirt/must-gather/cmd
COPY cmd .
RUN (cd vmConvertor && go build -ldflags="-s -w" .)

FROM quay.io/openshift/origin-must-gather:4.12.0 as builder
FROM quay.io/openshift/origin-must-gather:4.13.0 as builder

FROM quay.io/centos/centos:stream8

Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ Usage: oc adm must-gather --image=quay.io/kubevirt/must-gather -- /usr/bin/gathe
> You can also choose to enable optional collectors combining one
> or more of the following parameters:
--images
--instancetypes
--vms_details
```

Expand Down Expand Up @@ -186,15 +185,6 @@ Or
oc adm must-gather --image=quay.io/kubevirt/must-gather -- PROS=3 /usr/bin/gather --images
```

### Targeted gathering - Instancetypes and preferences

VirtualMachineInstancetypes and VirtualMachinePreferences are not currently collected by default but can be
by running the following command:

```sh
oc adm must-gather --image=quay.io/kubevirt/must-gather -- /usr/bin/gather --instancetypes
```

## Development
You can build the image locally using the Dockerfile included.

Expand Down
2 changes: 1 addition & 1 deletion automation/deploy_hco.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -ex

HCO_VERSION=1.8.0
HCO_VERSION=1.9.0
UNSTABLE="-unstable"
MINOR_VER="${HCO_VERSION%.*}"
CMD=oc
Expand Down
5 changes: 1 addition & 4 deletions collection-scripts/gather
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function main() {
"ssp"
"virtualmachines"
"webhooks"
"instancetypes"
)
declare requested_scripts=("${mandatory_scripts[@]}")

Expand All @@ -38,9 +39,6 @@ function parse_flags {
--images)
requested_scripts+=("images")
;;
--instancetypes)
requested_scripts+=("instancetypes")
;;
--vms_details)
requested_scripts+=("vms_details")
requested_scripts+=("vms_namespaces")
Expand Down Expand Up @@ -80,7 +78,6 @@ Usage: oc adm must-gather --image=quay.io/kubevirt/must-gather -- /usr/bin/gathe
> You can also choose to enable optional collectors combining one
> or more of the following parameters:
--images
--instancetypes
--vms_details
"
}
Expand Down
14 changes: 13 additions & 1 deletion collection-scripts/gather_instancetypes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ DIR_NAME=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "${DIR_NAME}/common.sh"
check_command

resources=(virtualmachineinstancetype virtulmachineclusterinstancetype virtualmachinepreference virtualmachineclusterpreference)
resources=(virtualmachineinstancetype virtualmachineclusterinstancetype virtualmachinepreference virtualmachineclusterpreference)

echo "${resources[@]}" | tr ' ' '\n' | xargs -t -I{} -P "${PROS}" --max-args=1 sh -c 'echo "inspecting $1" && oc adm inspect --dest-dir ${BASE_COLLECTION_PATH} --all-namespaces $1' -- {}

function gather_controller_revision() {
oc_project=$(echo "$1" | awk -F_ '{print $1}')
revision_name=$(echo "$1" | awk -F_ '{print $2}')
echo "inspecting ${revision_name} controller revision"

/usr/bin/oc adm inspect --dest-dir "${BASE_COLLECTION_PATH}" -n "${oc_project}" controllerrevision "${revision_name}"
}

export -f gather_controller_revision
controller_revisions=$(oc get controllerrevision --all-namespaces | grep virtualmachine | awk '{print $1 "_" $2}')
echo "${controller_revisions[@]}" | tr ' ' '\n' | xargs -P "${PROS}" --max-args=1 -t -I{} sh -c 'gather_controller_revision $1' -- {}

9 changes: 8 additions & 1 deletion tests/validate_must_gather_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ var _ = Describe("validate the must-gather output", func() {
"cdiconfigs.cdi.kubevirt.io": false,
"cdis.cdi.kubevirt.io": false,
"networkaddonsconfigs.networkaddonsoperator.network.kubevirt.io": false,
"virtualmachineclusterinstancetypes.instancetype.kubevirt.io": false,
"virtualmachineclusterpreferences.instancetype.kubevirt.io": false,
}

for expectedResource := range expectedResources {
Expand All @@ -120,7 +122,12 @@ var _ = Describe("validate the must-gather output", func() {
crDir := path.Join(crsDir, cr.Name())
crFiles, err := os.ReadDir(crDir)
Expect(err).ToNot(HaveOccurred())
Expect(crFiles).Should(HaveLen(1))

if strings.Contains(cr.Name(), "instancetype") {
Expect(crFiles).ShouldNot(BeEmpty())
} else {
Expect(crFiles).Should(HaveLen(1))
}

if crFiles[0].IsDir() {
continue
Expand Down

0 comments on commit a61e3cc

Please sign in to comment.