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

Refactor entrypoint.sh 1.0 #47

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

usmanmani1122
Copy link
Contributor

@usmanmani1122 usmanmani1122 commented Aug 30, 2024

Description

Ths PR lays the base for refactoring entrypoint. In this PR, we have moved out exported variables in a separate script which will be sourced in the main script.
We will now send a zip containing scripts which will be extracted on the server and executed there. The deployment change is done in this PR.
Actual diff of the entrypoint script can be checked here

@usmanmani1122 usmanmani1122 self-assigned this Aug 30, 2024
@usmanmani1122 usmanmani1122 changed the title Refactor entrypoint.sh Refactor entrypoint.sh 1.0 Sep 17, 2024
@usmanmani1122 usmanmani1122 marked this pull request as ready for review September 26, 2024 08:10
Copy link
Contributor

@toliaqat toliaqat left a comment

Choose a reason for hiding this comment

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

I don't understand the design and the objectives. Let's talk in our sync on what we want to achieve in the end.

Copy link
Contributor

@toliaqat toliaqat left a comment

Choose a reason for hiding this comment

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

I would rename source.sh to constants.sh.
Good idea to make it flexible to refactor large entrypoint into smaller scripts.

Copy link
Contributor

@toliaqat toliaqat left a comment

Choose a reason for hiding this comment

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

I would like mfig to review as well before you merge it.

Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

Just one question about set -ex. After that's resolved, feel free to merge!

BTW, if you haven't already done so, I suggest installing shellcheck (and an editor plugin like the ShellCheck VSCode extension by Timon Wong) to help write robust shell scripts. It has countless warnings in main.sh (mainly because entrypoint.sh was written without such an an extension), but shellcheck can be very useful when developing a script from scratch.

set -x
set +e
set -ex
Copy link
Member

Choose a reason for hiding this comment

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

These do not mean the same thing. Do you really want set -ex? That's the same as set -e and set -x. set -e will silently terminate the script if any commands return a nonzero exit code. Has this script been audited to ensure that all exit codes are handled carefully to guarantee no unexpected termination?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well I'm curious that why it was set +e at first place. We should stop further execution when any inside command returns non-zero status.
By set +e, we might be supressing the issues directly/indirectly affecting the containers.

Also I think @michaelfig you have raised a good point about verification of exitcode handling and I think "set -ex" might help to identify/fix such problems.

Copy link
Member

@michaelfig michaelfig Oct 16, 2024

Choose a reason for hiding this comment

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

If you'd like to take on this work of auditing and handling the exit codes, I recommend doing it in a separate PR after this one lands (using set +e in this current PR and only enabling set -ex in the new one).

The main reason I'd like this separated is that the current PR should be a pure refactor (i.e. easy to review and uncontroversial to land) and not a behaviour change.

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.

4 participants