Lower log level of missing output
Lower the log level of a warning for a missing output to debug. This log line appears repeatedly on successful cluster deletion, creation failure (for unrelated reasons) and nodegroup creation failure (again for unrelated reasons, eg timeout). This is triggered when having multiple magnum conductors all trying to query the status in heat. Additionally, this warning is not an indication of a malfunction in a cluster or a failure, so it is useful only for debugging. Finally, add the cluster id, cluster status and stack id to have more context. story: 2007636 task: 40062 Change-Id: Ie44b1d13899d77bd2a5d5b1e6107c384277788b9 Signed-off-by: Spyros Trigazis <spyridon.trigazis@cern.ch>
This commit is contained in:
parent
52690900a7
commit
65ab249189
|
@ -49,7 +49,7 @@ class ScaleManager(object):
|
|||
|
||||
cluster = self.new_cluster
|
||||
stack = self.osclient.heat().stacks.get(cluster.stack_id)
|
||||
hosts = hosts_output.get_output_value(stack)
|
||||
hosts = hosts_output.get_output_value(stack, cluster)
|
||||
if hosts is None:
|
||||
raise exception.MagnumException(_(
|
||||
"Output key '%(output_key)s' is missing from stack "
|
||||
|
|
|
@ -35,7 +35,7 @@ class K8sApiAddressOutputMapping(template_def.OutputMapping):
|
|||
if self.cluster_attr is None:
|
||||
return
|
||||
|
||||
output_value = self.get_output_value(stack)
|
||||
output_value = self.get_output_value(stack, cluster)
|
||||
if output_value is not None:
|
||||
# TODO(yuanying): port number is hardcoded, this will be fix
|
||||
protocol = 'https'
|
||||
|
|
|
@ -24,7 +24,7 @@ class SwarmApiAddressOutputMapping(template_def.OutputMapping):
|
|||
if self.cluster_attr is None:
|
||||
return
|
||||
|
||||
output_value = self.get_output_value(stack)
|
||||
output_value = self.get_output_value(stack, cluster)
|
||||
if output_value is not None:
|
||||
# Note(rocha): protocol should always be tcp as the docker
|
||||
# command client does not handle https (see bug #1604812).
|
||||
|
|
|
@ -26,7 +26,7 @@ class SwarmModeApiAddressOutputMapping(template_def.OutputMapping):
|
|||
if self.cluster_attr is None:
|
||||
return
|
||||
|
||||
output_value = self.get_output_value(stack)
|
||||
output_value = self.get_output_value(stack, cluster)
|
||||
if output_value is not None:
|
||||
# Note(rocha): protocol should always be tcp as the docker
|
||||
# command client does not handle https (see bug #1604812).
|
||||
|
|
|
@ -114,7 +114,7 @@ class OutputMapping(object):
|
|||
if self.cluster_attr is None:
|
||||
return
|
||||
|
||||
output_value = self.get_output_value(stack)
|
||||
output_value = self.get_output_value(stack, cluster)
|
||||
if output_value is None:
|
||||
return
|
||||
setattr(cluster, self.cluster_attr, output_value)
|
||||
|
@ -122,12 +122,19 @@ class OutputMapping(object):
|
|||
def matched(self, output_key):
|
||||
return self.heat_output == output_key
|
||||
|
||||
def get_output_value(self, stack):
|
||||
def get_output_value(self, stack, cluster):
|
||||
for output in stack.to_dict().get('outputs', []):
|
||||
if output['output_key'] == self.heat_output:
|
||||
return output['output_value']
|
||||
|
||||
LOG.warning('stack does not have output_key %s', self.heat_output)
|
||||
LOG.debug('cluster %(cluster_uuid)s, status %(cluster_status)s, '
|
||||
'stack %(stack_id)s does not have output_key '
|
||||
'%(heat_output)s',
|
||||
{'cluster_uuid': cluster.uuid,
|
||||
'cluster_status': cluster.status,
|
||||
'stack_id': stack.id,
|
||||
'heat_output': self.heat_output}
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
|
@ -150,7 +157,7 @@ class NodeGroupOutputMapping(OutputMapping):
|
|||
if self.nodegroup_attr is None:
|
||||
return
|
||||
|
||||
output_value = self.get_output_value(stack)
|
||||
output_value = self.get_output_value(stack, cluster)
|
||||
if output_value is None:
|
||||
return
|
||||
|
||||
|
@ -166,9 +173,10 @@ class NodeGroupOutputMapping(OutputMapping):
|
|||
setattr(ng, self.nodegroup_attr, output_value)
|
||||
ng.save()
|
||||
|
||||
def get_output_value(self, stack):
|
||||
def get_output_value(self, stack, cluster):
|
||||
if not self.is_stack_param:
|
||||
return super(NodeGroupOutputMapping, self).get_output_value(stack)
|
||||
return super(NodeGroupOutputMapping, self).get_output_value(
|
||||
stack, cluster)
|
||||
return self.get_param_value(stack)
|
||||
|
||||
def get_param_value(self, stack):
|
||||
|
|
|
@ -150,24 +150,25 @@ class TemplateDefinitionTestCase(base.TestCase):
|
|||
]
|
||||
|
||||
mock_stack = mock.MagicMock()
|
||||
mock_cluster = mock.MagicMock()
|
||||
mock_stack.to_dict.return_value = {'outputs': heat_outputs}
|
||||
|
||||
output = cmn_tdef.OutputMapping('key1')
|
||||
value = output.get_output_value(mock_stack)
|
||||
value = output.get_output_value(mock_stack, mock_cluster)
|
||||
self.assertEqual('value1', value)
|
||||
|
||||
output = cmn_tdef.OutputMapping('key2')
|
||||
value = output.get_output_value(mock_stack)
|
||||
value = output.get_output_value(mock_stack, mock_cluster)
|
||||
self.assertEqual(["value2", "value3"], value)
|
||||
|
||||
output = cmn_tdef.OutputMapping('key3')
|
||||
value = output.get_output_value(mock_stack)
|
||||
value = output.get_output_value(mock_stack, mock_cluster)
|
||||
self.assertIsNone(value)
|
||||
|
||||
# verify stack with no 'outputs' attribute
|
||||
mock_stack.to_dict.return_value = {}
|
||||
output = cmn_tdef.OutputMapping('key1')
|
||||
value = output.get_output_value(mock_stack)
|
||||
value = output.get_output_value(mock_stack, mock_cluster)
|
||||
self.assertIsNone(value)
|
||||
|
||||
def test_add_output_with_mapping_type(self):
|
||||
|
|
Loading…
Reference in New Issue