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

Do not redefine the global $resources variable #23

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

fmount
Copy link
Contributor

@fmount fmount commented Nov 26, 2023

This patch fixes in the first place the usage of the resources variable.
The purpose of this variable is to define a set of k8s related services
that should be collected for each namespace; for this reason it's
defined in common.sh and exported, so it can be used in any script
that is sourced by gather_run.
Instead of using the same $resources variable that is used a lot in the
collection-scripts, this change customizes the variable name used to collect
CR(s) and apiservices, and it avoids collisions with other get_resources
happening in other namespaces.
In addition, this patch fixes the way CRD(s) are collected: they are global
and shouldn't be collected per-namespace, hence they're now collected
within the crd/ folder created in the root must-gather directory.

@fmount fmount requested review from abays and lewisdenny November 26, 2023 07:10
@fmount fmount force-pushed the fix_crs branch 3 times, most recently from 9e03265 to ed2249d Compare November 26, 2023 19:39
@fmount fmount changed the title Use a different variable to collect CRS Do not redefine the global resources variable Nov 26, 2023
@fmount fmount changed the title Do not redefine the global resources variable Do not redefine the global $resources variable Nov 26, 2023
for resource in "${resources[@]}"; do
run_bg /usr/bin/oc adm inspect --dest-dir must-gather "${resource}"
for resource in "${crds[@]}"; do
run_bg /usr/bin/oc get crd "$resource" > "${BASE_COLLECTION_PATH}/crd/${resource}.yaml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: I don't think this is not going to output the yaml like we want should be oc get crd "$resource" -o yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, updating it!

while read -r ocresource; do
ocobject=$(echo "$ocresource" | awk '{print $1}')
ocproject=$(echo "$ocresource" | awk '{print $2}')
if [ -z "${ocproject}" ]||[ "${ocproject}" == "<none>" ]; then
object_collection_path=${BASE_COLLECTION_PATH}/cluster-scoped-resources/${resource}
if [ -n "${ocproject}" ]||[ "${ocproject}" != "<none>" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: This should not be an or (||) but an and (&&)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, not sure why I have this leftover here, but yes, when I change -z to -n I intended to change the and condition as well! Updating it!

This patch fixes in the first place the usage of the "resources" variable.
The purpose of this variable is to define a set of k8s related services
that should be collected for each namespace; for this reason it's
defined in common.sh and exported, so it can be used in any script that
is sourced by "gather_run".
Instead of using the same "$resources" variable that is used a lot in the
collection-scripts, this change customizes the variable name used to collect
CR(s) and apiservices, and it avoids collisions with other 'get_resources'
happening in other namespaces.
In addition, this patch fixes the way CRD(s) are collected: they are
global and shouldn't be collected "per namespace", hence they're now
collected within the "crd/" folder created in the root must-gather directory.

Signed-off-by: Francesco Pantano <[email protected]>
Copy link
Contributor

@Akrog Akrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@fmount fmount merged commit b535eb2 into openstack-k8s-operators:main Nov 27, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants