Skip to content

Commit f68cafb

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Remove sysvinit/upstart support"
2 parents 35ee088 + 991e0da commit f68cafb

File tree

25 files changed

+210
-1102
lines changed

25 files changed

+210
-1102
lines changed

elements/amphora-agent/install.d/amphora-agent-source-install/75-amphora-agent-install

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,10 @@ mkdir -p /var/lib/octavia
4141
install -D -g root -o root -m 0644 ${SCRIPTDIR}/amphora-agent.logrotate /etc/logrotate.d/amphora-agent
4242

4343
case "$DIB_INIT_SYSTEM" in
44-
upstart)
45-
install -D -g root -o root -m 0644 ${SCRIPTDIR}/amphora-agent.conf /etc/init/amphora-agent.conf
46-
install -D -g root -o root -m 0644 ${SCRIPTDIR}/prometheus-proxy.conf /etc/init/prometheus-proxy.conf
47-
;;
4844
systemd)
4945
install -D -g root -o root -m 0644 ${SCRIPTDIR}/amphora-agent.service /usr/lib/systemd/system/amphora-agent.service
5046
install -D -g root -o root -m 0644 ${SCRIPTDIR}/prometheus-proxy.service /usr/lib/systemd/system/prometheus-proxy.service
5147
;;
52-
sysv)
53-
install -D -g root -o root -m 0644 ${SCRIPTDIR}/amphora-agent.init /etc/init.d/amphora-agent.init
54-
install -D -g root -o root -m 0644 ${SCRIPTDIR}/prometheus-proxy.init /etc/init.d/prometheus-proxy.init
55-
;;
5648
*)
5749
echo "Unsupported init system"
5850
exit 1

elements/certs-ramfs/init-scripts/sysv/certs-ramfs

Lines changed: 0 additions & 39 deletions
This file was deleted.

elements/certs-ramfs/init-scripts/upstart/certs-ramfs.conf

Lines changed: 0 additions & 14 deletions
This file was deleted.

elements/certs-ramfs/post-install.d/30-enable-certs-ramfs-service

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ set -eu
77
set -o pipefail
88

99
case "$DIB_INIT_SYSTEM" in
10-
upstart|sysv)
11-
# nothing to do
12-
exit 0
13-
;;
1410
systemd)
1511
systemctl enable certs-ramfs.service
1612
;;

octavia/amphorae/backends/agent/agent_jinja_cfg.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ def build_agent_config(self, amphora_id, topology):
5252
'haproxy_cmd': CONF.haproxy_amphora.haproxy_cmd,
5353
'heartbeat_interval': CONF.health_manager.heartbeat_interval,
5454
'heartbeat_key': CONF.health_manager.heartbeat_key,
55-
'respawn_count': CONF.haproxy_amphora.respawn_count,
56-
'respawn_interval': CONF.haproxy_amphora.respawn_interval,
5755
'amphora_udp_driver': CONF.amphora_agent.amphora_udp_driver,
5856
'agent_tls_protocol': CONF.amphora_agent.agent_tls_protocol,
5957
'topology': topology,

octavia/amphorae/backends/agent/api_server/keepalived.py

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
j2_env = jinja2.Environment(autoescape=True, loader=jinja2.FileSystemLoader(
3636
os.path.dirname(os.path.realpath(__file__)) + consts.AGENT_API_TEMPLATES))
37-
UPSTART_TEMPLATE = j2_env.get_template(consts.KEEPALIVED_JINJA2_UPSTART)
38-
SYSVINIT_TEMPLATE = j2_env.get_template(consts.KEEPALIVED_JINJA2_SYSVINIT)
3937
SYSTEMD_TEMPLATE = j2_env.get_template(consts.KEEPALIVED_JINJA2_SYSTEMD)
4038
check_script_template = j2_env.get_template(consts.CHECK_SCRIPT_CONF)
4139

