diff --git a/lib/reversetunnel/agent.go b/lib/reversetunnel/agent.go index 6e2c814e9cdd3..bb226fa356b2b 100644 --- a/lib/reversetunnel/agent.go +++ b/lib/reversetunnel/agent.go @@ -341,7 +341,10 @@ func (a *Agent) run() { defer conn.Close() // Successfully connected to remote cluster. - a.log.WithField("addr", conn.LocalAddr().String()).WithField("remote-addr", conn.RemoteAddr().String()).Info("Connected.") + a.log.WithFields(log.Fields{ + "addr": conn.LocalAddr().String(), + "remote-addr": conn.RemoteAddr().String(), + }).Info("Connected.") // wrap up remaining business logic in closure for easy // conditional execution. diff --git a/lib/services/server.go b/lib/services/server.go index 0c94fd2a624a9..575a01c92dd8a 100644 --- a/lib/services/server.go +++ b/lib/services/server.go @@ -408,6 +408,12 @@ func (r *Metadata) Merge(src proto.Message) { expires := *m.Expires r.Expires = &expires } + if len(m.Labels) != 0 { + r.Labels = make(map[string]string) + for k, v := range m.Labels { + r.Labels[k] = v + } + } } const ( diff --git a/lib/services/services_test.go b/lib/services/services_test.go index 7ec8fafd4361f..b2a543da2a082 100644 --- a/lib/services/services_test.go +++ b/lib/services/services_test.go @@ -105,6 +105,7 @@ func (s *ServicesSuite) TestLabelKeyValidation(c *check.C) { func TestServerDeepCopy(t *testing.T) { t.Parallel() + // setup now := time.Date(1984, time.April, 4, 0, 0, 0, 0, time.UTC) expires := now.Add(1 * time.Hour) srv := &ServerV2{ @@ -159,11 +160,16 @@ func TestServerDeepCopy(t *testing.T) { }, }, } + + // exercise srv2 := srv.DeepCopy() - require.Empty(t, cmp.Diff(srv, srv2)) + // verify + require.Empty(t, cmp.Diff(srv, srv2)) require.IsType(t, srv2, &ServerV2{}) + // Mutate the second value but expect the original to be unaffected + srv2.(*ServerV2).Metadata.Labels["foo"] = "bar" srv2.(*ServerV2).Spec.CmdLabels = map[string]CommandLabelV2{ "srv-cmd": { Period: Duration(3 * time.Second), @@ -172,7 +178,12 @@ func TestServerDeepCopy(t *testing.T) { } expires2 := now.Add(10 * time.Minute) srv2.(*ServerV2).Metadata.Expires = &expires2 + + // exercise srv3 := srv.DeepCopy() + + // verify require.Empty(t, cmp.Diff(srv, srv3)) + require.NotEmpty(t, cmp.Diff(srv.GetMetadata().Labels, srv2.GetMetadata().Labels)) require.NotEmpty(t, cmp.Diff(srv2, srv3)) }