mirror of https://github.com/k3s-io/k3s
Merge pull request #48446 from Cynerva/gkk/stop-snaps
Automatic merge from submit-queue (batch tested with PRs 47043, 48448, 47515, 48446) Fix charms leaving services running after remove-unit **What this PR does / why we need it**: This fixes a case where removed charm units can sometimes leave behind running services that interfere with the rest of the cluster. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note Fix charms leaving services running after remove-unit ```pull/6/head
commit
3823270b9e
|
@ -45,6 +45,7 @@ from charms.kubernetes.flagmanager import FlagManager
|
|||
from charmhelpers.core import hookenv
|
||||
from charmhelpers.core import host
|
||||
from charmhelpers.core import unitdata
|
||||
from charmhelpers.core.host import service_stop
|
||||
from charmhelpers.core.templating import render
|
||||
from charmhelpers.fetch import apt_install
|
||||
from charmhelpers.contrib.charmsupport import nrpe
|
||||
|
@ -695,6 +696,16 @@ def disable_gpu_mode():
|
|||
remove_state('kubernetes-master.gpu.enabled')
|
||||
|
||||
|
||||
@hook('stop')
|
||||
def shutdown():
|
||||
""" Stop the kubernetes master services
|
||||
|
||||
"""
|
||||
service_stop('snap.kube-apiserver.daemon')
|
||||
service_stop('snap.kube-controller-manager.daemon')
|
||||
service_stop('snap.kube-scheduler.daemon')
|
||||
|
||||
|
||||
def arch():
|
||||
'''Return the package architecture as a string. Raise an exception if the
|
||||
architecture is not supported by kubernetes.'''
|
||||
|
|
|
@ -158,15 +158,12 @@ def install_snaps():
|
|||
def shutdown():
|
||||
''' When this unit is destroyed:
|
||||
- delete the current node
|
||||
- stop the kubelet service
|
||||
- stop the kube-proxy service
|
||||
- remove the 'kubernetes-worker.cni-plugins.installed' state
|
||||
- stop the worker services
|
||||
'''
|
||||
if os.path.isfile(kubeconfig_path):
|
||||
kubectl('delete', 'node', gethostname())
|
||||
service_stop('kubelet')
|
||||
service_stop('kube-proxy')
|
||||
remove_state('kubernetes-worker.cni-plugins.installed')
|
||||
service_stop('snap.kubelet.daemon')
|
||||
service_stop('snap.kube-proxy.daemon')
|
||||
|
||||
|
||||
@when('docker.available')
|
||||
|
|
Loading…
Reference in New Issue