From 85a3d9c402f3f8c057bbcffc9acd850d21d9a449 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:07:15 -0600 Subject: [PATCH 1/2] omit the github.com/pkg/profile library and code which relies on it temporarily - fails to compile on go 1.19 --- go.mod | 1 - go.sum | 2 - pkg/visor/etc.go | 10 +- pkg/visor/visor.go | 5 +- vendor/github.com/godbus/dbus/v5/conn.go | 2 +- vendor/github.com/pkg/profile/.travis.yml | 9 - vendor/github.com/pkg/profile/AUTHORS | 1 - vendor/github.com/pkg/profile/LICENSE | 24 -- vendor/github.com/pkg/profile/README.md | 57 ---- vendor/github.com/pkg/profile/profile.go | 310 ---------------------- vendor/modules.txt | 3 - 11 files changed, 10 insertions(+), 414 deletions(-) delete mode 100644 vendor/github.com/pkg/profile/.travis.yml delete mode 100644 vendor/github.com/pkg/profile/AUTHORS delete mode 100644 vendor/github.com/pkg/profile/LICENSE delete mode 100644 vendor/github.com/pkg/profile/README.md delete mode 100644 vendor/github.com/pkg/profile/profile.go diff --git a/go.mod b/go.mod index fba8b9a29e..baa435b2a2 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/mattn/go-colorable v0.1.12 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/mmcloughlin/avo v0.0.0-20200523190732-4439b6b2c061 // indirect - github.com/pkg/profile v1.5.0 github.com/shirou/gopsutil/v3 v3.21.4 github.com/sirupsen/logrus v1.8.1 github.com/skycoin/skycoin v0.27.1 diff --git a/go.sum b/go.sum index 4bddc75a90..ea6ed6b768 100644 --- a/go.sum +++ b/go.sum @@ -459,8 +459,6 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.5.0 h1:042Buzk+NhDI+DeSAA62RwJL8VAuZUMQZUjCsRz1Mug= -github.com/pkg/profile v1.5.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/pkg/visor/etc.go b/pkg/visor/etc.go index 4d0c961f83..9ebd98d2f4 100644 --- a/pkg/visor/etc.go +++ b/pkg/visor/etc.go @@ -3,18 +3,19 @@ package visor import ( "fmt" - "net/http" - _ "net/http/pprof" // nolint:gosec // https://golang.org/doc/diagnostics.html#profiling "os" - "time" - "github.com/pkg/profile" "github.com/spf13/cobra" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/logging" ) +/* +// "net/http" +// "time" +// _ "net/http/pprof" // nolint:gosec // https://golang.org/doc/diagnostics.html#profiling +//"github.com/pkg/profile" NOT WORKING WITH GO 1.19 func initPProf(log *logging.MasterLogger, profMode string, profAddr string) (stop func()) { var optFunc func(*profile.Profile) @@ -55,6 +56,7 @@ func initPProf(log *logging.MasterLogger, profMode string, profAddr string) (sto } return stop } +*/ func logBuildInfo(mLog *logging.MasterLogger) { log := mLog.PackageLogger("buildinfo") diff --git a/pkg/visor/visor.go b/pkg/visor/visor.go index 8b2c83e91c..ff1a926105 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -152,8 +152,9 @@ func run(conf *visorconfig.V1) error { store, hook := logstore.MakeStore(runtimeLogMaxEntries) mLog.AddHook(hook) - stopPProf := initPProf(mLog, pprofMode, pprofAddr) - defer stopPProf() +//commented out pending fixes for go 1.19 + //stopPProf := initPProf(mLog, pprofMode, pprofAddr) + //defer stopPProf() if conf == nil { conf = initConfig() diff --git a/vendor/github.com/godbus/dbus/v5/conn.go b/vendor/github.com/godbus/dbus/v5/conn.go index 8080f3e918..69978ea26a 100644 --- a/vendor/github.com/godbus/dbus/v5/conn.go +++ b/vendor/github.com/godbus/dbus/v5/conn.go @@ -432,7 +432,7 @@ func (conn *Conn) inWorker() { case TypeSignal: conn.handleSignal(sequence, msg) case TypeMethodCall: -conn.handleCall(msg) + go conn.handleCall(msg) } } diff --git a/vendor/github.com/pkg/profile/.travis.yml b/vendor/github.com/pkg/profile/.travis.yml deleted file mode 100644 index 0b895c9849..0000000000 --- a/vendor/github.com/pkg/profile/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go -go_import_path: github.com/pkg/profile -go: - - 1.13.x - - 1.14.x - - tip - -script: - - go test -race github.com/pkg/profile diff --git a/vendor/github.com/pkg/profile/AUTHORS b/vendor/github.com/pkg/profile/AUTHORS deleted file mode 100644 index 00441d354b..0000000000 --- a/vendor/github.com/pkg/profile/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Dave Cheney diff --git a/vendor/github.com/pkg/profile/LICENSE b/vendor/github.com/pkg/profile/LICENSE deleted file mode 100644 index f747a8411e..0000000000 --- a/vendor/github.com/pkg/profile/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2013 Dave Cheney. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pkg/profile/README.md b/vendor/github.com/pkg/profile/README.md deleted file mode 100644 index 8bae598267..0000000000 --- a/vendor/github.com/pkg/profile/README.md +++ /dev/null @@ -1,57 +0,0 @@ -profile -======= - -Simple profiling support package for Go - -[![Build Status](https://travis-ci.org/pkg/profile.svg?branch=master)](https://travis-ci.org/pkg/profile) [![GoDoc](http://godoc.org/github.com/pkg/profile?status.svg)](http://godoc.org/github.com/pkg/profile) - - -installation ------------- - - go get github.com/pkg/profile - -usage ------ - -Enabling profiling in your application is as simple as one line at the top of your main function - -```go -import "github.com/pkg/profile" - -func main() { - defer profile.Start().Stop() - ... -} -``` - -options -------- - -What to profile is controlled by config value passed to profile.Start. -By default CPU profiling is enabled. - -```go -import "github.com/pkg/profile" - -func main() { - // p.Stop() must be called before the program exits to - // ensure profiling information is written to disk. - p := profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook) - ... - // You can enable different kinds of memory profiling, either Heap or Allocs where Heap - // profiling is the default with profile.MemProfile. - p := profile.Start(profile.MemProfileAllocs, profile.ProfilePath("."), profile.NoShutdownHook) -} -``` - -Several convenience package level values are provided for cpu, memory, and block (contention) profiling. - -For more complex options, consult the [documentation](http://godoc.org/github.com/pkg/profile). - -contributing ------------- - -We welcome pull requests, bug fixes and issue reports. - -Before proposing a change, please discuss it first by raising an issue. diff --git a/vendor/github.com/pkg/profile/profile.go b/vendor/github.com/pkg/profile/profile.go deleted file mode 100644 index bc3a0d61fb..0000000000 --- a/vendor/github.com/pkg/profile/profile.go +++ /dev/null @@ -1,310 +0,0 @@ -// Package profile provides a simple way to manage runtime/pprof -// profiling of your Go application. -package profile - -import ( - "io/ioutil" - "log" - "os" - "os/signal" - "path/filepath" - "runtime" - "runtime/pprof" - "runtime/trace" - "sync/atomic" -) - -const ( - cpuMode = iota - memMode - mutexMode - blockMode - traceMode - threadCreateMode - goroutineMode -) - -// Profile represents an active profiling session. -type Profile struct { - // quiet suppresses informational messages during profiling. - quiet bool - - // noShutdownHook controls whether the profiling package should - // hook SIGINT to write profiles cleanly. - noShutdownHook bool - - // mode holds the type of profiling that will be made - mode int - - // path holds the base path where various profiling files are written. - // If blank, the base path will be generated by ioutil.TempDir. - path string - - // memProfileRate holds the rate for the memory profile. - memProfileRate int - - // memProfileType holds the profile type for memory - // profiles. Allowed values are `heap` and `allocs`. - memProfileType string - - // closer holds a cleanup function that run after each profile - closer func() - - // stopped records if a call to profile.Stop has been made - stopped uint32 -} - -// NoShutdownHook controls whether the profiling package should -// hook SIGINT to write profiles cleanly. -// Programs with more sophisticated signal handling should set -// this to true and ensure the Stop() function returned from Start() -// is called during shutdown. -func NoShutdownHook(p *Profile) { p.noShutdownHook = true } - -// Quiet suppresses informational messages during profiling. -func Quiet(p *Profile) { p.quiet = true } - -// CPUProfile enables cpu profiling. -// It disables any previous profiling settings. -func CPUProfile(p *Profile) { p.mode = cpuMode } - -// DefaultMemProfileRate is the default memory profiling rate. -// See also http://golang.org/pkg/runtime/#pkg-variables -const DefaultMemProfileRate = 4096 - -// MemProfile enables memory profiling. -// It disables any previous profiling settings. -func MemProfile(p *Profile) { - p.memProfileRate = DefaultMemProfileRate - p.mode = memMode -} - -// MemProfileRate enables memory profiling at the preferred rate. -// It disables any previous profiling settings. -func MemProfileRate(rate int) func(*Profile) { - return func(p *Profile) { - p.memProfileRate = rate - p.mode = memMode - } -} - -// MemProfileHeap changes which type of memory profiling to profile -// the heap. -func MemProfileHeap() func(*Profile) { - return func(p *Profile) { - p.memProfileType = "heap" - p.mode = memMode - } -} - -// MemProfileAllocs changes which type of memory to profile -// allocations. -func MemProfileAllocs() func(*Profile) { - return func(p *Profile) { - p.memProfileType = "allocs" - p.mode = memMode - } -} - -// MutexProfile enables mutex profiling. -// It disables any previous profiling settings. -func MutexProfile(p *Profile) { p.mode = mutexMode } - -// BlockProfile enables block (contention) profiling. -// It disables any previous profiling settings. -func BlockProfile(p *Profile) { p.mode = blockMode } - -// Trace profile enables execution tracing. -// It disables any previous profiling settings. -func TraceProfile(p *Profile) { p.mode = traceMode } - -// ThreadcreationProfile enables thread creation profiling.. -// It disables any previous profiling settings. -func ThreadcreationProfile(p *Profile) { p.mode = threadCreateMode } - -// GoroutineProfile enables goroutine profiling. -// It disables any previous profiling settings. -func GoroutineProfile(p *Profile) { p.mode = goroutineMode } - -// ProfilePath controls the base path where various profiling -// files are written. If blank, the base path will be generated -// by ioutil.TempDir. -func ProfilePath(path string) func(*Profile) { - return func(p *Profile) { - p.path = path - } -} - -// Stop stops the profile and flushes any unwritten data. -func (p *Profile) Stop() { - if !atomic.CompareAndSwapUint32(&p.stopped, 0, 1) { - // someone has already called close - return - } - p.closer() - atomic.StoreUint32(&started, 0) -} - -// started is non zero if a profile is running. -var started uint32 - -// Start starts a new profiling session. -// The caller should call the Stop method on the value returned -// to cleanly stop profiling. -func Start(options ...func(*Profile)) interface { - Stop() -} { - if !atomic.CompareAndSwapUint32(&started, 0, 1) { - log.Fatal("profile: Start() already called") - } - - var prof Profile - for _, option := range options { - option(&prof) - } - - path, err := func() (string, error) { - if p := prof.path; p != "" { - return p, os.MkdirAll(p, 0777) - } - return ioutil.TempDir("", "profile") - }() - - if err != nil { - log.Fatalf("profile: could not create initial output directory: %v", err) - } - - logf := func(format string, args ...interface{}) { - if !prof.quiet { - log.Printf(format, args...) - } - } - - if prof.memProfileType == "" { - prof.memProfileType = "heap" - } - - switch prof.mode { - case cpuMode: - fn := filepath.Join(path, "cpu.pprof") - f, err := os.Create(fn) - if err != nil { - log.Fatalf("profile: could not create cpu profile %q: %v", fn, err) - } - logf("profile: cpu profiling enabled, %s", fn) - pprof.StartCPUProfile(f) - prof.closer = func() { - pprof.StopCPUProfile() - f.Close() - logf("profile: cpu profiling disabled, %s", fn) - } - - case memMode: - fn := filepath.Join(path, "mem.pprof") - f, err := os.Create(fn) - if err != nil { - log.Fatalf("profile: could not create memory profile %q: %v", fn, err) - } - old := runtime.MemProfileRate - runtime.MemProfileRate = prof.memProfileRate - logf("profile: memory profiling enabled (rate %d), %s", runtime.MemProfileRate, fn) - prof.closer = func() { - pprof.Lookup(prof.memProfileType).WriteTo(f, 0) - f.Close() - runtime.MemProfileRate = old - logf("profile: memory profiling disabled, %s", fn) - } - - case mutexMode: - fn := filepath.Join(path, "mutex.pprof") - f, err := os.Create(fn) - if err != nil { - log.Fatalf("profile: could not create mutex profile %q: %v", fn, err) - } - runtime.SetMutexProfileFraction(1) - logf("profile: mutex profiling enabled, %s", fn) - prof.closer = func() { - if mp := pprof.Lookup("mutex"); mp != nil { - mp.WriteTo(f, 0) - } - f.Close() - runtime.SetMutexProfileFraction(0) - logf("profile: mutex profiling disabled, %s", fn) - } - - case blockMode: - fn := filepath.Join(path, "block.pprof") - f, err := os.Create(fn) - if err != nil { - log.Fatalf("profile: could not create block profile %q: %v", fn, err) - } - runtime.SetBlockProfileRate(1) - logf("profile: block profiling enabled, %s", fn) - prof.closer = func() { - pprof.Lookup("block").WriteTo(f, 0) - f.Close() - runtime.SetBlockProfileRate(0) - logf("profile: block profiling disabled, %s", fn) - } - - case threadCreateMode: - fn := filepath.Join(path, "threadcreation.pprof") - f, err := os.Create(fn) - if err != nil { - log.Fatalf("profile: could not create thread creation profile %q: %v", fn, err) - } - logf("profile: thread creation profiling enabled, %s", fn) - prof.closer = func() { - if mp := pprof.Lookup("threadcreate"); mp != nil { - mp.WriteTo(f, 0) - } - f.Close() - logf("profile: thread creation profiling disabled, %s", fn) - } - - case traceMode: - fn := filepath.Join(path, "trace.out") - f, err := os.Create(fn) - if err != nil { - log.Fatalf("profile: could not create trace output file %q: %v", fn, err) - } - if err := trace.Start(f); err != nil { - log.Fatalf("profile: could not start trace: %v", err) - } - logf("profile: trace enabled, %s", fn) - prof.closer = func() { - trace.Stop() - logf("profile: trace disabled, %s", fn) - } - - case goroutineMode: - fn := filepath.Join(path, "goroutine.pprof") - f, err := os.Create(fn) - if err != nil { - log.Fatalf("profile: could not create goroutine profile %q: %v", fn, err) - } - logf("profile: goroutine profiling enabled, %s", fn) - prof.closer = func() { - if mp := pprof.Lookup("goroutine"); mp != nil { - mp.WriteTo(f, 0) - } - f.Close() - logf("profile: goroutine profiling disabled, %s", fn) - } - } - - if !prof.noShutdownHook { - go func() { - c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt) - <-c - - log.Println("profile: caught interrupt, stopping profiles") - prof.Stop() - - os.Exit(0) - }() - } - - return &prof -} diff --git a/vendor/modules.txt b/vendor/modules.txt index e36be869c5..4651aa6567 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -184,9 +184,6 @@ github.com/modern-go/reflect2 # github.com/pkg/errors v0.9.1 ## explicit github.com/pkg/errors -# github.com/pkg/profile v1.5.0 -## explicit; go 1.13 -github.com/pkg/profile # github.com/pmezard/go-difflib v1.0.0 ## explicit github.com/pmezard/go-difflib/difflib From 32fc064b2b4342fe3e27b53865fd304eb4993c7f Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:13:32 -0600 Subject: [PATCH 2/2] fix goimports errors --- pkg/visor/visor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/visor/visor.go b/pkg/visor/visor.go index ff1a926105..aad26c92ae 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -152,7 +152,7 @@ func run(conf *visorconfig.V1) error { store, hook := logstore.MakeStore(runtimeLogMaxEntries) mLog.AddHook(hook) -//commented out pending fixes for go 1.19 + //commented out pending fixes for go 1.19 //stopPProf := initPProf(mLog, pprofMode, pprofAddr) //defer stopPProf()