-
Notifications
You must be signed in to change notification settings - Fork 490
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
Fixes dead Dataverse after server restart #10915
Conversation
@pdurbin Can you take a look? The problem prevented our server from restarting. I tested with this commit on my local system and it fixed the problem. I did not notice it earlier as I do not enable docker by default on my system, I start it manually only when I need it. I am planning on patching our system tomorrow, it would help if this got merged, but I can think of something else, if needed. Thanks! |
@ErykKul interesting. Thanks for the PR. Let's see what @poikilotherm thinks. Also I put it on our agenda for tomorrow: https://docs.google.com/document/d/1KIvrM5prIJyJKij4nwxNw5genQolmqSG5GDWbIH7d7U/edit?usp=sharing |
I have patched our build script: libis/rdm-build@b5e8b74 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for this PR @ErykKul .
I cannot approve the changes you are suggesting, as they pose a security risk by allowing an undefined state. In case I misunderstood your use case with what I write below: could you elaborate more on it and the context? Thanks!
At build time, the password for the users is set to the default values and these are also exposed as environment variables. At container-start time, the passwords are changed when they are not still set to the default values. The env vars are scrambled after usage for setting the password, so they don't end up in the running container.
If you set the environment variables to an empty string, you are more or less trying to set the password to an empty string. This is usually rejected by the tools, as it is a clear security violation. This works as expected, as you mentioned that the server startup crashed in this case.
Setting any of these passwords must happen at container-start time, as the changed passwords are not kept around. The next time the container is started from the image, the changes will be gone. So allowing this || true
here means the password will still be set to the default. But why add the environment variables with the secret password set to ""
then in the first place?
In case you set a custom password at build time by changing the env vars (which IMO is a bad idea, as anyone getting ahold of the image can extract the passwords - don't ship secrets as part of an image), this is indeed a problem. But we should have a better solution than just allowing the password commands to fail. In case you use a derived image and execute commands to change the passwords, the env vars will still be set to their defaults and no change commands will be executed at container-start time.
No problem, Closing. |
FWIW, with the test described in the issue: Password was still the custom one after server restart, as set initially (I tested with asadmin command). |
@ErykKul I tried to reproduce the problem, but wasn't able to. Can you please give me a list of your steps to follow? Thanks! |
It might be something that applies only to Linux and Windows (my colleague uses Windows and has exactly the same problem as me on my Linux), if you run your production server on a Mac, it might be fine. I do not have a Mac to test it on. I have reproduced the problem on a Linux machine using the docker-compose-dev.yaml. In the yaml add these to the environment variables of your dataverse container:
Now, make sure no docker containers are running (just to reduce the number of variables for the test). Make sure docker is enabled at the startup:
Go to the development branch and start docker in background:
Wait until everything is up, http://localhost:8080 shows a dataverse page. Check if setting password worked. First, check what the container name is for the dev_dataverse:
In my case it is
Run this command:
It will ask you to provide the credentials, use admin/notDefaultPassword
Now test the patch. First, check out this branch:
Kill all the containers, etc. Now, build an image containing the updated script from this branch:
Make sure that when you run: Restart your Linux again. Verify that dataverse is up and running and try the I verified this patch using our own build script and I did run the tests as above on my own machine, as well as on the pilot and production servers with this patch installed. I use Arch btw |
I finally managed to build the image containing the updated scripts and run it using the docker-compose-dev.yaml. I run against countless other problems... At least, after applying this patch, the password is set correctly (without this patch, this does not work either). Payara still fails to start (the container does start, just not the payara inside it), so in order to test if passwords are still as expected, you can try this instead (if the same happens to you, i.e., if you can reproduce it) -> run
It will prompt you for password, it should be |
I see I still messed things up a little bit, the command to start the docker compose properly is not:
but
Otherwise finding stats will not work and you cannot see the container name and id running this command (you need the name of the container in order to know to which shell to connect to run the
I will restart my PC again and see if the docker daemon ( |
TLDR; this PR fixes dead Dataverse after system restart when using NOT default passwords (it does not fix docker-compose-dev.yaml, mvn scripts, etc. problems). |
OMG! @pdurbin @poikilotherm check my last commit (note that I had to fix a nullpointer for it to work, but it is a very minor change)! It looks amazing! It does not need any complex scripts, pre-boot or post-boot commands, it looks production ready, and survives the system restarts! How cool is that! Try it out with |
This comment has been minimized.
This comment has been minimized.
We could also do something similar for the dev version; it looks like mounting |
This comment has been minimized.
This comment has been minimized.
It looks like the ADMIN_PASSWORD is a setup once thing:
It needs to be set only once for production, from what I understand? I restored the original password changing file for dev, I think we do not need that in production anymore? I also removed the |
📦 Pushed preview images as
🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name. |
@ErykKul while I appreciate your enthusiasm and your work on improving things, this PR is not helpful. From a rather narrow scoped PR, trying to solve one thing you moved to "burn it all" 🔥 🔥 . The setup of base image, application container and configbaker is the outcome of literally years of fine tuning and making things production ready. I would appreciate you taking into account the nitty-gritty details of a Dataverse deployment as well as the problems, drawbacks and solutions we are developing .Elaborating on all of them is way to much to put in a GitHub comment. Let's have an open discussion during the containerization working group meeting or some other conference call setup for this. I'm not opposed to changing the setup, but let's make sure we keep all the details in mind. In the mean time, I have been able to reproduce the problem. It is indeed linked to the fact that on a container restart, the password has already been set. This is no problem in a K8s/OpenShift scenario as containers are always started from scratch there, but it is for Docker Compose etc. If you start the stack using I will go ahead and implement a solution to eliminate the problem. |
Cool, thanks! It was not my intention to burn anything. As I see it, the difference is just one line of code, changing this:
to something like this:
could have the best of both worlds: ease of use and patching (you can even have a forked Dataverse, build a war, and use it in the optimized for Dataverse image) and having the best possible image tweaked for production, with all the details and finesse of the Dataverse deployment. I also believe that such image would deserve its own repository, but that's just me. Nevertheless, my ideas here might still be not helpful and irrelevant. You can close it if you do not see anything useful here. |
@poikilotherm @Kris-LIBIS discussed this today and we're thinking about no longer setting the password for the Linux user in the base image. See notes at https://docs.google.com/document/d/1AN6aAX5rt4lS5fEGYY1Q7Feug2GkIoLve-8WSOppVpA/edit?usp=sharing Also, we clarified that this password behavior is new as of 6.4, added in this PR: |
I have worked out a demo using the docker-compose similar to this one in the libis/rdm-integration. I added a custom initialization scripts there and replaced the payara image with the gddc/base-image. The base-image does fix the nullpointer. Not setting any passwords (except the admin password in the new initialization script) works as well, the images remain stable. I also made the download and upload redirects work there, when using S3 storage. I am happy with that setup, so I am closing this issue. |
@ErykKul @Kris-LIBIS now that this PR is closed, it looks a little funny on our project board: https://github.com/orgs/IQSS/projects/34 Would one of you be willing to create an issue that describes the problem? It can be a super short issue. It's well understood. 😄 |
Hi. I have created this issue: #10998, and added it to the project board. I removed this PR from the project. |
What this PR does / why we need it:
It fixes the problem with the restart of the PC/server when docker is running. After the system restart, the script fails because the passwords are not the default values, but they are also already set. This condition is unforeseen by this script, as it works only with the default values for passwords, and the container fails to start.
Which issue(s) this PR closes:
Special notes for your reviewer:
Suggestions on how to test this:
Set password in docker-compose to not default values and restart the system. Dataverse fails to restart after system restart. After applying this commit, it works again.
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No
Is there a release notes update needed for this change?:
No
Additional documentation:
No