mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #65187 from kwmonroe/feature/goal-state-status
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. juju charms: set more accurate status based on goal_state **What this PR does / why we need it**: Use juju goal-state to report more accurate charm status. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes https://github.com/juju-solutions/bundle-canonical-kubernetes/issues/593 **Special notes for your reviewer**: The goal-state hook tool was released in juju 2.4. For deployments on earlier versions of juju, this will fall back to the current status reporting behavior. **Release note**: ```release-note Report accurate status for kubernetes-master and -worker charms. ```
This commit is contained in:
commit
a1344cb0d5
@ -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')
|
||||||
|
@ -1009,6 +1009,16 @@ def missing_kube_control():
|
|||||||
missing.
|
missing.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
goal_state = hookenv.goal_state()
|
||||||
|
except NotImplementedError:
|
||||||
|
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(
|
hookenv.status_set(
|
||||||
'blocked',
|
'blocked',
|
||||||
'Relate {}:kube-control kubernetes-master:kube-control'.format(
|
'Relate {}:kube-control kubernetes-master:kube-control'.format(
|
||||||
|
Loading…
Reference in New Issue
Block a user