@@ -60,34 +58,17 @@ def upload_keepalived_config(self):
6058
f.write(b)
6159
b = stream.read(BUFFER)
6260

63-
init_system = util.get_os_init_system()
64-
65-
file_path = util.keepalived_init_path(init_system)
66-
67-
init_enable_cmd = None
68-
if init_system == consts.INIT_SYSTEMD:
69-
template = SYSTEMD_TEMPLATE
70-
init_enable_cmd = "systemctl enable octavia-keepalived"
71-
72-
# Render and install the network namespace systemd service
73-
util.install_netns_systemd_service()
74-
util.run_systemctl_command(
75-
consts.ENABLE, consts.AMP_NETNS_SVC_PREFIX)
76-
elif init_system == consts.INIT_UPSTART:
77-
template = UPSTART_TEMPLATE
78-
elif init_system == consts.INIT_SYSVINIT:
79-
template = SYSVINIT_TEMPLATE
80-
init_enable_cmd = f"insserv {file_path}"
81-
else:
82-
raise util.UnknownInitError()
83-
84-
if init_system == consts.INIT_SYSTEMD:
85-
# mode 00644
86-
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
87-
else:
88-
# mode 00755
89-
mode = (stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP |
90-
stat.S_IROTH | stat.S_IXOTH)
61+
file_path = util.keepalived_init_path()
62+
63+
template = SYSTEMD_TEMPLATE
64+
65+
# Render and install the network namespace systemd service
66+
util.install_netns_systemd_service()
67+
util.run_systemctl_command(
68+
consts.ENABLE, consts.AMP_NETNS_SVC_PREFIX, False)
69+
70+
# mode 00644
71+
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
9172
if not os.path.exists(file_path):
9273
with os.fdopen(os.open(file_path, flags, mode), 'w') as text_file:
9374
text = template.render(
@@ -118,17 +99,13 @@ def upload_keepalived_config(self):
11899
util.vrrp_check_script_update(None, consts.AMP_ACTION_START)
119100

120101
# Make sure the new service is enabled on boot
121-
if init_enable_cmd is not None:
122-
try:
123-
subprocess.check_output(init_enable_cmd.split(),
124-
stderr=subprocess.STDOUT,
125-
encoding='utf-8')
126-
except subprocess.CalledProcessError as e:
127-
LOG.debug('Failed to enable octavia-keepalived service: '
128-
'%(err)s %(output)s', {'err': e, 'output': e.output})
129-
return webob.Response(json={
130-
'message': "Error enabling octavia-keepalived service",
131-
'details': e.output}, status=500)
102+
try:
103+
util.run_systemctl_command(consts.ENABLE,
104+
consts.KEEPALIVED_SYSTEMD)
105+
except subprocess.CalledProcessError as e:
106+
return webob.Response(json={
107+
'message': "Error enabling octavia-keepalived service",
108+
'details': e.output}, status=500)
132109

133110
res = webob.Response(json={'message': 'OK'}, status=200)
134111
res.headers['ETag'] = stream.get_md5()
@@ -158,14 +135,10 @@ def manager_keepalived_service(self, action):
158135
except OSError:
159136
pass
160137

161-
cmd = f"/usr/sbin/service octavia-keepalived {action}"
162-
163138
try:
164-
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT,
165-
encoding='utf-8')
139+
util.run_systemctl_command(action,
140+
consts.KEEPALIVED_SYSTEMD)
166141
except subprocess.CalledProcessError as e:
167-
LOG.debug('Failed to %s octavia-keepalived service: %s %s',
168-
action, e, e.output)
169142
return webob.Response(json={
170143
'message': f"Failed to {action} octavia-keepalived service",
171144
'details': e.output}, status=500)

octavia/amphorae/backends/agent/api_server/keepalivedlvs.py

Lines changed: 34 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838

