mirror of
https://github.com/gravitational/teleport
synced 2024-10-21 17:53:28 +00:00
Lower EC2 label log frequency (#15179)
This change makes the error message for when EC2 tags aren't available in instance metadata only emit once, to reduce log spam. Co-authored-by: Roman Tkachenko <roman@goteleport.com>
This commit is contained in:
parent
f56dd09ebd
commit
d46ccb22ab
|
@ -70,6 +70,9 @@ type EC2 struct {
|
|||
labels map[string]string
|
||||
|
||||
closeCh chan struct{}
|
||||
// loggedInstanceTagsNotFound is used to ensure that the error message for
|
||||
// incorrectly configured instance metadata is only logged once.
|
||||
loggedInstanceTagsNotFound bool
|
||||
}
|
||||
|
||||
func New(ctx context.Context, c *Config) (*EC2, error) {
|
||||
|
@ -110,11 +113,16 @@ func (l *EC2) Sync(ctx context.Context) error {
|
|||
tags, err := l.c.Client.GetTagKeys(ctx)
|
||||
if err != nil {
|
||||
if trace.IsNotFound(err) {
|
||||
l.c.Log.Warningf("could not fetch tags, please ensure 'allow instance tags in metadata' is enabled on the instance")
|
||||
// Only show the error the first time around.
|
||||
if !l.loggedInstanceTagsNotFound {
|
||||
l.loggedInstanceTagsNotFound = true
|
||||
l.c.Log.Warning("Could not fetch EC2 instance's tags, please ensure 'allow instance tags in metadata' is enabled on the instance.")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return trace.Wrap(err)
|
||||
}
|
||||
l.loggedInstanceTagsNotFound = false
|
||||
|
||||
currentLabels := l.Get()
|
||||
var errors []error
|
||||
|
|
Loading…
Reference in a new issue