Conversation
|
@rvalle @rhtyd what do you think? |
|
@DaanHoogland here are my observations:
I was thinking on creating a complementary dependency (in /etc/systemd...) from the cloudstack-setup-databases. We could create it once the admin requests a configuration with mysql at localhost. then we know that mysql or mariadb run on the same system Then we could add a switch for cloudstack-setup-databases that disables or forces this configuration. |
|
@DaanHoogland I have an important delivery at work at the end of month, but after that I can help you implement this. |
|
@rvalle in the case of
If I interpret the docs correctly we can add the mysql.target with no harm. if either is present they will be started. The user must make sure not both are present though, to avoid conflict. I can see how you envision a more elegant solution, but I would opt for next release for that, minimising code change during freeze and hastening release. If this can be tested and shown to work.... I would prefer to be working on the next release by the end of the month ;) |
|
@DaanHoogland, no no, I think your solution is better. No need to modify the script. I will try to test your proposal. Stopping mysql/mariadb should stop the CS Management too. And how do we do with the mysql/mariadb thing? the service units have different names, right? Or is it recommended to go with mariadb in general? |
|
@DaanHoogland also, is it .target or .service? I understand .target as a group of units, but is mariadb a target? |
|
@rvalle I have not looked into the diff between target and service yet, missed that one. Need to look. Actually i may have completely goofed there. it probably should be db.target and then it should be filled accordingly. My systemd is not fluent obviously. |
|
@DaanHoogland I will try to test tonight. might also switch to mariadb or test if the solution works with both databases. |
|
@rvalle my use of target is due to an overzealous c&p action. I think it should be .service in both cases unless we decide to make it more versatile by having a db.target that can deal with either and will handle the case of both gracefully. I'll update the PR to read service. |
|
did you have a chance to test @rvalle ? |
|
I edited the cloudstack-management.service file: and ran
In this case, mysqld started before cloudstack-management, but after executing:
to see what happens when mysqld is stopped, cloudstack-management didn't stop and started throwing errors. By chaning the cloudstack-management.service file to: and executing
cloudstack was stopped first before mysql was stopped. By my testing, using "Wants", instead of "Requires", mysqld will start before cloudstack-management, but will not shut down cloudstack-management before mysqld. I will take a look at a solution |
|
@Spaceman1984 did you remember the daemon-reload after the changes? |
|
@DaanHoogland I will test this weekend |
|
@DaanHoogland I managed to get some testing now... This seems to imply that Wants/Requires do have semantic differences other than the ones we have discussed before... I am back to the Systemd documentation... see if I can find the details. |
|
This is the best I can find from Redhat 7 Requires : Configures dependencies on other units. The units listed in Requires are activated together with the unit. If any of the required units fail to start, the unit is not activated. Wants: Configures weaker dependencies than Requires. If any of the listed units does not start successfully, it has no impact on the unit activation. This is the recommended way to establish custom unit dependencies. Looks like Wants would also start CSM if mysql is present but fails to start. I am thinking that manually stopping the service could also be interpreted as failure (?). I am not sure, but Requires is a much safer relationship for our use case. |
|
I have continued testing a bit more. However, I can attempt to start CSM with mysql stopped and it will not start it automatically either. I wonder what would happen in a situation in which CSM takes some time to stop, like just after the install. I am going to try to run my to run the following test:
|
|
@rvalle what if mariadb/mysql server run on another server ? |
|
ok I did run the install test with restart after install. So, this is the status: Wants seems sufficient for startup, shutdown and reboot. While still works if no mysql is installed. as @weizhouapache is pointing. Requires is stronger and will deal with things like shutting down CSM automatically if you happen to stop mysql (perhaps during a mysql update). Will also start mysql automatically at CSM startup even if is stopped, or will not start CSM if mysql is misconfigured. However it does require mysql to be present in the system. And you need to know if it is mysql or mariadb. What we can do from here? I think we should include Wants in the distribution file, because it causes no harm, and serves as a safeward. It will work and provide protection for most of the use cases. We still have the option to modify the service unit from /etc/systemd as discussed in #3954 adding a Requires once we know that the mysql/mariadb runs on localhost for sure. This could be dome from the script cloudstack-setup-databases. Another posibilty is simply to include an additional comment with instructions in the at the distrubuted Systemd. This comment could be extended to other depndencies, something like this in the provided Systemd script: |
|
Code LGTM |
|
@blueorangutan package |
|
@Spaceman1984 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-1076 |
|
Tested with mysqld, the config behaves as expected. @rvalle I tried to corrupt the db, but I was only able to do it while the upgrade scripts were running. Do you do the restart while the upgrade script is executing or after? I executed: I watch the log until the SQL queries stop being logged then I restart. At this point cloudstack seems to fire up properly, I didn't see any errors in the log. But If I restart while the SQL scripts are being logged Cloudstack won't start up and I have to run the db setup script again to initialize the db. |
|
@Spaceman1984 I could read your comment as a LGTM or as a request for changes, please pass a verdict!?! |
|
@Spaceman1984 my use case is just to deploy CSM with ansible and reboot the system at the end, as part of some testing. My test was trying to prove that after a reboot the server was in the exact same state as after the ansible playbooks run. The goal is trying to prove that after a reboot everything works as expect. But then I noticed that all those tests would corrupt the database, so I started digging into this. But Still think that this PR is best for all cases. Someone installing CSM is going to tune many other things too. |
|
LGTM @DaanHoogland |
|
@DaanHoogland you'll need to please add "mysqld" as the dependency as well (mysql happens to be an alias for mysqld 5.6 on CentOS7- what @Spaceman1984 tested) - as "mysqld" is the unit name for mysql 5.7 and there is no such alias Tested by adding "mysql.service" alias: LGTM (after adding "mysqld") |
|
I can add mysqld but it makes more sense to me replacing mysql with mysqld, after reading your comment. If mysql is an alias for mysqld these are not both needed. |
|
on Ubuntu its mysql so I prefer to have both (all 3 that is) |
|
@blueorangutan package |
|
@Spaceman1984 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-1085 |
|
@blueorangutan test matrix |
|
@andrijapanicsb a Trillian-Jenkins matrix job (centos7 mgmt + xs71, centos7 mgmt + vmware67, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests |
|
Trillian test result (tid-1296)
|
|
Trillian test result (tid-1297)
|
|
Trillian test result (tid-1298)
|
* 4.13: systemd dependency on db (#3973)
Description
Fixes: #3954
Types of changes
Screenshots (if appropriate):
How Has This Been Tested?