Avoid possible conflicting KubernetesNode document

This avoids a tricky-to-debug situation where it can appear that
different labels (or even a different ip address) is applied to a host
than expected.

Change-Id: I29fc99581a85f9cd1275f5cc07dfcb1be0e98339
This commit is contained in:
Mark Burnett 2018-03-02 15:58:44 -06:00
parent 25062d253a
commit ed32542da7
2 changed files with 22 additions and 0 deletions

View File

@ -25,6 +25,8 @@ from promenade import policy
LOG = logging.getLogger(__name__)
SENTINEL = object()
class JoinScriptsResource(BaseResource):
"""
@ -48,6 +50,10 @@ class JoinScriptsResource(BaseResource):
except exceptions.DeckhandException as e:
raise falcon.HTTPInternalServerError(description=str(e))
if config.get_path('KubernetesNode:.', SENTINEL) != SENTINEL:
raise exceptions.ExistingKubernetesNodeDocumentError(
'Existing KubernetesNode documents found')
node_document = {
'schema': 'promenade/KubernetesNode/v1',
'metadata': {

View File

@ -243,6 +243,22 @@ class ApiError(PromenadeException):
status = falcon.HTTP_400
class ExistingKubernetesNodeDocumentError(ApiError):
"""
An exception to represent the unexpected discovery of
`promenade/KubernetesNode/v1` documents in the given site design when
calling the `join-scripts` api.
**Message:** *Existing KubernetesNode documents found*
**Troubleshoot:** *KubernetesNode documents should not be in the site
design when using the join-scripts API for join script generation.*
"""
title = 'Unexpected KubernetesNode document found'
status = falcon.HTTP_400
class InvalidFormatError(PromenadeException):
"""
An exception to cover invalid input formatting.