3939
j2_env = jinja2.Environment(autoescape=True, loader=jinja2.FileSystemLoader(
4040
os.path.dirname(os.path.realpath(__file__)) + consts.AGENT_API_TEMPLATES))
41-
UPSTART_TEMPLATE = j2_env.get_template(consts.KEEPALIVED_JINJA2_UPSTART)
42-
SYSVINIT_TEMPLATE = j2_env.get_template(consts.KEEPALIVED_JINJA2_SYSVINIT)
4341
SYSTEMD_TEMPLATE = j2_env.get_template(consts.KEEPALIVED_JINJA2_SYSTEMD)
4442
check_script_file_template = j2_env.get_template(
4543
consts.KEEPALIVED_CHECK_SCRIPT)
@@ -92,32 +90,18 @@ def upload_lvs_listener_config(self, listener_id):
9290
f.write(b)
9391
b = stream.read(BUFFER)
9492

95-
init_system = util.get_os_init_system()
93+
file_path = util.keepalived_lvs_init_path(listener_id)
9694

97-
file_path = util.keepalived_lvs_init_path(init_system, listener_id)
95+
template = SYSTEMD_TEMPLATE
9896

99-
if init_system == consts.INIT_SYSTEMD:
100-
template = SYSTEMD_TEMPLATE
101-
102-
# Render and install the network namespace systemd service
103-
util.install_netns_systemd_service()
104-
util.run_systemctl_command(
105-
consts.ENABLE, consts.AMP_NETNS_SVC_PREFIX)
106-
elif init_system == consts.INIT_UPSTART:
107-
template = UPSTART_TEMPLATE
108-
elif init_system == consts.INIT_SYSVINIT:
109-
template = SYSVINIT_TEMPLATE
110-
else:
111-
raise util.UnknownInitError()
97+
# Render and install the network namespace systemd service
98+
util.install_netns_systemd_service()
99+
util.run_systemctl_command(
100+
consts.ENABLE, consts.AMP_NETNS_SVC_PREFIX, False)
112101

113102
# Render and install the keepalivedlvs init script
114-
if init_system == consts.INIT_SYSTEMD:
115-
# mode 00644
116-
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
117-
else:
118-
# mode 00755
119-
mode = (stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP |
120-
stat.S_IROTH | stat.S_IXOTH)
103+
# mode 00644
104+
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
121105
keepalived_pid, vrrp_pid, check_pid = util.keepalived_lvs_pids_path(
122106
listener_id)
123107
if not os.path.exists(file_path):
@@ -136,23 +120,15 @@ def upload_lvs_listener_config(self, listener_id):
136120
text_file.write(text)
137121

138122
# Make sure the keepalivedlvs service is enabled on boot
139-
if init_system == consts.INIT_SYSTEMD:
123+
try:
140124
util.run_systemctl_command(
141-
consts.ENABLE, f"octavia-keepalivedlvs-{str(listener_id)}")
142-
elif init_system == consts.INIT_SYSVINIT:
143-
init_enable_cmd = f"insserv {file_path}"
144-
try:
145-
subprocess.check_output(init_enable_cmd.split(),
146-
stderr=subprocess.STDOUT,
147-
encoding='utf-8')
148-
except subprocess.CalledProcessError as e:
149-
LOG.debug('Failed to enable '
150-
'octavia-keepalivedlvs service: '
151-
'%(err)s', {'err': str(e)})
152-
return webob.Response(json={
153-
'message': ("Error enabling "
154-
"octavia-keepalivedlvs service"),
155-
'details': e.output}, status=500)
125+
consts.ENABLE,
126+
consts.KEEPALIVEDLVS_SYSTEMD % listener_id)
127+
except subprocess.CalledProcessError as e:
128+
return webob.Response(json={
129+
'message': ("Error enabling "
130+
"octavia-keepalivedlvs service"),
131+
'details': e.output}, status=500)
156132

