Skip to content

Commit

Permalink
Fix kubelet cloud config not updating when azure data changes (#131)
Browse files Browse the repository at this point in the history
* Fix kubelet cloud config not updating when azure data changes

* Add `tox -e format` and run it
  • Loading branch information
George Kraft committed Nov 21, 2022
1 parent 4258fd8 commit c436d1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions reactive/kubernetes_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from charms.reactive import is_state, is_flag_set, any_flags_set
from charms.reactive import when, when_any, when_not, when_none
from charms.reactive import data_changed, is_data_changed
from charms.reactive import register_trigger

from charmhelpers.core import hookenv, unitdata
from charmhelpers.core.host import service_stop, service_restart
Expand Down Expand Up @@ -102,6 +103,11 @@
db = unitdata.kv()


register_trigger(
when="endpoint.azure.ready.changed", clear_flag="kubernetes-worker.cloud.ready"
)


@hook("upgrade-charm")
def upgrade_charm():
# migrate to new flags
Expand Down Expand Up @@ -1265,6 +1271,7 @@ def cloud_ready():
write_gcp_snap_config("kubelet")
elif is_state("endpoint.azure.ready"):
write_azure_snap_config("kubelet")
clear_flag("endpoint.azure.ready.changed")
set_state("kubernetes-worker.cloud.ready")
set_state("kubernetes-worker.restart-needed") # force restart

Expand Down
6 changes: 6 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ deps =
commands =
flake8 {toxinidir}/reactive {toxinidir}/tests {toxinidir}/actions
black --check {toxinidir}/reactive {toxinidir}/tests {toxinidir}/actions

[testenv:format]
deps =
black
commands =
black {toxinidir}/reactive {toxinidir}/tests {toxinidir}/actions

0 comments on commit c436d1d

Please sign in to comment.