Allow update of network configuration for bootstrap nodes only

Before this change, bonds get broken (their slaves become lost)
when node gets 'error' status after netconfig is done.
So, redeployment of such node would not be successful.

Change-Id: I9de989d0566cf4e5e1e735ec432cb921f43522eb
Closes-Bug: 1580541
This commit is contained in:
Aleksey Kasatkin 2016-05-12 12:18:16 +03:00
parent 5c7c578eda
commit 2576e69e96
3 changed files with 24 additions and 14 deletions

View File

@ -126,7 +126,7 @@ class TestNodeCollectionNICsHandler(BaseIntegrationTest):
def test_interface_changes_locking(self):
lock_vs_status = {
consts.NODE_STATUSES.discover: False,
consts.NODE_STATUSES.error: False,
consts.NODE_STATUSES.error: True,
consts.NODE_STATUSES.provisioning: True,
consts.NODE_STATUSES.provisioned: True,
consts.NODE_STATUSES.deploying: True,
@ -139,6 +139,7 @@ class TestNodeCollectionNICsHandler(BaseIntegrationTest):
nodes_kwargs=[{'roles': ['controller'], 'meta': meta}]
)
node = self.env.nodes[0]
node.error_type = consts.NODE_ERRORS.deploy
for status, lock in six.iteritems(lock_vs_status):
node.status = status
self.db.flush()

View File

@ -18,7 +18,6 @@ from mock import patch
from copy import deepcopy
from oslo_serialization import jsonutils
import six
from nailgun import consts
from nailgun import objects
@ -503,14 +502,19 @@ class TestHandlers(BaseIntegrationTest):
new_nic['offloading_modes'])
def test_NIC_locking_on_update_by_agent(self):
lock_vs_status = {
consts.NODE_STATUSES.discover: False,
consts.NODE_STATUSES.error: False,
consts.NODE_STATUSES.provisioning: True,
consts.NODE_STATUSES.provisioned: True,
consts.NODE_STATUSES.deploying: True,
consts.NODE_STATUSES.ready: True,
consts.NODE_STATUSES.removing: True}
lock_vs_status = (
(consts.NODE_STATUSES.discover, False),
(consts.NODE_STATUSES.error, True, consts.NODE_ERRORS.deletion),
(consts.NODE_STATUSES.error, True, consts.NODE_ERRORS.deploy),
(consts.NODE_STATUSES.error, False, consts.NODE_ERRORS.discover),
(consts.NODE_STATUSES.error, True, consts.NODE_ERRORS.provision),
(consts.NODE_STATUSES.error, True,
consts.NODE_ERRORS.stop_deployment),
(consts.NODE_STATUSES.provisioning, True),
(consts.NODE_STATUSES.provisioned, True),
(consts.NODE_STATUSES.deploying, True),
(consts.NODE_STATUSES.ready, True),
(consts.NODE_STATUSES.removing, True))
meta = self.env.default_metadata()
self.env.set_interfaces_in_meta(meta, [
@ -520,9 +524,12 @@ class TestHandlers(BaseIntegrationTest):
new_meta = deepcopy(meta)
node = self.env.nodes[0]
for status, lock in six.iteritems(lock_vs_status):
node.status = status
for case in lock_vs_status:
node.status = case[0]
if node.status == consts.NODE_STATUSES.error:
node.error_type = case[2]
self.db.flush()
lock = case[1]
new_meta['interfaces'][0]['current_speed'] += 1
node_data = {'mac': node['mac'], 'meta': new_meta}

View File

@ -430,12 +430,14 @@ class Node(NailgunObject):
def is_interfaces_configuration_locked(cls, instance):
"""Returns true if update of network configuration is not allowed.
It is not allowed during provision/deployment, after
successful deployment and during node removal.
Update of network configuration is allowed for bootstrap nodes only.
"""
return instance.status not in (
consts.NODE_STATUSES.discover,
consts.NODE_STATUSES.error,
) or (
instance.status == consts.NODE_STATUSES.error and
instance.error_type != consts.NODE_ERRORS.discover
)
@classmethod