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

Fix 'setup-zk' bash syntax error #769

Merged
merged 1 commit into from
Mar 17, 2025
Merged

Conversation

gerlowskija
Copy link
Contributor

Mismatched brackets were causing the 'grep' portion of the conditional to report an error when triggered.

Fixes #759

Mismatched brackets were causing the 'grep' portion of the conditional
to report an error when triggered.
Copy link
Contributor

@HoustonPutman HoustonPutman left a comment

Choose a reason for hiding this comment

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

Can we test this? I ask because your testing for the other ticket didn't see an error here...

@gerlowskija
Copy link
Contributor Author

I think our existing testing (see tests/e2e/solrcloud_security_json_test.go) is sufficient here. It never caught the #759 error, because it's not actually an error ("just" some noise in the logs)!

grep -q does print a message to stderr, but it doesn't impact the return status of the grep call, which returns zero/non-zero based on whether it finds a match in /tmp/current_security.json. grep doesn't care that you also asked it to search other files (i.e. ]) that don't exist. So despite the syntax error, the overall conditional still operated as we wanted it to.

We could add an additional test case to solrcloud_security_json_test.go, to cover the case of a security.json file whose contents are {}, but IMO that edgecase is rare enough that it's not worth bloating the runtime of our e2e tests.

If anyone disagrees though, lmk and I'll add it in. Otherwise, I'll probably target early next week to merge this.

@madrob
Copy link
Contributor

madrob commented Mar 14, 2025

I would consider pulling the entire scriptlets into separate files and then you can run spellcheck on those?

@gerlowskija
Copy link
Contributor Author

"Spellcheck" or "ShellCheck"?

Assuming you mean "ShellCheck", but I'm not too familiar with it. Seems like a good thing to have analysis on generally - our unit tests validate that the container "command" looks the way we expect, but nothing ever really ensures that it's even valid bash 😦

Thanks for the pointer; will take a look and file a follow-on ticket if it seems promising!

@gerlowskija gerlowskija merged commit d14f13b into apache:main Mar 17, 2025
3 checks passed
@gerlowskija gerlowskija deleted the 759-bash-fix branch March 17, 2025 17:02
gerlowskija added a commit that referenced this pull request Mar 17, 2025
Mismatched brackets were causing the 'grep' portion of the conditional
to report an error when triggered.
@madrob
Copy link
Contributor

madrob commented Mar 17, 2025

Yes, shellcheck. Auto-correct got me!

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.

Zk-setup error
3 participants