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

Change Shellcheck severity level to warning and make fixes #2611

Merged
merged 5 commits into from
Jan 17, 2024

Conversation

judysng
Copy link
Contributor

@judysng judysng commented Jan 8, 2024

Description of changes

  • Changed the shellcheck severity level to warning to discover potential problems earlier
  • Fixed the warnings, the warnings are in this check in my fork

Tests

  • Tested the bash line changes locally
  • Ran bump-version.sh

References

  • Also changed severity level to warning in the CLI and node

Checklist

  • Make sure you are pointing to the right branch.
  • If you're creating a patch for a branch other than develop add the branch name as prefix in the PR title (e.g. [release-3.6]).
  • Check all commits' messages are clear, describing what and why vs how.
  • Make sure to have added unit tests or integration tests to cover the new/modified code.
  • Check if documentation is impacted by this change.

Please review the guidelines for contributing and Pull Request Instructions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (517e55d) 75.56% compared to head (88ba324) 75.56%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2611   +/-   ##
========================================
  Coverage    75.56%   75.56%           
========================================
  Files           16       16           
  Lines         2132     2132           
========================================
  Hits          1611     1611           
  Misses         521      521           
Flag Coverage Δ
unittests 75.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -73,7 +72,7 @@ function print_block_device_mapping {
function check_instance_store {
if ls /dev/nvme* >& /dev/null; then
IS_NVME=1
MAPPINGS=$(realpath --relative-to=/dev/ -P /dev/disk/by-id/nvme*Instance_Storage* | grep -v "*Instance_Storage*" | uniq)
MAPPINGS=$(realpath --relative-to=/dev/ -P /dev/disk/by-id/nvme*Instance_Storage* | grep -v "Instance_Storage" | uniq)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this shellcheck warning SC2063, I deleted the *'s as advised, but I am unsure what behavior we want:

Before, the grep -v "*Instance_Storage*" wouldn't filter out any results, because the * at the beginning wouldn't match anything, so the statement would've been the same as MAPPINGS=$(realpath --relative-to=/dev/ -P /dev/disk/by-id/nvme*Instance_Storage* | uniq). Is that what we want instead?

With the deletion of the *'s, MAPPINGS would be empty, because grep will filter out all results since all the results contain Instance_Storage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's do this:
MAPPINGS=$(realpath --relative-to=/dev/ -P /dev/disk/by-id/nvme*Instance_Storage* | grep -v "\*Instance_Storage\*" | uniq)

Explanation: The command does not filter out any results on instance types without instance store. If the command is run on instance types with instance store, there will be results.

The -v in grep is revert filter. This is to filter out /dev/disk/by-id/nvme*Instance_Storage* from realpath when running on instance types without instance store.

My proposal uses \ to escape * to tell shellcheck the *s are not Regex keywords

I usually sub-command one by one to understand a command so big :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh got it, thanks for the explanation. I have updated the line

@@ -75,6 +75,7 @@ checksum_mismatch() {
unable_to_retrieve_package() {
echo "Unable to retrieve a valid package!"
report_bug
# shellcheck disable=SC2154
echo "Metadata URL: $metadata_url"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am unsure where metadata_url comes from

Copy link
Contributor

Choose a reason for hiding this comment

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

As you can see in the first comment of this bash script, this file is a copy of the https://omnitruck.cinc.sh/install.sh file, with some modification (you can see the modification in the comments on top of the file).

During the modification we removed the part to download the installer from cinc website and we're downloading it from S3 instead. You can remove all the lines were we're printing the metadata_url, it's useless for us.

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, I deleted the lines with metadata_url. Thanks!

@judysng judysng merged commit 655b9f8 into aws:develop Jan 17, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants