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

Crash when MinIO bucket does not have versioning enabled #545 #546

Conversation

fflorent
Copy link
Collaborator

@fflorent fflorent commented Jun 26, 2023

Fixes #545

Notes for the reviewers:

  • I assumed the ICreate#configure() method is to proceed to some checks before installing the document-related endpoint, based on this comment, is it OK for you?
  • As an exception in the configure method would not stop the server, I rather called process.exit(). However I feel like just throwing an exception (and thus disallowing using the /docs endpoint) can be also reasonable.
  • It may also need some tests. I will write them when the main idea of the implementation is stable (especially when my questions above and this comment are answered :) ).

Thanks in advance for your help 🙏

@fflorent fflorent marked this pull request as draft June 26, 2023 13:03
@fflorent fflorent force-pushed the issue-545-disallow-bucket-no-versioning branch from a5998bb to 91f72a3 Compare June 26, 2023 13:06
@paulfitz
Copy link
Member

* I assumed the `ICreate#configure()` method is to proceed to some checks before installing the document-related endpoint, [based on this comment](https://github.com/incubateur-territoires/grist-core/blob/a5998bbcfdc56b1203c576da7a287e24b0223733/app/server/lib/ICreate.ts#L33), is it OK for you?

That's a fine interpretation.

* As an exception in the configure method would not stop the server, I rather called `process.exit()`. However I feel like just throwing an exception (and thus disallowing using the `/docs` endpoint) can be also reasonable.

I'm surprised that throwing an exception in configure wouldn't propagate to mergedServerMain.main and so prevent any server that includes docs endpoints from starting. I would prefer an exception if possible.

* It may also need some tests. I will write them when the main idea of the implementation is stable (especially when my questions above and [this comment](https://github.com/gristlabs/grist-core/pull/546/files#r1242264301) are answered :) ).

Main idea seems grand :-) - thanks for working on this!

@fflorent fflorent marked this pull request as ready for review June 28, 2023 08:19
@fflorent
Copy link
Collaborator Author

I'm surprised that throwing an exception in configure wouldn't propagate to mergedServerMain.main and so prevent any server that includes docs endpoints from starting. I would prefer an exception if possible.

I made a change here where the main server is called:
76df23c

Whether I start using yarn start or yarn start:prod, it seems that the stubs/app/server/server.ts file is executed

@paulfitz
Copy link
Member

Ah, sounds like node is waiting for something to finish up. Maybe mergedServerMain.main needs a catch clause that calls server.close() to shut down anything that is already started, if there is an exception.

@fflorent
Copy link
Collaborator Author

Ah, sounds like node is waiting for something to finish up. Maybe mergedServerMain.main needs a catch clause that calls server.close() to shut down anything that is already started, if there is an exception.

I attempted the below patch, with no luck, the process does not exit despite the server being closed:
incubateur-territoires@f46bbe4

@paulfitz
Copy link
Member

Ah, sounds like node is waiting for something to finish up. Maybe mergedServerMain.main needs a catch clause that calls server.close() to shut down anything that is already started, if there is an exception.

I attempted the below patch, with no luck, the process does not exit despite the server being closed: incubateur-territoires@f46bbe4

Hmm, if I throw an exception just before the call to configure(), when using your branch, behavior with yarn run start:prod looks as expected (exception thrown, process stops). Haven't tried with MinIO actually set up though...

@fflorent
Copy link
Collaborator Author

You're right, that works in production mode and that seems reasonable like this. I cherry-picked the commit and removed the await server.stopListening('crash'); instruction as close() makes the app crash.

Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

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

Looks good, thank you! A minio server is set up in .github/workflows/main.yml and some tests are run against it, so a test could be added for this fail-fast feature. But it feels like it could be a bit cumbersome, and the consequences of failure seem very minor, I'm ok accepting this without automated tests.

@paulfitz
Copy link
Member

@fflorent let me know if you'd like this landed as is, or if you have ambitions to write a test for it (your call, not essential in this case in my opinion).

@fflorent
Copy link
Collaborator Author

fflorent commented Jul 5, 2023

OK then, I am OK merging without tests.

@paulfitz paulfitz merged commit b6b2d05 into gristlabs:main Jul 10, 2023
@vviers vviers added the anct label Jul 11, 2023
@fflorent fflorent deleted the issue-545-disallow-bucket-no-versioning branch July 11, 2023 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

S3: Detect bucket versioning
3 participants