8000 fix: Litestream S3 - add support to deprecated env variables by pranavxc · Pull Request #8555 · nocodb/nocodb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Litestream S3 - add support to deprecated env variables #8555

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

Merged
merged 1 commit into from
May 23, 2024

Conversation

pranavxc
Copy link
Member

Change Summary

Change type

  • feat: (new feature for the user, not a new feature for build script)
  • fix: (bug fix for the user, not a fix to a build script)
  • docs: (changes to the documentation)
  • style: (formatting, missing semi colons, etc; no production code change)
  • refactor: (refactoring production code, eg. renaming a variable)
  • test: (adding missing tests, refactoring tests; no production code change)
  • chore: (updating grunt tasks etc; no production code change)

Test/ Verification

Provide summary of changes.

Additional information / screenshots (optional)

Anything for maintainers to be made aware of

@pranavxc pranavxc added the 🛑 Status: Do Not Merge Used in PR only. The PR cannot be merged due to some reasons. label May 23, 2024
Copy link
Contributor
coderabbitai bot commented May 23, 2024

Warning

Rate Limit Exceeded

@pranavxc has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 0 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 6b9ffa6 and f441403.

Walkthrough

The start-litestream.sh script has been updated to enhance S3 backup configuration. It now dynamically sets LITESTREAM_S3_PATH and LITESTREAM_S3_BUCKET based on the provided AWS environment variables. Additionally, the use_litestream function has been modified to verify the presence of either LITESTREAM_S3_BUCKET or LITESTREAM_S3_ENDPOINT before proceeding.

Changes

File Path Change Summary
packages/nocodb/docker/start-litestream.sh - Removed export LITESTREAM_S3_URL="s3://${AWS_BUCKET}/${AWS_BUCKET_PATH}"
- Added export LITESTREAM_S3_PATH="${AWS_BUCKET_PATH}"
- Added export LITESTREAM_S3_BUCKET="${AWS_BUCKET}"
- Added export LITESTREAM_S3_FORCE_PATH_STYLE="false"
- Modified condition in use_litestream to check for [ -n "${LITESTREAM_S3_BUCKET}" ] or [ -n "${LITESTREAM_S3_ENDPOINT}" ]

Assessment against linked issues

Objective Addressed Explanation
Ensure persistence backs up to S3 on the latest version of Noco (#8549)
Verify that use_litestream function checks for either LITESTREAM_S3_BUCKET or LITESTREAM_S3_ENDPOINT
Ensure LITESTREAM_S3_PATH and LITESTREAM_S3_BUCKET are set based on AWS_BUCKET_PATH and AWS_BUCKET (#8549)
Remove deprecated export LITESTREAM_S3_URL configuration

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4ee308e and ad35cb5.
Files selected for processing (1)
  • packages/nocodb/docker/start-litestream.sh (2 hunks)
Additional Context Used
ShellCheck (2)
packages/nocodb/docker/start-litestream.sh (2)

[error] 14-14: To expand via indirection, use arrays, ${!name} or (for sh only) eval.


[warning] 28-28: This } is literal. Check expression (missing ;/\n?) or quote it.

Additional comments not posted (1)
packages/nocodb/docker/start-litestream.sh (1)

28-28: Verify the syntax around the conditional braces.

@pranavxc pranavxc force-pushed the fix/8549-add-support-to-deprecated-envs branch from ad35cb5 to 90008af Compare May 23, 2024 09:52
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ad35cb5 and 90008af.
Files selected for processing (1)
  • packages/nocodb/docker/start-litestream.sh (2 hunks)
Additional Context Used
ShellCheck (1)
packages/nocodb/docker/start-litestream.sh (1)

[warning] 28-28: This } is literal. Check expression (missing ;/\n?) or quote it.

Additional comments not posted (1)
packages/nocodb/docker/start-litestream.sh (1)

14-16: The backward compatibility for S3 environment variables is correctly implemented.

Copy link
Contributor
github-actions bot commented May 23, 2024

