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

Adding term catch to load job cache script #2382

Open
wants to merge 8 commits into
base: integration
Choose a base branch
from

Conversation

avgAGB
Copy link
Collaborator

@avgAGB avgAGB commented May 3, 2024

No description provided.

else
echo "Second SIGTERM received, dipping out"
rm -r -f "$tmpdir"
exit $?
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is following the pattern that was established before you but this doesn't look right to me. I think if we Ctrl+C this script, we wouldn't want to return a successful exit code (0). But this is returning the exit code of the rm command above it, so if the rm works, then we return success.

Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, maybe instead we exit with a 1 here instead? I think that might be prudent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Works for me. Can you also add it to the KILL INT trap too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, will do.

jschmidt10
jschmidt10 previously approved these changes May 14, 2024
# prepare a directory with links to all of the files/directories to put into the jobcache
tmpdir=`mktemp -d $MKTEMP_OPTS`
trap 'rm -r -f "$tmpdir"; exit $?' INT TERM EXIT
trap 'rm -r -f "$tmpdir"; exit 1' INT EXIT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't

trap 'blah ; exit 1' EXIT

guarantee that the script will always exit w/ non-zero status?

Copy link
Collaborator Author

@avgAGB avgAGB May 14, 2024

Choose a reason for hiding this comment

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

going off a discussion with Jeff it looks like if TERM/KILL signals are being sent while this script is running it probably makes sense to return with a non-zero status to imply the script did not exit clean. If the trap isn't encountered though, we would want to exit with a 0 in that case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Trap arg for EXIT will fire even on normal exit of the script. So, I don't see how we'll ever get a zero exit status

E.g., if you run the script below, you'll get non-zero return status:

#!/bin/bash
trap 'echo trapping; exit 1' INT EXIT
exit 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah ok, now I follow. I'll see if I can extract out the EXIT signal from that logic

@keith-ratcliffe keith-ratcliffe changed the base branch from integration to release/version6.14 May 24, 2024 15:57
@keith-ratcliffe keith-ratcliffe dismissed their stale review May 24, 2024 15:57

The base branch was changed.

@keith-ratcliffe keith-ratcliffe changed the base branch from release/version6.14 to integration May 24, 2024 15:58
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.

None yet

3 participants