When deploying cos-configuration-k8s in a bundle, the tests are very flaky and often fail because cos-configuration-k8s goes to "hook failed: install" state. This is caused by trying to access self.model.storages["content-from-git"][0].location from the charm initialization code when the storage has not yet been attached.
When the charm is initialized, we try to access the storage, and if it is not yet available, return gracefully.
Context
This was faced during deploying cos-configuration-k8s in a bundle, where tests would fail if charm hooks were fired before storage was attached.
For the solution, I noticed a few lines earlier we check:
if len(self.model.storages["content-from-git"]) == 0:
return
However, even if this check passes, the self.model.storages["content-from-git"][0].location may still fail, and I've added an a similar logic to check to detect this and return.
Issue
When deploying
cos-configuration-k8s
in a bundle, the tests are very flaky and often fail becausecos-configuration-k8s
goes to "hook failed: install" state. This is caused by trying to accessself.model.storages["content-from-git"][0].location
from the charm initialization code when the storage has not yet been attached.https://github.com/canonical/cos-configuration-k8s-operator/issues/84
Solution
When the charm is initialized, we try to access the storage, and if it is not yet available, return gracefully.
Context
This was faced during deploying cos-configuration-k8s in a bundle, where tests would fail if charm hooks were fired before storage was attached.
For the solution, I noticed a few lines earlier we check:
However, even if this check passes, the
self.model.storages["content-from-git"][0].location
may still fail, and I've added an a similar logic to check to detect this andreturn
.Testing Instructions