Uffizzi Preview deployment-52180 was deleted.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 90008af and 3472c0a.
Files selected for processing (1)
  • packages/nocodb/docker/start-litestream.sh (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/nocodb/docker/start-litestream.sh

8000 Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3472c0a and d8bdb59.
Files ignored due to path filters (1)
  • packages/nocodb/docker/litestream.yml is excluded by !**/*.yml
Files selected for processing (1)
  • packages/nocodb/docker/start-litestream.sh (2 hunks)
Additional Context Used
ShellCheck (6)
packages/nocodb/docker/start-litestream.sh (6)

[info] 22-22: The mentioned syntax error was in this if expression.


[error] 22-22: You need a space after the [ and before the ].


[error] 22-22: Couldn't parse this test expression. Fix to allow more checks.


[error] 22-22: Expected this to be an argument to the unary condition.


[error] 22-22: You need a space before the ].


[error] 22-22: Missing space before ]. Fix any mentioned problems and try again.

Additional comments not posted (3)
packages/nocodb/docker/start-litestream.sh (3)

17-19: Good use of conditional checks to ensure backward compatibility with deprecated environment variables.


21-21: Setting LITESTREAM_S3_FORCE_PATH_STYLE to "false" by default is a sensible default, ensuring compatibility with most S3 configurations.


14-16: Ensure that AWS_BUCKET_PATH is always defined before use.

@pranavxc pranavxc force-pushed the fix/8549-add-support-to-deprecated-envs branch from d8bdb59 to 6b9ffa6 Compare May 23, 2024 12:55
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d8bdb59 and 6b9ffa6.
Files ignored due to path filters (1)
  • packages/nocodb/docker/litestream.yml is excluded by !**/*.yml
Files selected for processing (1)
  • packages/nocodb/docker/start-litestream.sh (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/nocodb/docker/start-litestream.sh

@pranavxc pranavxc force-pushed the fix/8549-add-support-to-deprecated-envs branch 3 times, most recently from 01da820 to 646766d Compare May 23, 2024 16:56
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (4)
packages/nocodb/Dockerfile (4)

Line range hint 10-10: Pin package versions in apk add commands to ensure reproducibility.

- RUN apk add --no-cache git make musl-dev gcc
+ RUN apk add --no-cache git=2.30.2-r0 make=4.3-r0 musl-dev=1.2.2-r3 gcc=10.2.1_pre1-r3

Line range hint 13-15: Consolidate consecutive RUN instructions to reduce layers and improve build efficiency.

- RUN git clone https://github.com/benbjohnson/litestream.git litestream
- RUN cd litestream && go install ./cmd/litestream
- RUN cp $GOPATH/bin/litestream /usr/src/lt
+ RUN git clone https://github.com/benbjohnson/litestream.git litestream && \
+     cd litestream && \
+     go install ./cmd/litestream && \
+     cp $GOPATH/bin/litestream /usr/src/lt

Line range hint 24-24: Pin package versions in apk add commands to ensure reproducibility.

- RUN apk add --no-cache python3 make g++
+ RUN apk add --no-cache python3=3.9.5-r1 make=4.3-r0 g++=10.2.1_pre1-r3

Line range hint 63-63: Pin package versions in apk add commands to ensure reproducibility.

- RUN apk add --update --no-cache dasel dumb-init nodejs
+ RUN apk add --update --no-cache dasel=1.20.0-r0 dumb-init=1.2.5-r0 nodejs=14.17.0-r0
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6b9ffa6 and 01da820.
Files ignored due to path filters (1)
  • packages/nocodb/docker/litestream.yml is excluded by !**/*.yml
Files selected for processing (3)
  • packages/noco-docs/docs/020.getting-started/050.self-hosted/020.environment-variables.md (1 hunks)
  • packages/nocodb/Dockerfile (1 hunks)
  • packages/nocodb/docker/start-litestream.sh (2 hunks)
Additional Context Used
LanguageTool (1)
packages/noco-docs/docs/020.getting-started/050.self-hosted/020.environment-variables.md (1)

Near line 25: Unpaired symbol: ‘'’ seems to be missing
Context: ...ter. Allowed special characters include $&+,:;=?@#\|'.^*()%!_-". | ...

ShellCheck (2)
packages/nocodb/docker/start-litestream.sh (2)

[warning] 14-14: This flag is used as a command name. Bad line break or missing [ .. ]?


[warning] 14-14: Found trailing ] outside test. Add missing [ or quote if intentional.

Hadolint (6)
packages/nocodb/Dockerfile (6)

10: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version>


13: Multiple consecutive RUN instructions. Consider consolidation.


14: Use WORKDIR to switch to a directory


15: Double quote to prevent globbing and word splitting.


24: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version>


63: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version>

Additional comments not posted (1)
packages/nocodb/docker/start-litestream.sh (1)

36-38: Ensure default values are set correctly in the script to avoid unexpected behavior.

Setting default values like this ensures that the system behaves predictably even when environment variables are not explicitly set by the user.

@pranavxc pranavxc force-pushed the fix/8549-add-support-to-deprecated-envs branch 3 times, most recently from fee20da to bebff78 Compare May 23, 2024 17:04
Signed-off-by: Pranav C <pranavxc@gmail.com>
@pranavxc pranavxc force-pushed the fix/8549-add-support-to-deprecated-envs branch from bebff78 to f441403 Compare May 23, 2024 17:38
@pranavxc pranavxc requested a review from mertmit May 23, 2024 19:14
@pranavxc pranavxc removed the 🛑 Status: Do Not Merge Used in PR only. The PR cannot be merged due to some reasons. label May 23, 2024
@pranavxc pranavxc merged commit bc48416 into develop May 23, 2024
23 checks passed
@pranavxc pranavxc deleted the fix/8549-add-support-to-deprecated-envs branch May 23, 2024 20:24
Copy link
Contributor
@salim-b salim-b left a comment

Choose a reason for hiding this comment

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

@pranavxc Some comments about your recent changes (I'm watching the these files via GitHub's atom feeds, so I got notified about your recent changes 😉).

If you'd like, I can prepare a follow-up PR with my suggestions. 🙂

@@ -19,14 +26,16 @@ use_litestream() {
&& [ -z "${DATABASE_URL}" ] \
&& [ -z "${DATABASE_URL_FILE}" ] \
&& [ -z "${NC_MINIMAL_DBS}" ] \
&& [ -n "${LITESTREAM_S3_ENDPOINT}" ] \
Copy link
Contributor

Choose a reason for hiding this comment

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

@pranavxc You should rather check whether either one of LITESTREAM_S3_ENDPOINT or LITESTREAM_S3_REGION is set than just deleting this line...

Copy link
Member Author

Choose a reason for hiding this comment

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

It fallbacks to the default region or endpoint if not set so kept as not mandatory

6D40
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the default region and endpoint? Where are they defined?I didn't spot anything about this in the Litestream doc...

Copy link
Member Author

Choose a reason for hiding this comment

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

Even I couldn’t find that details but it fallbacks to us-east-1 I guess

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, ok. We should then update the env var documentation if we keep it that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn’t added that info since I couldn’t find that info anywhere in their docs

Comment on lines +36 to +37
# set default bucket path if not provided
: "${LITESTREAM_S3_PATH:=nocodb}"
Copy link
Contributor

Choose a reason for hiding this comment

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

To be consistent, I would rather set this in the Dockerfile where the other Litestream-specific defaults are set.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we set it at docker file it's hard to add backward compatibility for env var AWS_BUCKET_PATH

F438 Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. Then I guess we have to leave it like this.

@@ -6,6 +6,7 @@ dbs:
- type: s3
endpoint: ${LITESTREAM_S3_ENDPOINT}
force-path-style: true
region: ${LITESTREAM_S3_REGION}
Copy link
Contributor

Choose a reason for hiding this comment

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

@pranavxc I think setting region does only make sense when not setting endpoint at the same time since endpoint already includes the region, cf. https://litestream.io/reference/config/#s3-replica.

Did you test what happens if LITESTREAM_S3_REGION is unset and LITESTREAM_S3_ENDPOINT is set and vice versa? Does Litestream ignore empty config entries?

Copy link
Member Author
@pranavxc pranavxc May 24, 2024

Choose a reason for hiding this comment

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

I tested and it was fine, will test again to confirm

Copy link
Contributor
@salim-b salim-b May 24, 2024

Choose a reason for hiding this comment

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

Note that I hardcoded force-path-style: true in the Dockerfile start script.

About force-path-style:

Uses the path style which is required by non-AWS services. This is automatically enabled if endpoint is set.

So I guess we'd have to remove force-path-style: true if we wanna support region, no?

(In the end I don't think it's really worth to support region since it only brings a tiny bit of convenience for AWS and Backblaze users but complicates support for other S3-compatible hosters.)

Copy link
Member Author
@pranavxc pranavxc May 24, 2024

Choose a reason for hiding this comment

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

Even with force-path-style: region was working for me. I kept it because setting region is easier than figuring out the endpoint.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even with force-path-style: region was working for me.

Ok, interesting...

I kept it because setting region is easier than figuring out the endpoint.

I see^^

I still think it would be best to adhere to what the official Litestream doc says, hence remove force-path-style: true if we keep region :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya better to remove since it automatically going to set to true when we are configuring custom endpoint

Comment on lines +15 to +18
export LITESTREAM_S3_PATH="${AWS_BUCKET_PATH}"
fi
if [ -z "${LITESTREAM_S3_BUCKET}" ] && [ -n "${AWS_BUCKET}" ] ; then
export LITESTREAM_S3_BUCKET="${AWS_BUCKET}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess, we should also document that AWS_BUCKET_PATH and AWS_BUCKET are deprecated, same as for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree and thanks for pointing out.

@@ -11,6 +11,13 @@ fi
if [ -z "${LITESTREAM_S3_SECRET_ACCESS_KEY}" ] && [ -n "${AWS_SECRET_ACCESS_KEY}" ] ; then
export LITESTREAM_S3_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
fi
if [ -z "${LITESTREAM_S3_PATH}" ] && -n [ "${AWS_BUCKET_PATH}" ] ; then
Copy link
Contributor

Choose a reason for hiding this comment

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

@pranavxc This seems to be invalid syntax, the -n test needs to be inside the brackets.

Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly I will create a follow up PR with your suggested changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you ping me when you submit that follow-up PR? 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

In between something, so once sorted out, I will work on it. I’m happy if you would like to open a PR as well.

Copy link
Contributor
@salim-b salim-b May 24, 2024

Choose a reason for hiding this comment

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

I've just submitted #8572 which should address everything we discussed here (except for testing) :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for creating the PR, soon I will test it and merge.

< 793D !-- Rendered timeline since 2024-05-24 08:35:37 -->
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.

🐛 Bug: Persistence not backing up to S3 on latest version of Noco
3 participants
0