157133
if NEED_CHECK:
158134
# inject the check script for keepalived process
@@ -166,7 +142,6 @@ def upload_lvs_listener_config(self, listener_id):
166142
'w') as script_file:
167143
text = check_script_file_template.render(
168144
consts=consts,
169-
init_system=init_system,
170145
keepalived_lvs_pid_dir=util.keepalived_lvs_dir()
171146
)
172147
script_file.write(text)
@@ -217,15 +192,10 @@ def manage_lvs_listener(self, listener_id, action):
217192
if consts.OFFLINE == self._check_lvs_listener_status(listener_id):
218193
action = consts.AMP_ACTION_START
219194

220-
cmd = ("/usr/sbin/service "
221-
f"octavia-keepalivedlvs-{listener_id} {action}")
222-
223195
try:
224-
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT,
225-
encoding='utf-8')
196+
util.run_systemctl_command(
197+
action, consts.KEEPALIVEDLVS_SYSTEMD % listener_id)
226198
except subprocess.CalledProcessError as e:
227-
LOG.debug('Failed to %s keepalivedlvs listener %s',
228-
listener_id + ' : ' + action, e)
229199
return webob.Response(json={
230200
'message': (f"Failed to {action} keepalivedlvs listener "
231201
f"{listener_id}"),
@@ -280,11 +250,10 @@ def delete_lvs_listener(self, listener_id):
280250
if os.path.exists(keepalived_pid) and os.path.exists(
281251
os.path.join('/proc',
282252
util.get_keepalivedlvs_pid(listener_id))):
283-
cmd = (f"/usr/sbin/service "
284-
f"octavia-keepalivedlvs-{listener_id} stop")
285253
try:
286-
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT,
287-
encoding='utf-8')
254+
util.run_systemctl_command(
255+
consts.STOP,
256+
consts.KEEPALIVEDLVS_SYSTEMD % listener_id)
288257
except subprocess.CalledProcessError as e:
289258
LOG.error("Failed to stop keepalivedlvs service: %s", e)
290259
return webob.Response(json={
@@ -301,31 +270,21 @@ def delete_lvs_listener(self, listener_id):
301270
os.remove(pid)
302271

303272
# disable the service
304-
init_system = util.get_os_init_system()
305-
init_path = util.keepalived_lvs_init_path(init_system, listener_id)
273+
init_path = util.keepalived_lvs_init_path(listener_id)
306274

307-
if init_system == consts.INIT_SYSTEMD:
275+
try:
308276
util.run_systemctl_command(
309-
consts.DISABLE, f"octavia-keepalivedlvs-{listener_id}")
310-
311-
elif init_system == consts.INIT_SYSVINIT:
312-
init_disable_cmd = f"insserv -r {init_path}"
313-
try:
314-
subprocess.check_output(init_disable_cmd.split(),
315-
stderr=subprocess.STDOUT,
316-
encoding='utf-8')
317-
except subprocess.CalledProcessError as e:
318-
LOG.error("Failed to disable "
319-
"octavia-keepalivedlvs-%(list)s service: "
320-
"%(err)s", {'list': listener_id, 'err': str(e)})
321-
return webob.Response(json={
322-
'message': (
323-
f"Error disabling octavia-keepalivedlvs-{listener_id} "
324-
f"service"),
325-
'details': e.output}, status=500)
326-
327-
elif init_system != consts.INIT_UPSTART:
328-
raise util.UnknownInitError()
277+
consts.DISABLE,
278+
consts.KEEPALIVEDLVS_SYSTEMD % listener_id)
279+
except subprocess.CalledProcessError as e:
280+
LOG.error("Failed to disable "
281+
"octavia-keepalivedlvs-%(list)s service: "
282+
"%(err)s", {'list': listener_id, 'err': str(e)})
283+
return webob.Response(json={
284+
'message': (
285+
f"Error disabling octavia-keepalivedlvs-{listener_id} "
286+
"service"),
287+
'details': e.output}, status=500)
329288

330289
# delete init script ,config file and log file for that listener
331290
if os.path.exists(init_path):

0 commit comments

Comments
 (0)