mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
set more accurate status based on charm goal_state
This commit is contained in:
parent
6d3f5b75f5
commit
ace790c07a
@ -396,12 +396,25 @@ def set_app_version():
|
|||||||
@hookenv.atexit
|
@hookenv.atexit
|
||||||
def set_final_status():
|
def set_final_status():
|
||||||
''' Set the final status of the charm as we leave hook execution '''
|
''' Set the final status of the charm as we leave hook execution '''
|
||||||
|
try:
|
||||||
|
goal_state = hookenv.goal_state()
|
||||||
|
except NotImplementedError:
|
||||||
|
goal_state = {}
|
||||||
|
|
||||||
if not is_state('kube-api-endpoint.available'):
|
if not is_state('kube-api-endpoint.available'):
|
||||||
hookenv.status_set('blocked', 'Waiting for kube-api-endpoint relation')
|
if 'relations' in goal_state and 'kube-api-endpoint' in goal_state['relations']:
|
||||||
|
status = 'waiting'
|
||||||
|
else:
|
||||||
|
status = 'blocked'
|
||||||
|
hookenv.status_set(status, 'Waiting for kube-api-endpoint relation')
|
||||||
return
|
return
|
||||||
|
|
||||||
if not is_state('kube-control.connected'):
|
if not is_state('kube-control.connected'):
|
||||||
hookenv.status_set('blocked', 'Waiting for workers.')
|
if 'relations' in goal_state and 'kube-control' in goal_state['relations']:
|
||||||
|
status = 'waiting'
|
||||||
|
else:
|
||||||
|
status = 'blocked'
|
||||||
|
hookenv.status_set(status, 'Waiting for workers.')
|
||||||
return
|
return
|
||||||
|
|
||||||
upgrade_needed = is_state('kubernetes-master.upgrade-needed')
|
upgrade_needed = is_state('kubernetes-master.upgrade-needed')
|
||||||
|
@ -1008,10 +1008,20 @@ def missing_kube_control():
|
|||||||
missing.
|
missing.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
hookenv.status_set(
|
try:
|
||||||
'blocked',
|
goal_state = hookenv.goal_state()
|
||||||
'Relate {}:kube-control kubernetes-master:kube-control'.format(
|
except NotImplementedError:
|
||||||
hookenv.service_name()))
|
goal_state = {}
|
||||||
|
|
||||||
|
if 'relations' in goal_state and 'kube-control' in goal_state['relations']:
|
||||||
|
hookenv.status_set(
|
||||||
|
'waiting',
|
||||||
|
'Waiting for kubernetes-master to become ready')
|
||||||
|
else:
|
||||||
|
hookenv.status_set(
|
||||||
|
'blocked',
|
||||||
|
'Relate {}:kube-control kubernetes-master:kube-control'.format(
|
||||||
|
hookenv.service_name()))
|
||||||
|
|
||||||
|
|
||||||
@when('docker.ready')
|
@when('docker.ready')
|
||||||
|
Loading…
Reference in New Issue
Block a user