Merge "Cleaning up after application removal"
This commit is contained in:
commit
61181932e9
@ -178,4 +178,20 @@ spec:
|
|||||||
- name: config-volume-{{- $root.Values.global.name }}
|
- name: config-volume-{{- $root.Values.global.name }}
|
||||||
mountPath: {{ $mount }}
|
mountPath: {{ $mount }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
---
|
||||||
|
# This ConfigMap is needed because we're not using ceph's helm chart
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: ceph-etc
|
||||||
|
# This is the name of the openstack application's namespace
|
||||||
|
namespace: openstack
|
||||||
|
data:
|
||||||
|
ceph.conf: |
|
||||||
|
[global]
|
||||||
|
auth_supported = none
|
||||||
|
{{ $monitors := $defaults.monitors }}{{ range $index, $element := $monitors}}
|
||||||
|
[mon.{{- $index }}]
|
||||||
|
mon_addr = {{ $element }}
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
@ -893,25 +893,43 @@ class AppOperator(object):
|
|||||||
if self._make_armada_request_with_monitor(app, constants.APP_DELETE_OP):
|
if self._make_armada_request_with_monitor(app, constants.APP_DELETE_OP):
|
||||||
if app.system_app:
|
if app.system_app:
|
||||||
try:
|
try:
|
||||||
p1 = subprocess.Popen(['kubectl', 'get', 'pods', '-n',
|
# TODO convert these kubectl commands to use the k8s api
|
||||||
'openstack'],
|
p1 = subprocess.Popen(
|
||||||
|
['kubectl', '--kubeconfig=/etc/kubernetes/admin.conf',
|
||||||
|
'get', 'pvc', '--no-headers', '-n', 'openstack'],
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
p2 = subprocess.Popen(['awk', '/osh-.*-test/{print $1}'],
|
p2 = subprocess.Popen(['awk', '{print $3}'],
|
||||||
stdin=p1.stdout,
|
stdin=p1.stdout,
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
p3 = subprocess.Popen(['xargs', '-i', 'kubectl',
|
p3 = subprocess.Popen(
|
||||||
'delete', 'pods', '-n', 'openstack',
|
['xargs', '-i', 'kubectl',
|
||||||
'{}'], stdin=p2.stdout,
|
'--kubeconfig=/etc/kubernetes/admin.conf', 'delete',
|
||||||
|
'pv', '{}', '--wait=false'],
|
||||||
|
stdin=p2.stdout,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
|
|
||||||
p1.stdout.close()
|
p1.stdout.close()
|
||||||
p2.stdout.close()
|
p2.stdout.close()
|
||||||
out, err = p3.communicate()
|
out, err = p3.communicate()
|
||||||
if not err:
|
if not err:
|
||||||
LOG.info("Old test pods cleanup completed.")
|
LOG.info("Persistent Volumes marked for deletion.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception("Failed to clean up test pods after app "
|
LOG.exception("Failed to clean up PVs after app "
|
||||||
"removal: %s" % e)
|
"removal: %s" % e)
|
||||||
|
|
||||||
|
try:
|
||||||
|
p1 = subprocess.Popen(
|
||||||
|
['kubectl', '--kubeconfig=/etc/kubernetes/admin.conf',
|
||||||
|
'delete', 'namespace', 'openstack'],
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
out, err = p1.communicate()
|
||||||
|
if not err:
|
||||||
|
LOG.info("Openstack namespace delete completed.")
|
||||||
|
except Exception as e:
|
||||||
|
LOG.exception("Failed to clean up openstack namespace "
|
||||||
|
"after app removal: %s" % e)
|
||||||
|
|
||||||
self._update_app_status(app, constants.APP_UPLOAD_SUCCESS)
|
self._update_app_status(app, constants.APP_UPLOAD_SUCCESS)
|
||||||
LOG.info("Application (%s) remove completed." % app.name)
|
LOG.info("Application (%s) remove completed." % app.name)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user