Skip to content

Commit

Permalink
Merge pull request #210 from hemanthnakkina/fix-disable-plugins
Browse files Browse the repository at this point in the history
Handle wait for application gone in plugin disable
  • Loading branch information
gboutry authored Apr 26, 2024
2 parents f938083 + 4abdf24 commit 05711cb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ jobs:
sg snap_daemon "openstack.sunbeam configure -a"
sg snap_daemon "openstack.sunbeam launch"
sg snap_daemon "openstack.sunbeam enable orchestration"
# sg snap_daemon "openstack.sunbeam enable loadbalancer"
# sg snap_daemon "openstack.sunbeam enable dns --nameservers=testing.github."
sg snap_daemon "openstack.sunbeam enable loadbalancer"
sg snap_daemon "openstack.sunbeam enable dns --nameservers=testing.github."
sg snap_daemon "openstack.sunbeam enable telemetry"
sg snap_daemon "openstack.sunbeam enable observability"
sg snap_daemon "openstack.sunbeam enable vault"
Expand All @@ -72,8 +72,8 @@ jobs:
# Commented disabling observability due to LP#1998282
# sg snap_daemon "openstack.sunbeam disable observability"
# sg snap_daemon "openstack.sunbeam disable telemetry"
# sg snap_daemon "openstack.sunbeam disable dns"
# sg snap_daemon "openstack.sunbeam disable loadbalancer"
sg snap_daemon "openstack.sunbeam disable dns"
sg snap_daemon "openstack.sunbeam disable loadbalancer"
sg snap_daemon "openstack.sunbeam disable orchestration"
# sg snap_daemon "openstack.sunbeam disable validation"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-snap-with-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jobs:
sg snap_daemon "sunbeam configure -a"
sg snap_daemon "sunbeam launch"
sg snap_daemon "sunbeam enable orchestration"
# sg snap_daemon "sunbeam enable loadbalancer"
# sg snap_daemon "sunbeam enable dns --nameservers=testing.github."
sg snap_daemon "sunbeam enable loadbalancer"
sg snap_daemon "sunbeam enable dns --nameservers=testing.github."
sg snap_daemon "sunbeam enable telemetry"
sg snap_daemon "sunbeam enable observability"
sg snap_daemon "sunbeam enable vault"
Expand All @@ -56,8 +56,8 @@ jobs:
# Commented disabling observability due to LP#1998282
# sg snap_daemon "sunbeam disable observability"
# sg snap_daemon "sunbeam disable telemetry"
# sg snap_daemon "sunbeam disable dns"
# sg snap_daemon "sunbeam disable loadbalancer"
sg snap_daemon "sunbeam disable dns"
sg snap_daemon "sunbeam disable loadbalancer"
sg snap_daemon "sunbeam disable orchestration"
# sg snap_daemon "sunbeam disable validation"
Expand Down
14 changes: 12 additions & 2 deletions sunbeam-python/sunbeam/plugins/interface/v1/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def run(self, status: Optional[Status] = None) -> Result:
self.jhelper.wait_until_active(
self.model,
apps,
timeout=APPLICATION_DEPLOY_TIMEOUT,
timeout=self.plugin.set_application_timeout_on_enable(),
)
)
except (JujuWaitException, TimeoutException) as e:
Expand Down Expand Up @@ -493,6 +493,16 @@ def run(self, status: Optional[Status] = None) -> Result:

apps = self.plugin.set_application_names()
LOG.debug(f"Application monitored for removal: {apps}")
# TODO(hemanth): Check if apps are removed or not.
try:
run_sync(
self.jhelper.wait_application_gone(
apps,
self.model,
timeout=self.plugin.set_application_timeout_on_disable(),
)
)
except TimeoutException as e:
LOG.debug(f"Failed to destroy {apps}", exc_info=True)
return Result(ResultType.FAILED, str(e))

return Result(ResultType.COMPLETED)
13 changes: 13 additions & 0 deletions sunbeam-python/tests/unit/sunbeam/plugins/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ def test_run_tf_apply_failed(self, cclient, jhelper, osplugin):
assert result.result_type == ResultType.FAILED
assert result.message == "apply failed..."

def test_run_waiting_timed_out(
self, cclient, read_config, jhelper, tfhelper, osplugin, manifest, pluginmanager
):
jhelper.wait_application_gone.side_effect = TimeoutException("timed out")

step = openstack.DisableOpenStackApplicationStep(jhelper, osplugin)
result = step.run()

osplugin.manifest.update_tfvars_and_apply_tf.assert_called_once()
jhelper.wait_application_gone.assert_called_once()
assert result.result_type == ResultType.FAILED
assert result.message == "timed out"


class MockStatus:
def __init__(self, value: dict):
Expand Down

0 comments on commit 05711cb

Please sign in to comment.