From 6dd7c28b573e1fc1d5155fc89667d25c7b56cded Mon Sep 17 00:00:00 2001 From: Rob Gulewich Date: Mon, 2 Nov 2020 18:58:28 -0800 Subject: [PATCH] Don't use the latest github.com/golang/protobuf Turns out it uses the new protobuf version under the hood, and there are backwards compatibility issues: https://github.com/golang/protobuf/issues/1014 --- cmd/titus-imds-cni/env.go | 2 +- go.mod | 2 ++ metadataserver/server_test.go | 9 +++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/titus-imds-cni/env.go b/cmd/titus-imds-cni/env.go index 98fe93b89..4be1ecfdb 100644 --- a/cmd/titus-imds-cni/env.go +++ b/cmd/titus-imds-cni/env.go @@ -205,7 +205,7 @@ func writeContainerInfo(pod *v1.Pod) error { return errors.Wrap(err, "Unable to decode containerInfo protobuf") } - out, err := json.MarshalIndent(cInfo, "", " ") // nolint: govet + out, err := json.MarshalIndent(&cInfo, "", " ") if err != nil { return errors.Wrap(err, "Unable to marshal containerInfo as JSON") } diff --git a/go.mod b/go.mod index 15bc4b62e..5ab4521ad 100644 --- a/go.mod +++ b/go.mod @@ -134,3 +134,5 @@ replace k8s.io/client-go => k8s.io/client-go v0.18.4 replace k8s.io/kubectl => k8s.io/kubectl v0.18.4 replace k8s.io/api => k8s.io/api v0.18.4 + +replace github.com/golang/protobuf => github.com/golang/protobuf v1.3.3 diff --git a/metadataserver/server_test.go b/metadataserver/server_test.go index 0cdf3921b..ddd0d4a51 100644 --- a/metadataserver/server_test.go +++ b/metadataserver/server_test.go @@ -26,6 +26,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/session" + "github.com/gogo/protobuf/proto" protobuf "github.com/golang/protobuf/proto" // nolint: staticcheck "github.com/gorilla/mux" "github.com/stretchr/testify/assert" @@ -396,7 +397,7 @@ func validateTaskIdentityRequest(t *testing.T, keyPair testKeyPair) func(*stubSe return err } taskIdentDoc := new(titus.TaskIdentityDocument) - err = protobuf.Unmarshal(content, taskIdentDoc) + err = proto.Unmarshal(content, taskIdentDoc) if err != nil { return err } @@ -407,14 +408,14 @@ func validateTaskIdentityRequest(t *testing.T, keyPair testKeyPair) func(*stubSe // Identity taskIdent := new(titus.TaskIdentity) - err = protobuf.Unmarshal(taskIdentDoc.Identity, taskIdent) + err = proto.Unmarshal(taskIdentDoc.Identity, taskIdent) if err != nil { return err } expectedTaskIdent := fakeTaskIdentity() assert.NotNil(t, taskIdent.UnixTimestampSec) expectedTaskIdent.UnixTimestampSec = taskIdent.UnixTimestampSec - assert.Equal(t, *expectedTaskIdent, *taskIdent) // nolint: govet + assert.Equal(t, expectedTaskIdent, taskIdent) // The identity server checks Process for entrypoint and command: assert.NotNil(t, taskIdent.Container.Process) assert.Equal(t, []string{*expectedTaskIdent.Container.EntrypointStr}, taskIdent.Container.Process.Entrypoint) // nolint: staticcheck @@ -494,7 +495,7 @@ func validateTaskIdentityJSONRequest(t *testing.T) func(*stubServer, *http.Respo expectedTaskIdent := fakeTaskIdentity() expectedTaskIdent.UnixTimestampSec = taskIdentDoc.Identity.UnixTimestampSec - assert.Equal(t, *expectedTaskIdent, *taskIdentDoc.Identity) // nolint: govet + assert.Equal(t, expectedTaskIdent, taskIdentDoc.Identity) return nil }