diff --git a/Gopkg.lock b/Gopkg.lock index 34c1a8c..47beefc 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -135,7 +135,7 @@ version = "v1.0.0" [[projects]] - digest = "1:d10c307caccb4aa5fa266259a57f5aace08b1c2d593428a9b588da0ada57e6d3" + digest = "1:20cbe272327eabe7f842ccaa7ffa69cbb118713df02822bbd60efad295694876" name = "github.com/go-delve/delve" packages = [ "pkg/dwarf/frame", @@ -149,6 +149,7 @@ "pkg/proc", "pkg/proc/core", "pkg/proc/core/minidump", + "pkg/proc/fbsdutil", "pkg/proc/gdbserial", "pkg/proc/linutil", "pkg/proc/native", @@ -159,11 +160,11 @@ "service/rpc1", ] pruneopts = "" - revision = "86d4b0b9915d55833a99bfb4c8b3a138f03ab802" - version = "v1.2.0" + revision = "dd3c2d63cc5b2aa84d7970eca0c91b45c71e9dd9" + version = "v1.3.1" [[projects]] - digest = "1:fd53b471edb4c28c7d297f617f4da0d33402755f58d6301e7ca1197ef0a90937" + digest = "1:8a7fe65e9ac2612c4df602cc9f014a92406776d993ff0f28335e5a8831d87c53" name = "github.com/gogo/protobuf" packages = [ "gogoproto", @@ -175,8 +176,8 @@ "types", ] pruneopts = "" - revision = "ba06b47c162d49f2af050fb4c75bcbc86a159d5c" - version = "v1.2.1" + revision = "0ca988a254f991240804bf9821f3450d87ccbb1b" + version = "v1.3.0" [[projects]] branch = "master" @@ -516,14 +517,6 @@ revision = "f55edac94c9bbba5d6182a4be46d86a2c9b5b50e" version = "v1.0.2" -[[projects]] - digest = "1:3e2fbf3f6d30c4c009be006f9d2a9eaefc804d8f6b991e88cb793b87318cc5bc" - name = "github.com/kr/pty" - packages = ["."] - pruneopts = "" - revision = "24b51915630e1d9d3c6adf15a3a96796bbc3cd43" - version = "v1.1.8" - [[projects]] digest = "1:ae39921edb7f801f7ce1b6b5484f9715a1dd2b52cb645daef095cd10fd6ee774" name = "github.com/magiconair/properties" @@ -766,7 +759,7 @@ version = "0.0.4" [[projects]] - digest = "1:329ae39b5196ac3042376a2bbddb16429cbfb5745706844c93f22b961191cffc" + digest = "1:e17b8df89bbba50273bb1ce185d0ec0eee9524869a2286a37bc77c5d54cf6521" name = "github.com/solo-io/go-utils" packages = [ "changelogutils", @@ -797,11 +790,11 @@ "vfsutils", ] pruneopts = "" - revision = "e5ce38a2654b9eb22951d058fb229fc7e7c9196c" - version = "v0.9.10" + revision = "71704af17a52b1dce01b6bb8bcab447f59e59f07" + version = "v0.9.17" [[projects]] - digest = "1:bc915870e191aff24a90ddeae4dbff7e97cc18ed63dd49b2110ff31f59e293de" + digest = "1:67ff7cabcba41f4ee95ab7f849a8ee619b56647d58ff0c0d8db1fbb3bac8867b" name = "github.com/solo-io/solo-kit" packages = [ "pkg/api/v1/clients", @@ -847,8 +840,8 @@ "test/testutils", ] pruneopts = "" - revision = "472cb6e323551e434ee67cdd9e823c82d8c25925" - version = "v0.10.4" + revision = "6172b86a18792f91c5323a624db93b8d8efbccb9" + version = "v0.10.10" [[projects]] digest = "1:956f655c87b7255c6b1ae6c203ebb0af98cf2a13ef2507e34c9bf1c0332ac0f5" @@ -1661,13 +1654,13 @@ analyzer-version = 1 input-imports = [ "github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubernetes", + "github.com/creack/pty", "github.com/davecgh/go-spew/spew", "github.com/go-delve/delve/service/rpc1", "github.com/gogo/protobuf/gogoproto", "github.com/gogo/protobuf/proto", "github.com/gogo/protobuf/sortkeys", "github.com/hashicorp/go-multierror", - "github.com/kr/pty", "github.com/mitchellh/go-homedir", "github.com/onsi/ginkgo", "github.com/onsi/gomega", diff --git a/Gopkg.toml b/Gopkg.toml index 4ee13ff..89ffcc5 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -21,6 +21,14 @@ # version = "2.4.0" +[[constraint]] + version = "1.3.0" + name = "github.com/gogo/protobuf" + +[[override]] + version = "1.3.1" + name = "github.com/golang/protobuf" + [[constraint]] branch = "master" name = "github.com/spf13/cobra" @@ -31,7 +39,7 @@ [[constraint]] name = "github.com/go-delve/delve" - version = "1.2.0" + version = "1.3.0" [[constraint]] name = "github.com/davecgh/go-spew" @@ -55,11 +63,11 @@ [[constraint]] name = "github.com/solo-io/solo-kit" - version = "0.10.0" + version = "0.10.10" [[constraint]] name = "github.com/solo-io/go-utils" - version = "0.9.10" + version = "0.9.17" [[constraint]] name = "github.com/solo-io/build" @@ -77,11 +85,6 @@ name = "gopkg.in/fsnotify.v1" source = "https://github.com/fsnotify/fsnotify.git" -[[override]] - name = "github.com/lyft/protoc-gen-validate" - version = "0.0.6" - source = "github.com/envoyproxy/protoc-gen-validate" - # make sure all kubernetes code is the same version. # when updating, update all in the same time. diff --git a/changelog/v0.5.19/go-util.yaml b/changelog/v0.5.19/go-util.yaml new file mode 100644 index 0000000..f404ff6 --- /dev/null +++ b/changelog/v0.5.19/go-util.yaml @@ -0,0 +1,14 @@ +changelog: + - dependencyOwner: solo-io + dependencyRepo: go-utils + dependencyTag: v0.9.17 + description: Update go-util to version v0.9.17. + type: DEPENDENCY_BUMP + - dependencyOwner: solo-io + dependencyRepo: solo-kit + dependencyTag: v0.10.10 + description: Update solo-kit to version v0.10.10. + type: DEPENDENCY_BUMP + - type: FIX + description: Fix timing issue to allow local dlv to connect to server. + issueLink: https://github:com/solo-io/squash/issues/237 diff --git a/cloudbuild.yaml b/cloudbuild.yaml index d9b7946..6143c82 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -43,7 +43,7 @@ steps: waitFor: ['dep'] - name: gcr.io/cloud-builders/gcloud - args: ['container', 'clusters', 'get-credentials', 'test-cluster'] + args: ['container', 'clusters', 'get-credentials', 'squash-test'] id: 'get-creds' waitFor: ['set-zone'] @@ -84,7 +84,7 @@ steps: - 'PROJECT_ROOT=github.com/solo-io/squash' - 'GOPATH=/workspace/gopath' - 'CLOUDSDK_COMPUTE_ZONE=us-central1-a' - - 'CLOUDSDK_CONTAINER_CLUSTER=test-cluster' + - 'CLOUDSDK_CONTAINER_CLUSTER=squash-test' - 'RUN_KUBE_TESTS=1' - 'TAGGED_VERSION=$TAG_NAME' - 'BUILD_ID=$BUILD_ID' diff --git a/pkg/api/v1/api_snapshot_emitter.sk.go b/pkg/api/v1/api_snapshot_emitter.sk.go index 1ac884f..3ea5767 100644 --- a/pkg/api/v1/api_snapshot_emitter.sk.go +++ b/pkg/api/v1/api_snapshot_emitter.sk.go @@ -16,8 +16,9 @@ import ( ) var ( - mApiSnapshotIn = stats.Int64("api.squash.solo.io/snap_emitter/snap_in", "The number of snapshots in", "1") - mApiSnapshotOut = stats.Int64("api.squash.solo.io/snap_emitter/snap_out", "The number of snapshots out", "1") + mApiSnapshotIn = stats.Int64("api.squash.solo.io/snap_emitter/snap_in", "The number of snapshots in", "1") + mApiSnapshotOut = stats.Int64("api.squash.solo.io/snap_emitter/snap_out", "The number of snapshots out", "1") + mApiSnapshotMissed = stats.Int64("api.squash.solo.io/snap_emitter/snap_missed", "The number of snapshots missed", "1") apisnapshotInView = &view.View{ Name: "api.squash.solo.io_snap_emitter/snap_in", @@ -33,10 +34,17 @@ var ( Aggregation: view.Count(), TagKeys: []tag.Key{}, } + apisnapshotMissedView = &view.View{ + Name: "api.squash.solo.io/snap_emitter/snap_missed", + Measure: mApiSnapshotMissed, + Description: "The number of snapshots updates going missed. this can happen in heavy load. missed snapshot will be re-tried after a second.", + Aggregation: view.Count(), + TagKeys: []tag.Key{}, + } ) func init() { - view.Register(apisnapshotInView, apisnapshotOutView) + view.Register(apisnapshotInView, apisnapshotOutView, apisnapshotMissedView) } type ApiEmitter interface { @@ -95,8 +103,19 @@ func (c *apiEmitter) Snapshots(watchNamespaces []string, opts clients.WatchOpts) } debugAttachmentChan := make(chan debugAttachmentListWithNamespace) + var initialDebugAttachmentList DebugAttachmentList + + currentSnapshot := ApiSnapshot{} + for _, namespace := range watchNamespaces { /* Setup namespaced watch for DebugAttachment */ + { + debugattachments, err := c.debugAttachment.List(namespace, clients.ListOpts{Ctx: opts.Ctx, Selector: opts.Selector}) + if err != nil { + return nil, nil, errors.Wrapf(err, "initial DebugAttachment list") + } + initialDebugAttachmentList = append(initialDebugAttachmentList, debugattachments...) + } debugAttachmentNamespacesChan, debugAttachmentErrs, err := c.debugAttachment.Watch(namespace, opts) if err != nil { return nil, nil, errors.Wrapf(err, "starting DebugAttachment watch") @@ -124,21 +143,31 @@ func (c *apiEmitter) Snapshots(watchNamespaces []string, opts clients.WatchOpts) } }(namespace) } + /* Initialize snapshot for Debugattachments */ + currentSnapshot.Debugattachments = initialDebugAttachmentList.Sort() snapshots := make(chan *ApiSnapshot) go func() { - originalSnapshot := ApiSnapshot{} - currentSnapshot := originalSnapshot.Clone() + // sent initial snapshot to kick off the watch + initialSnapshot := currentSnapshot.Clone() + snapshots <- &initialSnapshot + timer := time.NewTicker(time.Second * 1) + var previousHash uint64 sync := func() { - if originalSnapshot.Hash() == currentSnapshot.Hash() { + currentHash := currentSnapshot.Hash() + if previousHash == currentHash { return } - stats.Record(ctx, mApiSnapshotOut.M(1)) - originalSnapshot = currentSnapshot.Clone() sentSnapshot := currentSnapshot.Clone() - snapshots <- &sentSnapshot + select { + case snapshots <- &sentSnapshot: + stats.Record(ctx, mApiSnapshotOut.M(1)) + previousHash = currentHash + default: + stats.Record(ctx, mApiSnapshotMissed.M(1)) + } } debugattachmentsByNamespace := make(map[string]DebugAttachmentList) diff --git a/pkg/api/v1/api_snapshot_simple_emitter.sk.go b/pkg/api/v1/api_snapshot_simple_emitter.sk.go index d9f7c73..54da391 100644 --- a/pkg/api/v1/api_snapshot_simple_emitter.sk.go +++ b/pkg/api/v1/api_snapshot_simple_emitter.sk.go @@ -45,16 +45,18 @@ func (c *apiSimpleEmitter) Snapshots(ctx context.Context) (<-chan *ApiSnapshot, go errutils.AggregateErrs(ctx, errs, watchErrs, "api-emitter") go func() { - originalSnapshot := ApiSnapshot{} - currentSnapshot := originalSnapshot.Clone() + currentSnapshot := ApiSnapshot{} timer := time.NewTicker(time.Second * 1) + var previousHash uint64 sync := func() { - if originalSnapshot.Hash() == currentSnapshot.Hash() { + currentHash := currentSnapshot.Hash() + if previousHash == currentHash { return } + previousHash = currentHash + stats.Record(ctx, mApiSnapshotOut.M(1)) - originalSnapshot = currentSnapshot.Clone() sentSnapshot := currentSnapshot.Clone() snapshots <- &sentSnapshot } diff --git a/pkg/api/v1/debug_attachment.pb.go b/pkg/api/v1/debug_attachment.pb.go index 86c2347..c9c2e28 100644 --- a/pkg/api/v1/debug_attachment.pb.go +++ b/pkg/api/v1/debug_attachment.pb.go @@ -22,7 +22,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type DebugAttachment_State int32 @@ -390,72 +390,14 @@ func (m *PortSpec) GetTarget() string { return "" } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*PortSpec) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _PortSpec_OneofMarshaler, _PortSpec_OneofUnmarshaler, _PortSpec_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*PortSpec) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*PortSpec_Plank)(nil), (*PortSpec_Target)(nil), } } -func _PortSpec_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*PortSpec) - // port_location - switch x := m.PortLocation.(type) { - case *PortSpec_Plank: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Plank) - case *PortSpec_Target: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Target) - case nil: - default: - return fmt.Errorf("PortSpec.PortLocation has unexpected type %T", x) - } - return nil -} - -func _PortSpec_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*PortSpec) - switch tag { - case 1: // port_location.plank - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.PortLocation = &PortSpec_Plank{x} - return true, err - case 2: // port_location.target - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.PortLocation = &PortSpec_Target{x} - return true, err - default: - return false, nil - } -} - -func _PortSpec_OneofSizer(msg proto.Message) (n int) { - m := msg.(*PortSpec) - // port_location - switch x := m.PortLocation.(type) { - case *PortSpec_Plank: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Plank))) - n += len(x.Plank) - case *PortSpec_Target: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Target))) - n += len(x.Target) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterEnum("squash.solo.io.DebugAttachment_State", DebugAttachment_State_name, DebugAttachment_State_value) proto.RegisterType((*DebugAttachment)(nil), "squash.solo.io.DebugAttachment") diff --git a/pkg/config/squash.go b/pkg/config/squash.go index 48ef75c..f22f923 100644 --- a/pkg/config/squash.go +++ b/pkg/config/squash.go @@ -196,7 +196,7 @@ func (s *Squash) connectUser(da *squashv1.DebugAttachment, remoteDbgPort int) er } dbgCmd := debugger.GetDebugCmd(s.LocalPort) - return s.callLocalDebuggerCommand(dbgCmd) + return dbgCmd.Run() } func (s *Squash) printEditorExtensionData(remoteDbgPort int) error { diff --git a/pkg/config/windows_false.go b/pkg/config/windows_false.go deleted file mode 100644 index 50e8f69..0000000 --- a/pkg/config/windows_false.go +++ /dev/null @@ -1,55 +0,0 @@ -// +build !windows - -package config - -import ( - "io" - "os" - "os/exec" - "os/signal" - "syscall" - - "github.com/kr/pty" - log "github.com/sirupsen/logrus" - "golang.org/x/crypto/ssh/terminal" -) - -func (s *Squash) callLocalDebuggerCommand(dbgCmd *exec.Cmd) error { - return ptyWrap(dbgCmd) -} - -func ptyWrap(c *exec.Cmd) error { - - // Start the command with a pty. - ptmx, err := pty.Start(c) - if err != nil { - return err - } - // Make sure to close the pty at the end. - defer func() { _ = ptmx.Close() }() // Best effort. - - // Handle pty size. - ch := make(chan os.Signal, 1) - signal.Notify(ch, syscall.SIGWINCH) - go func() { - for range ch { - if err := pty.InheritSize(os.Stdin, ptmx); err != nil { - log.Printf("error resizing pty: %s", err) - } - } - }() - ch <- syscall.SIGWINCH // Initial resize. - - // Set stdin in raw mode. - oldState, err := terminal.MakeRaw(int(os.Stdin.Fd())) - if err != nil { - panic(err) - } - defer func() { _ = terminal.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort. - - // Copy stdin to the pty and the pty to stdout. - go func() { _, _ = io.Copy(ptmx, os.Stdin) }() - _, _ = io.Copy(os.Stdout, ptmx) - - return nil -} diff --git a/pkg/config/windows_true.go b/pkg/config/windows_true.go deleted file mode 100644 index 17325e6..0000000 --- a/pkg/config/windows_true.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build windows - -package config - -import ( - "fmt" - "os/exec" - - "github.com/solo-io/squash/pkg/debuggers/local" -) - -// since dlv is proxied we are using a pseudoterminal to correctly handle -// control characters. However, the pseudoterminal we are using does not have -// a windows implementation. For now, skip connecting for windows users. -func (s *Squash) callLocalDebuggerCommand(dbgCmd *exec.Cmd) error { - debugger := local.GetParticularDebugger(s.Debugger) - if warning := debugger.WindowsSupportWarning(); warning != "" { - return fmt.Errorf(warning) - } - return dbgCmd.Run() -} diff --git a/pkg/platforms/kubernetes/alphav1/runtime.go b/pkg/platforms/kubernetes/alphav1/runtime.go index 9df3390..451f198 100644 --- a/pkg/platforms/kubernetes/alphav1/runtime.go +++ b/pkg/platforms/kubernetes/alphav1/runtime.go @@ -125,21 +125,27 @@ limitations under the License. */ package runtime -import proto "github.com/gogo/protobuf/proto" -import fmt "fmt" -import math "math" -import _ "github.com/gogo/protobuf/gogoproto" - import ( + fmt "fmt" + + proto "github.com/gogo/protobuf/proto" + + math "math" + + _ "github.com/gogo/protobuf/gogoproto" + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" -) -import strings "strings" -import reflect "reflect" -import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" + strings "strings" + + reflect "reflect" -import io "io" + github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" + + io "io" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal