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 support for not (re)starting server after cloud-setup-management. #1162

Merged
merged 1 commit into from
Dec 7, 2015
Merged

Add support for not (re)starting server after cloud-setup-management. #1162

merged 1 commit into from
Dec 7, 2015

Conversation

ProjectMoon
Copy link

This adds an option to the cloud-setup-management script to not start the management server after a successful configuration of it.

The primary motivation for this is to avoid circular dependency issues on systems that use systemd. When calling cloud-setup-management from a unit with a Before= directive on a service depending on
cloudstack-management, the process will deadlock because /usr/bin/service will delegate to systemd, which is waiting for the Before service to start.

Executing the cloud-setup-management script with this new --no-start option will simply leave the management server stopped after a successful configuration. systemd can then be bypassed with export _SYSTEMCTL_SKIP_REDIRECT=1 and using the init.d script.

@@ -24,20 +24,23 @@ from cloudutils.globalEnv import globalEnv
from cloudutils.serviceConfigServer import cloudManagementConfig
from optparse import OptionParser
if __name__ == '__main__':
initLoging("@MSLOGDIR@/setupManagement.log")
initLoging("/var/log/cloudstack/management/setupManagement.log")
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this hardcoded value fly on windows? (yes it is used as ms platform by some)

Copy link
Author

Choose a reason for hiding this comment

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

Ah yes this was an unintended change. I will put it back to the original @MSLOGDIR@ tomorrow.

This adds an option to the cloud-setup-management script to not start
the management server after a successful configuration of it. The
primary motivation for this is to avoid circular dependency issues on
systems that use systemd. When calling cloud-setup-management from a
unit with a Before= directive on a service depending on
cloudstack-management, the process will deadlock because
/usr/bin/service will delegate to systemd, which is waiting for the
Before service to start.
@ProjectMoon
Copy link
Author

Removed the unintentional change to the initLoging (sic) method.

if self.syscfg.svo.enableService("cloudstack-management"):
return True
else:
raise CloudRuntimeException("Failed to configure %s, please see the /var/log/cloudstack/management/setupManagement.log for detail"%self.serviceName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry to be a nag @ProjectMoon but can you change the path in the log message as well?

Copy link
Author

Choose a reason for hiding this comment

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

I will change it, but it should be known that this was actually the original message. :) Does need to be fixed though.

Copy link
Author

Choose a reason for hiding this comment

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

So, one possible issue with this: will the serviceConfigServer.py script be processed by the *.in ant tasks, or will a new antrun task need to be added to process the files found at python/lib/cloudutils?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah you are right, and am I glad I forgot to add a 👎 ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

We crossed each other here, what do you mean?

Copy link
Author

Choose a reason for hiding this comment

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

The original message had the log message in the wrong place (I think it was pointing at /var/log/cloudstack-management/setupManagement.log). I changed it to the right path on Linux systems (for Ubuntu and friends). But probably the log path can be fixed as part of this commit or in another one. But in order for the replace.properties stuff to work, there is an antrun task I believe. Not sure it would currently process files in the directory that serviceConfigServer.py is in.

@DaanHoogland
Copy link
Contributor

lgtm
@remibergsma can you schedule a regression?

@remibergsma
Copy link
Contributor

@DaanHoogland That makes no sense. We should build RPMs and install mgt server from it and test both the new and existing features. The integration tests do not hit this code as far as I know.

@remibergsma
Copy link
Contributor

LGTM:

Old default behaviour is to enable service:

[root@cs1 x86_64]# cloudstack-setup-management --tomcat7 
Starting to configure CloudStack Management Server:
Configure Firewall ...        [OK]
Configure CloudStack Management Server ...[OK]
CloudStack Management Server setup is Done!
[root@cs1 x86_64]# ls -la /etc/systemd/system/multi-user.target.wants/cloudstack-management.service
lrwxrwxrwx. 1 root root 53 Dec  7 20:03 /etc/systemd/system/multi-user.target.wants/cloudstack-management.service -> /usr/lib/systemd/system/cloudstack-management.service

And with extra option it is not enabled:

[root@cs1 x86_64]# systemctl disable cloudstack-management
rm '/etc/systemd/system/multi-user.target.wants/cloudstack-management.service'
[root@cs1 x86_64]# ls -la /etc/systemd/system/multi-user.target.wants/cloudstack-management.service
ls: cannot access /etc/systemd/system/multi-user.target.wants/cloudstack-management.service: No such file or directory
[root@cs1 x86_64]# cloudstack-setup-management --tomcat7 --no-start
Starting to configure CloudStack Management Server:
Configure Firewall ...        [OK]
Configure CloudStack Management Server ...Configured successfully, but not starting management server.
[OK]
CloudStack Management Server setup is Done!
[root@cs1 x86_64]# ls -la /etc/systemd/system/multi-user.target.wants/cloudstack-management.service
ls: cannot access /etc/systemd/system/multi-user.target.wants/cloudstack-management.service: No such file or directory

@asfgit asfgit merged commit e0e65f5 into apache:4.6 Dec 7, 2015
asfgit pushed a commit that referenced this pull request Dec 7, 2015
Add support for not (re)starting server after cloud-setup-management.This adds an option to the cloud-setup-management script to not start the management server after a successful configuration of it.

The primary motivation for this is to avoid circular dependency issues on systems that use systemd. When calling cloud-setup-management from a unit with a Before= directive on a service depending on
cloudstack-management, the process will deadlock because /usr/bin/service will delegate to systemd, which is waiting for the Before service to start.

Executing the cloud-setup-management script with this new `--no-start` option will simply leave the management server stopped after a successful configuration. systemd can then be bypassed with `export _SYSTEMCTL_SKIP_REDIRECT=1` and using the init.d script.

* pr/1162:
  Add support for not (re)starting server after cloud-setup-management.

Signed-off-by: Remi Bergsma <github@remi.nl>
@ProjectMoon ProjectMoon deleted the pr-no-start branch December 8, 2015 11:23
asfgit pushed a commit that referenced this pull request Dec 7, 2016
[CLOUDSTACK-9645] Followup fix for #1162: Add support for not (re)starting server after cloud-setup-management.New version against #1330, opened against master.

```
Moving stop of management in config inside if statement.

It will only run the stop command when --no-start is specified.
```

* pr/1566:
  CLOUDSTACK-9645: Moving stop of management in config inside if statement.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
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.

4 participants