Make 'blocked' status when node have no storage device
Currently there is an msg for no storage status on ceph node. But it doesn't make this charm state 'blocked'. is_storage_fine function has been created to check storage devices on ceph_hooks.py and using it on assess_status. Change-Id: I790fde0280060fa220ee83de2ad2319ac2c77230 Closes-Bug: lp1424510
This commit is contained in:
parent
a7c5e85c40
commit
fc04dd0fff
@ -252,6 +252,13 @@ def get_devices():
|
|||||||
return devices
|
return devices
|
||||||
|
|
||||||
|
|
||||||
|
def is_storage_fine():
|
||||||
|
for dev in get_devices():
|
||||||
|
if not os.path.exists(dev):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('mon-relation-joined')
|
@hooks.hook('mon-relation-joined')
|
||||||
def mon_relation_joined():
|
def mon_relation_joined():
|
||||||
public_addr = get_public_addr()
|
public_addr = get_public_addr()
|
||||||
@ -476,6 +483,11 @@ def assess_status():
|
|||||||
status_set('waiting', 'Peer units detected, waiting for addresses')
|
status_set('waiting', 'Peer units detected, waiting for addresses')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# check storage state
|
||||||
|
if not is_storage_fine():
|
||||||
|
status_set('blocked', 'No usable storage devices found')
|
||||||
|
return
|
||||||
|
|
||||||
# active - bootstrapped + quorum status check
|
# active - bootstrapped + quorum status check
|
||||||
if ceph.is_bootstrapped() and ceph.is_quorum():
|
if ceph.is_bootstrapped() and ceph.is_quorum():
|
||||||
status_set('active', 'Unit is ready and clustered')
|
status_set('active', 'Unit is ready and clustered')
|
||||||
|
@ -49,19 +49,33 @@ class ServiceStatusTestCase(test_utils.CharmTestCase):
|
|||||||
hooks.assess_status()
|
hooks.assess_status()
|
||||||
self.status_set.assert_called_with('waiting', mock.ANY)
|
self.status_set.assert_called_with('waiting', mock.ANY)
|
||||||
|
|
||||||
|
@mock.patch.object(hooks, 'is_storage_fine')
|
||||||
@mock.patch.object(hooks, 'get_peer_units')
|
@mock.patch.object(hooks, 'get_peer_units')
|
||||||
def test_assess_status_peers_complete_active(self, _peer_units):
|
def test_assess_status_peers_complete_active(self, _peer_units, _storage):
|
||||||
_peer_units.return_value = ENOUGH_PEERS_COMPLETE
|
_peer_units.return_value = ENOUGH_PEERS_COMPLETE
|
||||||
self.ceph.is_bootstrapped.return_value = True
|
self.ceph.is_bootstrapped.return_value = True
|
||||||
self.ceph.is_quorum.return_value = True
|
self.ceph.is_quorum.return_value = True
|
||||||
|
_storage.return_value = True
|
||||||
hooks.assess_status()
|
hooks.assess_status()
|
||||||
self.status_set.assert_called_with('active', mock.ANY)
|
self.status_set.assert_called_with('active', mock.ANY)
|
||||||
|
|
||||||
|
@mock.patch.object(hooks, 'is_storage_fine')
|
||||||
@mock.patch.object(hooks, 'get_peer_units')
|
@mock.patch.object(hooks, 'get_peer_units')
|
||||||
def test_assess_status_peers_complete_down(self, _peer_units):
|
def test_assess_status_peers_complete_down(self, _peer_units, _storage):
|
||||||
_peer_units.return_value = ENOUGH_PEERS_COMPLETE
|
_peer_units.return_value = ENOUGH_PEERS_COMPLETE
|
||||||
self.ceph.is_bootstrapped.return_value = False
|
self.ceph.is_bootstrapped.return_value = False
|
||||||
self.ceph.is_quorum.return_value = False
|
self.ceph.is_quorum.return_value = False
|
||||||
|
_storage.return_value = False
|
||||||
|
hooks.assess_status()
|
||||||
|
self.status_set.assert_called_with('blocked', mock.ANY)
|
||||||
|
|
||||||
|
@mock.patch.object(hooks, 'is_storage_fine')
|
||||||
|
@mock.patch.object(hooks, 'get_peer_units')
|
||||||
|
def test_assess_status_storage_fail(self, _peer_units, _storage):
|
||||||
|
_peer_units.return_value = ENOUGH_PEERS_COMPLETE
|
||||||
|
self.ceph.is_bootstrapped.return_value = True
|
||||||
|
self.ceph.is_quorum.return_value = True
|
||||||
|
_storage.return_value = False
|
||||||
hooks.assess_status()
|
hooks.assess_status()
|
||||||
self.status_set.assert_called_with('blocked', mock.ANY)
|
self.status_set.assert_called_with('blocked', mock.ANY)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user