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

Add Postgresql statefulsets with master/slave replication on OpenShift. #4599

Merged

Conversation

patrickdillon
Copy link
Contributor

@patrickdillon patrickdillon commented Apr 18, 2018

This pull requests modifies openshift.json to set up a postgres statefulset with master/slave replication.

This pull request requires that the dataverse glassfish image be rebuilt with the small tweak I committed in default.config (pointing to the master postgres pod). To test, perhaps before rebuilding the image, you can point to my docker image by changing line 113 in openshift.json to "dockerImageRepository": "patrickdillon/dataverse-glassfish"

No changes have been made to run dv on openshift:
oc new-project [name]
oc new-app openshift.json

Once you have started, you can test with the psql client in each container. From the terminal in each postgres container, you can login and check that the tables were created. That should be enough to show changes from master have been replicated:
psql -d dvndb
\dt

You can also make a change, such as changing the name of the dataverse from root to something else and then checking that with select * from dataverse;

I still need to update my Dockerhub image to incorporate the fixes to solr. I will do that soon and update if there are problems.

Related Issues

@coveralls
Copy link

coveralls commented Apr 18, 2018

Coverage Status

Coverage increased (+0.2%) to 13.293% when pulling e7a56c7 on EC528-Dataverse-Scaling:4598-openshift-postgresql into 747b83c on IQSS:develop.

@@ -3,7 +3,7 @@ GLASSFISH_DIRECTORY /usr/local/glassfish4
ADMIN_EMAIL
MAIL_SERVER mail.hmdc.harvard.edu
POSTGRES_ADMIN_PASSWORD secret
POSTGRES_SERVER 127.0.0.1
POSTGRES_SERVER dataverse-postgresql-0.dataverse-postgresql-service
Copy link
Contributor

Choose a reason for hiding this comment

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

This changes the default behavior (and default documentation example) to openshift - this change might be better to make in conf/docker/dataverse-glassfish/default.config.

Copy link
Member

Choose a reason for hiding this comment

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

Right, we don't want to affect the "here" link at "If desired, these default values can be configured by creating a default.config (example here) file in the installer’s working directory" at http://guides.dataverse.org/en/4.8.6/installation/installation-main.html#running-the-dataverse-installer

Good catch @pameyer

@patrickdillon can you please put the "doc" version of the file back to how it was and make the change in conf/docker/dataverse-glassfish/default.config instead? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand. I believe I have fixed this now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@patrickdillon Thanks! Looks fixed to me.

@@ -42,6 +42,7 @@
"selector": {
"name": "iqss-dataverse-postgresql"
},
"clusterIP": "None",
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatting looks off.

Add Postgresql statefulsets with master/slave replication on OpoenShift.

Simple test. Non functional.

Adding missing semicolon.

Glassfish starts but no dataverse.

Glassfish can connect to postgres but does not save in application.

Fixing service problem with postgres stateful set.

going to try to break command over multiple lines.

WIP extending image with S2I

Replication is working. Just needs to be cleaned up.

Cleaned up.

Removing print tests.

Resetting install to upstream.

Resetting build.sh to upstream.

Fixing image pull policy.

Fixing default config.

Fixing formatting issues.

More formatting.
@patrickdillon patrickdillon force-pushed the 4598-openshift-postgresql branch from 0b76e1d to 51cecfc Compare April 23, 2018 13:26
"metadata": {
"name": "dataverse-postgresql",
"annotations": {
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
"serviceName" : "dataverse-postgresql-service",
"replicas" : 1,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danmcp raised the question of whether running a setup with only a master and no slaves would have any side effects. I think there would be no side effects and it would be similar to just running a single instance Postgres setup.

Our code is based off this example, which states:

Once the master is started, it works as a standalone database server, fully independent of the slaves.

I dug in a little more to the image to see what is happening:
For the postgres image, the only side effect for running as master is that these configuration settings are copied into the main postgres config file: https://github.com/sclorg/postgresql-container/blob/master/src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template

To me, the above settings look innocuous.

For further context, here is the master-binary: https://github.com/sclorg/postgresql-container/blob/master/src/root/usr/bin/run-postgresql-master

And that environment variable is called in this common script, which just copies the first file above into the main config settings: https://github.com/sclorg/postgresql-container/blob/b737ad26db4f8769e775ca165284f62c7f2a66db/src/root/usr/share/container-scripts/postgresql/common.sh

Copy link
Member

Choose a reason for hiding this comment

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

@patrickdillon thanks, I just moved this to QA.

Copy link
Member

@pdurbin pdurbin 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.

@@ -241,7 +248,10 @@
"containers": [
{
"name": "centos-postgresql-94-centos7",
"image": "centos-postgresql-94-centos7",
"image": "centos/postgresql-94-centos7",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By using centos/postgresql-94-centos7 instead of centos-postgresql-94-centos7 we are pointing directly to the Docker Hub repo rather than the ImageStream. The reason I changed this was because it started throwing an error after changing from a DeploymentConfig to a StatefulSet v1beta1. I just tried testing again with the image stream and it still is getting the error. Once OpenShift is updated to a newer version we can try changing it back or if there are any suggestions let me know.

"kind": "DeploymentConfig",
"apiVersion": "v1",
"kind": "StatefulSet",
"apiVersion": "apps/v1beta1",
Copy link
Member

Choose a reason for hiding this comment

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

Does v1beta1 require a beta version of minishift? Or can I just use the most recent regular release of minishift?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regular release is fine. I was running on v1.14

Copy link
Member

Choose a reason for hiding this comment

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

Ok, great. Thanks.

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.

5 participants