diff --git a/cmd/containerd-shim/main_unix.go b/cmd/containerd-shim/main_unix.go index 097377f71..d0cc0ad71 100644 --- a/cmd/containerd-shim/main_unix.go +++ b/cmd/containerd-shim/main_unix.go @@ -39,11 +39,11 @@ import ( "github.com/containerd/containerd/runtime/linux/proc" "github.com/containerd/containerd/runtime/shim" shimapi "github.com/containerd/containerd/runtime/shim/v1" + "github.com/containerd/ttrpc" "github.com/containerd/typeurl" ptypes "github.com/gogo/protobuf/types" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/stevvooe/ttrpc" "golang.org/x/sys/unix" ) diff --git a/cmd/containerd-shim/shim_darwin.go b/cmd/containerd-shim/shim_darwin.go index d9ed59100..a46fdd195 100644 --- a/cmd/containerd-shim/shim_darwin.go +++ b/cmd/containerd-shim/shim_darwin.go @@ -24,7 +24,7 @@ import ( "github.com/containerd/containerd/runtime/shim" runc "github.com/containerd/go-runc" - "github.com/stevvooe/ttrpc" + "github.com/containerd/ttrpc" ) // setupSignals creates a new signal handler for all signals and sets the shim as a diff --git a/cmd/containerd-shim/shim_linux.go b/cmd/containerd-shim/shim_linux.go index 6686b4ec9..d7a11821e 100644 --- a/cmd/containerd-shim/shim_linux.go +++ b/cmd/containerd-shim/shim_linux.go @@ -22,8 +22,8 @@ import ( "github.com/containerd/containerd/runtime/shim" runc "github.com/containerd/go-runc" + "github.com/containerd/ttrpc" "github.com/opencontainers/runc/libcontainer/system" - "github.com/stevvooe/ttrpc" "golang.org/x/sys/unix" ) diff --git a/cmd/containerd-shim/shim_unix.go b/cmd/containerd-shim/shim_unix.go index f920fd42d..3abd806cb 100644 --- a/cmd/containerd-shim/shim_unix.go +++ b/cmd/containerd-shim/shim_unix.go @@ -24,7 +24,7 @@ import ( "github.com/containerd/containerd/runtime/shim" runc "github.com/containerd/go-runc" - "github.com/stevvooe/ttrpc" + "github.com/containerd/ttrpc" ) // setupSignals creates a new signal handler for all signals and sets the shim as a diff --git a/cmd/ctr/commands/shim/shim.go b/cmd/ctr/commands/shim/shim.go index 5aa703643..793dc3c9e 100644 --- a/cmd/ctr/commands/shim/shim.go +++ b/cmd/ctr/commands/shim/shim.go @@ -27,12 +27,12 @@ import ( "github.com/containerd/console" "github.com/containerd/containerd/cmd/ctr/commands" shim "github.com/containerd/containerd/runtime/shim/v1" + "github.com/containerd/ttrpc" "github.com/containerd/typeurl" ptypes "github.com/gogo/protobuf/types" "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/stevvooe/ttrpc" "github.com/urfave/cli" ) diff --git a/cmd/protoc-gen-gogoctrd/main.go b/cmd/protoc-gen-gogoctrd/main.go index 149469726..47c3f8a96 100644 --- a/cmd/protoc-gen-gogoctrd/main.go +++ b/cmd/protoc-gen-gogoctrd/main.go @@ -18,10 +18,10 @@ package main import ( _ "github.com/containerd/containerd/protobuf/plugin/fieldpath" + _ "github.com/containerd/ttrpc/plugin" "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" "github.com/gogo/protobuf/vanity" "github.com/gogo/protobuf/vanity/command" - _ "github.com/stevvooe/ttrpc/plugin" ) func main() { diff --git a/runtime/linux/process.go b/runtime/linux/process.go index a8a95db46..02cccd206 100644 --- a/runtime/linux/process.go +++ b/runtime/linux/process.go @@ -26,8 +26,8 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/runtime" shim "github.com/containerd/containerd/runtime/shim/v1" + "github.com/containerd/ttrpc" "github.com/pkg/errors" - "github.com/stevvooe/ttrpc" ) // Process implements a linux process diff --git a/runtime/linux/task.go b/runtime/linux/task.go index d19090a72..43c93eaba 100644 --- a/runtime/linux/task.go +++ b/runtime/linux/task.go @@ -32,9 +32,9 @@ import ( "github.com/containerd/containerd/runtime/shim/client" shim "github.com/containerd/containerd/runtime/shim/v1" runc "github.com/containerd/go-runc" + "github.com/containerd/ttrpc" "github.com/gogo/protobuf/types" "github.com/pkg/errors" - "github.com/stevvooe/ttrpc" ) // Task on a linux based system diff --git a/runtime/shim/client/client.go b/runtime/shim/client/client.go index e46d6df3a..009ccc939 100644 --- a/runtime/shim/client/client.go +++ b/runtime/shim/client/client.go @@ -31,9 +31,9 @@ import ( "golang.org/x/sys/unix" + "github.com/containerd/ttrpc" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/stevvooe/ttrpc" "github.com/containerd/containerd/events" "github.com/containerd/containerd/log" diff --git a/runtime/shim/v1/shim.pb.go b/runtime/shim/v1/shim.pb.go index a357fd367..e4dae343d 100644 --- a/runtime/shim/v1/shim.pb.go +++ b/runtime/shim/v1/shim.pb.go @@ -50,7 +50,7 @@ import strings "strings" import reflect "reflect" import context "context" -import ttrpc "github.com/stevvooe/ttrpc" +import ttrpc "github.com/containerd/ttrpc" import io "io" diff --git a/vendor.conf b/vendor.conf index 2e100c161..7d655555c 100644 --- a/vendor.conf +++ b/vendor.conf @@ -37,7 +37,7 @@ github.com/Microsoft/hcsshim v0.6.11 github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4 -github.com/stevvooe/ttrpc d4528379866b0ce7e9d71f3eb96f0582fc374577 +github.com/containerd/ttrpc fa6c68143601db58b3636ee9948aad2fe08ed1ea github.com/syndtr/gocapability db04d3cc01c8b54962a58ec7e491717d06cfcc16 gotest.tools v2.1.0 github.com/google/go-cmp v0.1.0 diff --git a/vendor/github.com/stevvooe/ttrpc/LICENSE b/vendor/github.com/containerd/ttrpc/LICENSE similarity index 100% rename from vendor/github.com/stevvooe/ttrpc/LICENSE rename to vendor/github.com/containerd/ttrpc/LICENSE diff --git a/vendor/github.com/stevvooe/ttrpc/README.md b/vendor/github.com/containerd/ttrpc/README.md similarity index 90% rename from vendor/github.com/stevvooe/ttrpc/README.md rename to vendor/github.com/containerd/ttrpc/README.md index b246e578b..d1eed6b12 100644 --- a/vendor/github.com/stevvooe/ttrpc/README.md +++ b/vendor/github.com/containerd/ttrpc/README.md @@ -1,6 +1,6 @@ # ttrpc -[![Build Status](https://travis-ci.org/stevvooe/ttrpc.svg?branch=master)](https://travis-ci.org/stevvooe/ttrpc) +[![Build Status](https://travis-ci.org/containerd/ttrpc.svg?branch=master)](https://travis-ci.org/containerd/ttrpc) GRPC for low-memory environments. @@ -25,7 +25,7 @@ Create a gogo vanity binary (see [`cmd/protoc-gen-gogottrpc/main.go`](cmd/protoc-gen-gogottrpc/main.go) for an example with the ttrpc plugin enabled. -It's recommended to use [`protobuild`](https://github.com/stevvooe/protobuild) +It's recommended to use [`protobuild`](https://github.com//stevvooe/protobuild) to build the protobufs for this project, but this will work with protoc directly, if required. diff --git a/vendor/github.com/stevvooe/ttrpc/channel.go b/vendor/github.com/containerd/ttrpc/channel.go similarity index 85% rename from vendor/github.com/stevvooe/ttrpc/channel.go rename to vendor/github.com/containerd/ttrpc/channel.go index 9493d6862..22f5496b4 100644 --- a/vendor/github.com/stevvooe/ttrpc/channel.go +++ b/vendor/github.com/containerd/ttrpc/channel.go @@ -1,3 +1,19 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + package ttrpc import ( diff --git a/vendor/github.com/stevvooe/ttrpc/client.go b/vendor/github.com/containerd/ttrpc/client.go similarity index 87% rename from vendor/github.com/stevvooe/ttrpc/client.go rename to vendor/github.com/containerd/ttrpc/client.go index f04718167..ede2e6b74 100644 --- a/vendor/github.com/stevvooe/ttrpc/client.go +++ b/vendor/github.com/containerd/ttrpc/client.go @@ -1,3 +1,19 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + package ttrpc import ( @@ -9,9 +25,9 @@ import ( "sync" "syscall" - "github.com/containerd/containerd/log" "github.com/gogo/protobuf/proto" "github.com/pkg/errors" + "github.com/sirupsen/logrus" "google.golang.org/grpc/status" ) @@ -180,7 +196,7 @@ func (c *Client) run() { case msg := <-incoming: call, ok := waiters[msg.StreamID] if !ok { - log.L.Errorf("ttrpc: received message for unknown channel %v", msg.StreamID) + logrus.Errorf("ttrpc: received message for unknown channel %v", msg.StreamID) continue } diff --git a/vendor/github.com/containerd/ttrpc/codec.go b/vendor/github.com/containerd/ttrpc/codec.go new file mode 100644 index 000000000..b4aac2fac --- /dev/null +++ b/vendor/github.com/containerd/ttrpc/codec.go @@ -0,0 +1,42 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package ttrpc + +import ( + "github.com/gogo/protobuf/proto" + "github.com/pkg/errors" +) + +type codec struct{} + +func (c codec) Marshal(msg interface{}) ([]byte, error) { + switch v := msg.(type) { + case proto.Message: + return proto.Marshal(v) + default: + return nil, errors.Errorf("ttrpc: cannot marshal unknown type: %T", msg) + } +} + +func (c codec) Unmarshal(p []byte, msg interface{}) error { + switch v := msg.(type) { + case proto.Message: + return proto.Unmarshal(p, v) + default: + return errors.Errorf("ttrpc: cannot unmarshal into unknown type: %T", msg) + } +} diff --git a/vendor/github.com/containerd/ttrpc/config.go b/vendor/github.com/containerd/ttrpc/config.go new file mode 100644 index 000000000..019b7a09d --- /dev/null +++ b/vendor/github.com/containerd/ttrpc/config.go @@ -0,0 +1,39 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package ttrpc + +import "github.com/pkg/errors" + +type serverConfig struct { + handshaker Handshaker +} + +type ServerOpt func(*serverConfig) error + +// WithServerHandshaker can be passed to NewServer to ensure that the +// handshaker is called before every connection attempt. +// +// Only one handshaker is allowed per server. +func WithServerHandshaker(handshaker Handshaker) ServerOpt { + return func(c *serverConfig) error { + if c.handshaker != nil { + return errors.New("only one handshaker allowed per server") + } + c.handshaker = handshaker + return nil + } +} diff --git a/vendor/github.com/stevvooe/ttrpc/handshake.go b/vendor/github.com/containerd/ttrpc/handshake.go similarity index 65% rename from vendor/github.com/stevvooe/ttrpc/handshake.go rename to vendor/github.com/containerd/ttrpc/handshake.go index a08ae8ee4..a424b67a4 100644 --- a/vendor/github.com/stevvooe/ttrpc/handshake.go +++ b/vendor/github.com/containerd/ttrpc/handshake.go @@ -1,3 +1,19 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + package ttrpc import ( diff --git a/vendor/github.com/stevvooe/ttrpc/plugin/generator.go b/vendor/github.com/containerd/ttrpc/plugin/generator.go similarity index 83% rename from vendor/github.com/stevvooe/ttrpc/plugin/generator.go rename to vendor/github.com/containerd/ttrpc/plugin/generator.go index 5603e57f4..0900386d6 100644 --- a/vendor/github.com/stevvooe/ttrpc/plugin/generator.go +++ b/vendor/github.com/containerd/ttrpc/plugin/generator.go @@ -1,3 +1,19 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + package plugin import ( @@ -32,7 +48,7 @@ func (p *ttrpcGenerator) Generate(file *generator.FileDescriptor) { p.PluginImports = generator.NewPluginImports(p.Generator) p.contextPkg = p.NewImport("context") p.typeurlPkg = p.NewImport("github.com/containerd/typeurl") - p.ttrpcPkg = p.NewImport("github.com/stevvooe/ttrpc") + p.ttrpcPkg = p.NewImport("github.com/containerd/ttrpc") for _, service := range file.GetService() { serviceName := service.GetName() diff --git a/vendor/github.com/stevvooe/ttrpc/server.go b/vendor/github.com/containerd/ttrpc/server.go similarity index 89% rename from vendor/github.com/stevvooe/ttrpc/server.go rename to vendor/github.com/containerd/ttrpc/server.go index fd29b719e..3797a09f8 100644 --- a/vendor/github.com/stevvooe/ttrpc/server.go +++ b/vendor/github.com/containerd/ttrpc/server.go @@ -1,3 +1,19 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + package ttrpc import ( @@ -9,8 +25,8 @@ import ( "sync/atomic" "time" - "github.com/containerd/containerd/log" "github.com/pkg/errors" + "github.com/sirupsen/logrus" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -88,7 +104,7 @@ func (s *Server) Serve(l net.Listener) error { } sleep := time.Duration(rand.Int63n(int64(backoff))) - log.L.WithError(err).Errorf("ttrpc: failed accept; backoff %v", sleep) + logrus.WithError(err).Errorf("ttrpc: failed accept; backoff %v", sleep) time.Sleep(sleep) continue } @@ -100,7 +116,7 @@ func (s *Server) Serve(l net.Listener) error { approved, handshake, err := handshaker.Handshake(ctx, conn) if err != nil { - log.L.WithError(err).Errorf("ttrpc: refusing connection after handshake") + logrus.WithError(err).Errorf("ttrpc: refusing connection after handshake") conn.Close() continue } @@ -416,12 +432,12 @@ func (c *serverConn) run(sctx context.Context) { case response := <-responses: p, err := c.server.codec.Marshal(response.resp) if err != nil { - log.L.WithError(err).Error("failed marshaling response") + logrus.WithError(err).Error("failed marshaling response") return } if err := ch.send(ctx, response.id, messageTypeResponse, p); err != nil { - log.L.WithError(err).Error("failed sending message on channel") + logrus.WithError(err).Error("failed sending message on channel") return } @@ -432,7 +448,7 @@ func (c *serverConn) run(sctx context.Context) { // requests due to a terminal error. recvErr = nil // connection is now "closing" if err != nil && err != io.EOF { - log.L.WithError(err).Error("error receiving message") + logrus.WithError(err).Error("error receiving message") } case <-shutdown: return diff --git a/vendor/github.com/stevvooe/ttrpc/services.go b/vendor/github.com/containerd/ttrpc/services.go similarity index 84% rename from vendor/github.com/stevvooe/ttrpc/services.go rename to vendor/github.com/containerd/ttrpc/services.go index b9a749e3d..e90963825 100644 --- a/vendor/github.com/stevvooe/ttrpc/services.go +++ b/vendor/github.com/containerd/ttrpc/services.go @@ -1,3 +1,19 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + package ttrpc import ( diff --git a/vendor/github.com/stevvooe/ttrpc/types.go b/vendor/github.com/containerd/ttrpc/types.go similarity index 56% rename from vendor/github.com/stevvooe/ttrpc/types.go rename to vendor/github.com/containerd/ttrpc/types.go index a522b0cf2..1f7969e5c 100644 --- a/vendor/github.com/stevvooe/ttrpc/types.go +++ b/vendor/github.com/containerd/ttrpc/types.go @@ -1,3 +1,19 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + package ttrpc import ( diff --git a/vendor/github.com/stevvooe/ttrpc/unixcreds_linux.go b/vendor/github.com/containerd/ttrpc/unixcreds_linux.go similarity index 82% rename from vendor/github.com/stevvooe/ttrpc/unixcreds_linux.go rename to vendor/github.com/containerd/ttrpc/unixcreds_linux.go index 812d927dc..a471bd365 100644 --- a/vendor/github.com/stevvooe/ttrpc/unixcreds_linux.go +++ b/vendor/github.com/containerd/ttrpc/unixcreds_linux.go @@ -1,3 +1,19 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + package ttrpc import ( diff --git a/vendor/github.com/stevvooe/ttrpc/codec.go b/vendor/github.com/stevvooe/ttrpc/codec.go deleted file mode 100644 index 7956a7222..000000000 --- a/vendor/github.com/stevvooe/ttrpc/codec.go +++ /dev/null @@ -1,26 +0,0 @@ -package ttrpc - -import ( - "github.com/gogo/protobuf/proto" - "github.com/pkg/errors" -) - -type codec struct{} - -func (c codec) Marshal(msg interface{}) ([]byte, error) { - switch v := msg.(type) { - case proto.Message: - return proto.Marshal(v) - default: - return nil, errors.Errorf("ttrpc: cannot marshal unknown type: %T", msg) - } -} - -func (c codec) Unmarshal(p []byte, msg interface{}) error { - switch v := msg.(type) { - case proto.Message: - return proto.Unmarshal(p, v) - default: - return errors.Errorf("ttrpc: cannot unmarshal into unknown type: %T", msg) - } -} diff --git a/vendor/github.com/stevvooe/ttrpc/config.go b/vendor/github.com/stevvooe/ttrpc/config.go deleted file mode 100644 index 23bc603a3..000000000 --- a/vendor/github.com/stevvooe/ttrpc/config.go +++ /dev/null @@ -1,23 +0,0 @@ -package ttrpc - -import "github.com/pkg/errors" - -type serverConfig struct { - handshaker Handshaker -} - -type ServerOpt func(*serverConfig) error - -// WithServerHandshaker can be passed to NewServer to ensure that the -// handshaker is called before every connection attempt. -// -// Only one handshaker is allowed per server. -func WithServerHandshaker(handshaker Handshaker) ServerOpt { - return func(c *serverConfig) error { - if c.handshaker != nil { - return errors.New("only one handshaker allowed per server") - } - c.handshaker = handshaker - return nil - } -}