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

LOG-6277: Fix LokiStack is not gathered even if it exists. #2845

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kattz-kawa
Copy link

Description

The must-gather code[1] gathers LokiStack only when "lokistack" wasn't found in the result of "oc get crd".
It means that LokiStack isn't gathered even if it exists.

[1]

loki_crd=$(oc get crd -A -o custom-columns=:.metadata.name | grep lokistack)||

The current line should use && instead of ||. This change is important because, in bash, if the left expression of || is true, the right expression is not evaluated. By using &&, the right expression will be evaluated if LokiStack exists, ensuring that the information is gathered correctly.

Here is an example to demonstrate this point:

$ bash -c 'echo first expression || echo second expression'
first expression  # <--- second expression is not evaluated
$ bash -c 'echo first expression && echo second expression'
first expression
second expression

/cc @Clee2691
/assign @jcantrill

Links

JIRA: https://issues.redhat.com/browse/LOG-6277

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 24, 2024
@openshift-ci-robot
Copy link

@kattz-kawa: This pull request references LOG-6277 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.8.0" version, but no target version was set.

In response to this:

Description

The must-gather code[1] gathers LokiStack only when "lokistack" wasn't found in the result of "oc get crd".
It means that LokiStack isn't gathered even if it exists.

[1]

loki_crd=$(oc get crd -A -o custom-columns=:.metadata.name | grep lokistack)||

The current line should use && instead of ||. This change is important because, in bash, if the left expression of || is true, the right expression is not evaluated. By using &&, the right expression will be evaluated if LokiStack exists, ensuring that the information is gathered correctly.

Here is an example to demonstrate this point:

$ bash -c 'echo first expression || echo second expression'
first expression  # <--- second expression is not evaluated
$ bash -c 'echo first expression && echo second expression'
first expression
second expression

/cc @Clee2691
/assign @jcantrill

Links

JIRA: https://issues.redhat.com/browse/LOG-6277

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from Clee2691 October 24, 2024 22:01
@openshift-ci openshift-ci bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 24, 2024
Copy link
Contributor

openshift-ci bot commented Oct 24, 2024

Hi @kattz-kawa. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@@ -91,7 +91,7 @@ else
log "Skipping collection inspection. No default CLO found" 2>&1 | tee "${LOGFILE_PATH}"
fi

loki_crd=$(oc get crd -A -o custom-columns=:.metadata.name | grep lokistack)||
loki_crd=$(oc get crd -A -o custom-columns=:.metadata.name | grep lokistack)&&
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the correct fix is to have two separate lines and no logical operator or list.

Copy link
Author

Choose a reason for hiding this comment

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

I agree with your point. It seems I misunderstood the significance of this logical operator. I will fix it into two separate lines and request a review again.

Signed-off-by: Katuya Kawakami <[email protected]>
Signed-off-by: Masaki Hatada <[email protected]>
Copy link
Contributor

openshift-ci bot commented Oct 25, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kattz-kawa
Once this PR has been reviewed and has the lgtm label, please ask for approval from jcantrill. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jcantrill
Copy link
Contributor

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 25, 2024
Copy link
Contributor

openshift-ci bot commented Oct 25, 2024

@kattz-kawa: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@jcantrill
Copy link
Contributor

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants