From 87a25403f137930f883d48bfc1d06c7dc608de0f Mon Sep 17 00:00:00 2001 From: Andrew Burke Date: Wed, 1 Jun 2022 12:19:23 -0700 Subject: [PATCH] Fix EC2 labels concurrent write --- integration/ec2_test.go | 3 +-- lib/labels/ec2/ec2.go | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/integration/ec2_test.go b/integration/ec2_test.go index 1810f75867202..364c3535baf40 100644 --- a/integration/ec2_test.go +++ b/integration/ec2_test.go @@ -411,8 +411,7 @@ func TestEC2Labels(t *testing.T) { } // TestEC2Hostname is an integration test which asserts that Teleport sets its -// hostname if the EC2 tag `TeleportHostname` is available. This test must be -// run on an instance with tag `TeleportHostname=fakehost.example.com`. +// hostname if the EC2 tag `TeleportHostname` is available. func TestEC2Hostname(t *testing.T) { teleportHostname := "fakehost.example.com" diff --git a/lib/labels/ec2/ec2.go b/lib/labels/ec2/ec2.go index f0ecf9df0c51e..15b3f3acc9e96 100644 --- a/lib/labels/ec2/ec2.go +++ b/lib/labels/ec2/ec2.go @@ -87,7 +87,11 @@ func New(ctx context.Context, c *Config) (*EC2, error) { func (l *EC2) Get() map[string]string { l.mu.RLock() defer l.mu.RUnlock() - return l.labels + labels := make(map[string]string) + for k, v := range l.labels { + labels[k] = v + } + return labels } // Apply adds EC2 labels to the provided resource.