From df0addb5e33a825c781ee100442708b61da0690c Mon Sep 17 00:00:00 2001 From: Angel Velazquez Date: Tue, 24 Aug 2021 17:12:16 -0700 Subject: [PATCH] Improve error log when instance reigstration fails due to bad attributes --- agent/api/container/transport.go | 2 +- agent/app/agent.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/agent/api/container/transport.go b/agent/api/container/transport.go index f17d0010c1b..1b8195458d8 100644 --- a/agent/api/container/transport.go +++ b/agent/api/container/transport.go @@ -56,7 +56,7 @@ func (tp *TransportProtocol) String() string { case TransportProtocolTCP: return tcp default: - seelog.Critical("Unknown TransportProtocol type!") + seelog.Criticalf("Unknown TransportProtocol type: %s", *tp) return tcp } } diff --git a/agent/app/agent.go b/agent/app/agent.go index 5cb520da63c..459797d07af 100644 --- a/agent/app/agent.go +++ b/agent/app/agent.go @@ -70,6 +70,7 @@ const ( clusterMismatchErrorFormat = "Data mismatch; saved cluster '%v' does not match configured cluster '%v'. Perhaps you want to delete the configured checkpoint file?" instanceIDMismatchErrorFormat = "Data mismatch; saved InstanceID '%s' does not match current InstanceID '%s'. Overwriting old datafile" instanceTypeMismatchErrorFormat = "The current instance type does not match the registered instance type. Please revert the instance type change, or alternatively launch a new instance: %v" + customAttributeErrorMessage = " Please make sure custom attributes are valid as per public AWS documentation: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-constraints.html#attributes" vpcIDAttributeName = "ecs.vpc-id" subnetIDAttributeName = "ecs.subnet-id" @@ -586,7 +587,11 @@ func (agent *ecsAgent) registerContainerInstance( return err } if _, ok := err.(apierrors.AttributeError); ok { - seelog.Critical("Instance registration attempt with an invalid attribute") + attributeErrorMsg := "" + if len(agent.cfg.InstanceAttributes) > 0 { + attributeErrorMsg = customAttributeErrorMessage + } + seelog.Critical("Instance registration attempt with invalid attribute(s)." + attributeErrorMsg) return err } return transientError{err} @@ -617,7 +622,11 @@ func (agent *ecsAgent) reregisterContainerInstance(client api.ECSClient, capabil return err } if _, ok := err.(apierrors.AttributeError); ok { - seelog.Critical("Instance re-registration attempt with an invalid attribute") + attributeErrorMsg := "" + if len(agent.cfg.InstanceAttributes) > 0 { + attributeErrorMsg = customAttributeErrorMessage + } + seelog.Critical("Instance re-registration attempt with invalid attribute(s)." + attributeErrorMsg) return err } return transientError{err}