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 subtraction bug in start_turbo_cache.sh #407

Merged
merged 1 commit into from
Nov 19, 2023

Conversation

cormacrelf
Copy link
Contributor

@cormacrelf cormacrelf commented Nov 18, 2023

  • Accept shellcheck SC2155 recommendations in start_turbo_cache.sh
  • Remove SCHEDULER_URL as it is both unused & refers to a nonexistent key
  • Accept shellcheck SC2004
  • Fix double negative when computing remaining memory % in terraform deployment

Description

I saw this while browsing through the code. There was a double negative sign.
While I was there, I accepted some shellcheck recommendations, which you can
see in the individual commits.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

It has not been tested.

Checklist

  • PR is contained in a single commit (I left it as separate commits for
    reviewability. You are welcome to squash it at merge time.)

This change is Reviewable

Copy link
Member

@aaronmondal aaronmondal left a comment

Choose a reason for hiding this comment

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

Thanks a lot for finding this ❤️

I like these changes a lot, but they overlap with ongoing work to integrate shellcheck in a regression-safe manner via pre-commit hooks.

I'd like to suggest only making the - - -> - change in this commit and remove all the shellcheck fixes.

Then we can fix all shellcheck issues in a single commit, similar to #405 by adding this to the global tools/pre-commit-hooks.nix file:

shellcheck.enable = true;

This way the nix flake check that runs in CI will ensure that we don't regress shellcheck issues. @cormacrelf WDYT? Would you be interested in tackling this?

Reviewed 1 of 1 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @cormacrelf)

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

FYI: We have been doing a lot of work behind the scenes to support Azure and GCP. We found some issues in the AWS example in the repo while supporting the other providers but haven't upstreamed them yet.

Thank you very much for your contributions ;-)

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @cormacrelf)


deployment-examples/terraform/AWS/scripts/start_turbo_cache.sh line 35 at r4 (raw file):

# These environmental variables are used inside the json file resolution.
export NATIVE_LINK_AWS_REGION="$AWS_REGION"
NATIVE_LINK_AWS_S3_CAS_BUCKET=$(echo "$TAGS"| jq -r '.Tags[] | select(.Key == "native_link:s3_cas_bucket").Value')

nit: Any reason why you prefer define then export rather than doing both in one line?


deployment-examples/terraform/AWS/scripts/start_turbo_cache.sh line 63 at r4 (raw file):

    /usr/local/bin/native-link /root/scheduler.json
elif [ "$TYPE" == "worker" ]; then
    SCHEDULER_URL=$(echo "$TAGS"| jq -r '.Tags[] | select(.Key == "native_link:scheduler_url").Value')

good catch :-)

…ployment

If TOTAL_AVAIL_MEMORY was 100, then this computed

    $(( 100 - - 10 - 5 ))

Which is actually 105. Now it's

    $(( 100 - 10 - 5 ))

Which is 85, as the comment originally claimed.
@cormacrelf
Copy link
Contributor Author

It seems one of you wants me to remove the shellcheck fixes, the other wants me to do them slightly differently. I'm going to get rid of them. You'll see them again when you get CI to check it for you.

I'm not using the AWS deployment at this stage. I might file an issue for the thing I'm thinking of doing (Nix shenanigans).

Copy link
Member

@aaronmondal aaronmondal left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @cormacrelf)

@aaronmondal aaronmondal merged commit 9e981a5 into TraceMachina:main Nov 19, 2023
14 of 15 checks passed
@cormacrelf cormacrelf deleted the bugfix/subtraction branch November 19, 2023 07:15
@allada
Copy link
Member

allada commented Nov 19, 2023

It seems one of you wants me to remove the shellcheck fixes, the other wants me to do them slightly differently. I'm going to get rid of them. You'll see them again when you get CI to check it for you.

I'm not using the AWS deployment at this stage. I might file an issue for the thing I'm thinking of doing (Nix shenanigans).

I see now, I was confused because some things where shellchecked and some were not. I'm in support of adding shellcheck, however I personally go for readability/simplicity, so I'd prefer to never allow our code base to use export VAR=... and force the definition and export to be separate rather than the alternative. I further debate can be had about it. I was more confused why some lines where changed and others were not, but then realized at a second pass because only the lines with commands were modified. I'd just rather not have other people go through the same thought process and rather just blindly follow a rule.

@cormacrelf
Copy link
Contributor Author

Fair. The reason for the rule is that the export builtin always returns 0, so a $() command can fail silently. So it does not warn about export VAR="... $whatever", but will complain about the actual problematic export VAR=$(...) ones. You can blindly "follow the rule" of just doing what shellcheck says, if it's running.

I recommend shellcheck in the editor, e.g. via null-ls for Neovim.

TripleKai pushed a commit to TripleKai/turbo-cache that referenced this pull request Nov 29, 2023
…ployment (TraceMachina#407)

If TOTAL_AVAIL_MEMORY was 100, then this computed

    $(( 100 - - 10 - 5 ))

Which is actually 105. Now it's

    $(( 100 - 10 - 5 ))

Which is 85, as the comment originally claimed.
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.

3 participants