diff --git a/.tool-versions b/.tool-versions index ad10f4f5bb..21e5c4e069 100644 --- a/.tool-versions +++ b/.tool-versions @@ -8,7 +8,7 @@ direnv 2.34.0 gcloud 473.0.0 ginkgo 2.20.0 golang 1.22.2 -golangci-lint 1.59.1 +golangci-lint 1.60.2 java temurin-21.0.3+9.0.LTS make 4.4 maven 3.8.6 diff --git a/devbox.json b/devbox.json index ca6c88335d..99171eb281 100644 --- a/devbox.json +++ b/devbox.json @@ -11,7 +11,6 @@ "bundix": "latest", "cloudfoundry-cli": "8.7.11", "coreutils": "latest", - "credhub-cli": "2.9.35", "delve": "latest", "direnv": "2.34.0", "fly": "7.10.0", @@ -20,7 +19,6 @@ "gnumake": "4.4", "gnutar": "latest", "go-tools": "latest", - "golangci-lint": "1.59.1", "gopls": "latest", "gum": "0.13.0", "jq": "latest", @@ -37,8 +35,10 @@ "swagger-cli": "latest", "which": "latest", "yq-go": "4.44.2", - "google-cloud-sdk": "latest", "go": "1.22.2", + "golangci-lint": "1.60.2", + "credhub-cli": "2.9.29", + "google-cloud-sdk": "latest", "temurin-bin-21": "latest", "ruby": "latest" }, diff --git a/devbox.lock b/devbox.lock index 047ab26bed..882ca01e24 100644 --- a/devbox.lock +++ b/devbox.lock @@ -313,51 +313,51 @@ } } }, - "credhub-cli@2.9.35": { - "last_modified": "2024-08-14T11:41:26Z", - "resolved": "github:NixOS/nixpkgs/0cb2fd7c59fed0cd82ef858cbcbdb552b9a33465#credhub-cli", + "credhub-cli@2.9.29": { + "last_modified": "2024-05-29T10:04:41Z", + "resolved": "github:NixOS/nixpkgs/ac82a513e55582291805d6f09d35b6d8b60637a1#credhub-cli", "source": "devbox-search", - "version": "2.9.35", + "version": "2.9.29", "systems": { "aarch64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/2xkv0vlafk8zgzjpz3yjagbgyv5kawkn-credhub-cli-2.9.35", + "path": "/nix/store/20xi78w44q6wn4847jrrlmxddyjycbrn-credhub-cli-2.9.29", "default": true } ], - "store_path": "/nix/store/2xkv0vlafk8zgzjpz3yjagbgyv5kawkn-credhub-cli-2.9.35" + "store_path": "/nix/store/20xi78w44q6wn4847jrrlmxddyjycbrn-credhub-cli-2.9.29" }, "aarch64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/r0kkggv2kbdma8l2n177nl0sw4lwvqr5-credhub-cli-2.9.35", + "path": "/nix/store/5hv8vj4dhy521m49sc4wwmaz2q319z9a-credhub-cli-2.9.29", "default": true } ], - "store_path": "/nix/store/r0kkggv2kbdma8l2n177nl0sw4lwvqr5-credhub-cli-2.9.35" + "store_path": "/nix/store/5hv8vj4dhy521m49sc4wwmaz2q319z9a-credhub-cli-2.9.29" }, "x86_64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/wkgc414d175cv1pa3h257pm264ayk8if-credhub-cli-2.9.35", + "path": "/nix/store/c5d2ggn5c819spywi74pzksbzds9ryym-credhub-cli-2.9.29", "default": true } ], - "store_path": "/nix/store/wkgc414d175cv1pa3h257pm264ayk8if-credhub-cli-2.9.35" + "store_path": "/nix/store/c5d2ggn5c819spywi74pzksbzds9ryym-credhub-cli-2.9.29" }, "x86_64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/zkmy2g042p75p3i6qib6s1589qymrg3k-credhub-cli-2.9.35", + "path": "/nix/store/3y6r6lgrbaq8521hk3zbalf3gz3albcg-credhub-cli-2.9.29", "default": true } ], - "store_path": "/nix/store/zkmy2g042p75p3i6qib6s1589qymrg3k-credhub-cli-2.9.35" + "store_path": "/nix/store/3y6r6lgrbaq8521hk3zbalf3gz3albcg-credhub-cli-2.9.29" } } }, @@ -853,51 +853,51 @@ } } }, - "golangci-lint@1.59.1": { - "last_modified": "2024-07-31T08:48:38Z", - "resolved": "github:NixOS/nixpkgs/c3392ad349a5227f4a3464dce87bcc5046692fce#golangci-lint", + "golangci-lint@1.60.2": { + "last_modified": "2024-08-21T11:30:02Z", + "resolved": "github:NixOS/nixpkgs/f132a77a82530de0d10216f09857090d324fee05#golangci-lint", "source": "devbox-search", - "version": "1.59.1", + "version": "1.60.2", "systems": { "aarch64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/k3rnfx753gnx5v8l3i4sx1g1al2ds0di-golangci-lint-1.59.1", + "path": "/nix/store/zl8l769wimy5bsvrlcvq9f6b7465z4hx-golangci-lint-1.60.2", "default": true } ], - "store_path": "/nix/store/k3rnfx753gnx5v8l3i4sx1g1al2ds0di-golangci-lint-1.59.1" + "store_path": "/nix/store/zl8l769wimy5bsvrlcvq9f6b7465z4hx-golangci-lint-1.60.2" }, "aarch64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/29908ar68rrr9jzdhzcrlkbfk30gnihf-golangci-lint-1.59.1", + "path": "/nix/store/drgzg08jxcc50azd6bchxy6gcym2kwav-golangci-lint-1.60.2", "default": true } ], - "store_path": "/nix/store/29908ar68rrr9jzdhzcrlkbfk30gnihf-golangci-lint-1.59.1" + "store_path": "/nix/store/drgzg08jxcc50azd6bchxy6gcym2kwav-golangci-lint-1.60.2" }, "x86_64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/v7882fqgdy46a7l432q11f3xmbln80rc-golangci-lint-1.59.1", + "path": "/nix/store/my7afydss5zsi4z30mzshj31bm2v5chd-golangci-lint-1.60.2", "default": true } ], - "store_path": "/nix/store/v7882fqgdy46a7l432q11f3xmbln80rc-golangci-lint-1.59.1" + "store_path": "/nix/store/my7afydss5zsi4z30mzshj31bm2v5chd-golangci-lint-1.60.2" }, "x86_64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/1m1i9zhrgdw2192803n6wf2k7g86y6d5-golangci-lint-1.59.1", + "path": "/nix/store/rp23zfccxkvzqphhrx0sp2pz682v89r8-golangci-lint-1.60.2", "default": true } ], - "store_path": "/nix/store/1m1i9zhrgdw2192803n6wf2k7g86y6d5-golangci-lint-1.59.1" + "store_path": "/nix/store/rp23zfccxkvzqphhrx0sp2pz682v89r8-golangci-lint-1.60.2" } } }, @@ -1666,7 +1666,6 @@ }, "ruby@latest": { "last_modified": "2024-08-14T11:41:26Z", - "plugin_version": "0.0.2", "resolved": "github:NixOS/nixpkgs/0cb2fd7c59fed0cd82ef858cbcbdb552b9a33465#ruby_3_3", "source": "devbox-search", "version": "3.3.4", diff --git a/packages/golangapiserver/spec b/packages/golangapiserver/spec index a984b58a25..1791520b06 100644 --- a/packages/golangapiserver/spec +++ b/packages/golangapiserver/spec @@ -227,5 +227,7 @@ files: - autoscaler/vendor/google.golang.org/protobuf/runtime/protoiface/* # gosub - autoscaler/vendor/google.golang.org/protobuf/runtime/protoimpl/* # gosub - autoscaler/vendor/google.golang.org/protobuf/types/known/timestamppb/* # gosub +- autoscaler/vendor/gopkg.in/errgo.v2/errors/* # gosub +- autoscaler/vendor/gopkg.in/errgo.v2/fmt/errors/* # gosub - autoscaler/vendor/gopkg.in/yaml.v2/* # gosub - autoscaler/vendor/gopkg.in/yaml.v3/* # gosub diff --git a/src/acceptance/assets/app/go_app/internal/app/cpu.go b/src/acceptance/assets/app/go_app/internal/app/cpu.go index 35733cb307..e194ec6f89 100644 --- a/src/acceptance/assets/app/go_app/internal/app/cpu.go +++ b/src/acceptance/assets/app/go_app/internal/app/cpu.go @@ -13,7 +13,7 @@ import ( //counterfeiter:generate . CPUWaster type CPUWaster interface { - UseCPU(utilisation uint64, duration time.Duration) + UseCPU(utilisation int64, duration time.Duration) IsRunning() bool StopTest() } @@ -31,15 +31,15 @@ func CPUTests(logger logr.Logger, r *gin.RouterGroup, cpuTest CPUWaster) *gin.Ro Error(c, http.StatusConflict, "CPU test is already running") return } - var utilization uint64 - var minutes uint64 + var utilization int64 + var minutes int64 var err error - utilization, err = strconv.ParseUint(c.Param("utilization"), 10, 64) + utilization, err = strconv.ParseInt(c.Param("utilization"), 10, 64) if err != nil { Error(c, http.StatusBadRequest, "invalid utilization: %s", err.Error()) return } - if minutes, err = strconv.ParseUint(c.Param("minutes"), 10, 64); err != nil { + if minutes, err = strconv.ParseInt(c.Param("minutes"), 10, 64); err != nil { Error(c, http.StatusBadRequest, "invalid minutes: %s", err.Error()) return } @@ -62,7 +62,7 @@ func CPUTests(logger logr.Logger, r *gin.RouterGroup, cpuTest CPUWaster) *gin.Ro return r } -func (m *ConcurrentBusyLoopCPUWaster) UseCPU(utilisation uint64, duration time.Duration) { +func (m *ConcurrentBusyLoopCPUWaster) UseCPU(utilisation int64, duration time.Duration) { m.startTest() for utilisation > 0 { @@ -71,7 +71,7 @@ func (m *ConcurrentBusyLoopCPUWaster) UseCPU(utilisation uint64, duration time.D utilisation = utilisation - perGoRoutineUtilisation // the core cpu wasting goroutine - go func(util uint64) { + go func(util int64) { // to achieve a desired utilisation, we run a busy loop for a certain percentage of time and then wait for the remainder // concretely, we split a second into two parts: one busy loop and one sleep // we repeat this "second" until the test is stopped diff --git a/src/acceptance/assets/app/go_app/internal/app/cpu_test.go b/src/acceptance/assets/app/go_app/internal/app/cpu_test.go index 7541a2bd0f..f423da7dbf 100644 --- a/src/acceptance/assets/app/go_app/internal/app/cpu_test.go +++ b/src/acceptance/assets/app/go_app/internal/app/cpu_test.go @@ -21,7 +21,7 @@ var _ = Describe("CPU tests", func() { Get("/cpu/invalid/4"). Expect(GinkgoT()). Status(http.StatusBadRequest). - Body(`{"error":{"description":"invalid utilization: strconv.ParseUint: parsing \"invalid\": invalid syntax"}}`). + Body(`{"error":{"description":"invalid utilization: strconv.ParseInt: parsing \"invalid\": invalid syntax"}}`). End() }) It("should err if cpu out of bounds", func() { @@ -29,7 +29,7 @@ var _ = Describe("CPU tests", func() { Get("/cpu/100001010101010249032897287298719874687936483275648273632429479827398798271/4"). Expect(GinkgoT()). Status(http.StatusBadRequest). - Body(`{"error":{"description":"invalid utilization: strconv.ParseUint: parsing \"100001010101010249032897287298719874687936483275648273632429479827398798271\": value out of range"}}`). + Body(`{"error":{"description":"invalid utilization: strconv.ParseInt: parsing \"100001010101010249032897287298719874687936483275648273632429479827398798271\": value out of range"}}`). End() }) It("should err if cpu not an int", func() { @@ -37,7 +37,7 @@ var _ = Describe("CPU tests", func() { Get("/cpu/5/invalid"). Expect(GinkgoT()). Status(http.StatusBadRequest). - Body(`{"error":{"description":"invalid minutes: strconv.ParseUint: parsing \"invalid\": invalid syntax"}}`). + Body(`{"error":{"description":"invalid minutes: strconv.ParseInt: parsing \"invalid\": invalid syntax"}}`). End() }) It("should return ok and sleep correctDuration", func() { @@ -51,7 +51,7 @@ var _ = Describe("CPU tests", func() { Eventually(func() int { return fakeCPUWaster.UseCPUCallCount() }).Should(Equal(1)) utilization, duration := fakeCPUWaster.UseCPUArgsForCall(0) Expect(duration).Should(Equal(4 * time.Minute)) - Expect(utilization).Should(Equal(uint64(5))) + Expect(utilization).Should(Equal(int64(5))) }) }) @@ -59,7 +59,7 @@ var _ = Describe("CPU tests", func() { Context("ConcurrentBusyLoopCPUWaster", func() { Context("UseCPU", FlakeAttempts(3), func() { DescribeTable("should use cpu", - func(utilisation uint64, duration time.Duration) { + func(utilisation int64, duration time.Duration) { oldCpu := getTotalCPUUsage("before test") By("wasting cpu time") @@ -86,11 +86,11 @@ var _ = Describe("CPU tests", func() { } Expect(newCpu - oldCpu).To(BeNumerically("~", expectedCPUUsage, tolerance)) }, - Entry("25% for 10 seconds", uint64(25), time.Second*10), - Entry("50% for 10 seconds", uint64(50), time.Second*10), - Entry("100% for 10 seconds", uint64(100), time.Second*10), - Entry("200% for 10 seconds", uint64(200), time.Second*10), - Entry("400% for 10 seconds", uint64(400), time.Second*10), + Entry("25% for 10 seconds", int64(25), time.Second*10), + Entry("50% for 10 seconds", int64(50), time.Second*10), + Entry("100% for 10 seconds", int64(100), time.Second*10), + Entry("200% for 10 seconds", int64(200), time.Second*10), + Entry("400% for 10 seconds", int64(400), time.Second*10), ) }) }) @@ -107,6 +107,6 @@ func getTotalCPUUsage(action string) time.Duration { return cpuTotalDuration } -func multiplyDurationByPercentage(duration time.Duration, percentage uint64) time.Duration { +func multiplyDurationByPercentage(duration time.Duration, percentage int64) time.Duration { return time.Duration(float64(duration) * float64(percentage) / 100) } diff --git a/src/acceptance/assets/app/go_app/internal/app/custom_metrics.go b/src/acceptance/assets/app/go_app/internal/app/custom_metrics.go index b295a7c096..26d919ab8c 100644 --- a/src/acceptance/assets/app/go_app/internal/app/custom_metrics.go +++ b/src/acceptance/assets/app/go_app/internal/app/custom_metrics.go @@ -169,8 +169,7 @@ func getCFInstanceIdentityCertificateClient() (*http.Client, error) { caCertPool := x509.NewCertPool() caCertPool.AppendCertsFromPEM(caCertBytes) - /* #nosec G402 -- test app that shall run on dev foundations without proper certs */ - //nolint:gosec // #nosec G402 -- due to https://github.com/securego/gosec/issues/1105 + //#nosec G402 -- test app that shall run on dev foundations without proper certs tlsConfig := &tls.Config{ Certificates: []tls.Certificate{cert}, InsecureSkipVerify: true, diff --git a/src/acceptance/assets/app/go_app/internal/app/memory.go b/src/acceptance/assets/app/go_app/internal/app/memory.go index 0893a37261..27e51be3c7 100644 --- a/src/acceptance/assets/app/go_app/internal/app/memory.go +++ b/src/acceptance/assets/app/go_app/internal/app/memory.go @@ -24,7 +24,7 @@ const ( //counterfeiter:generate . MemoryGobbler type MemoryGobbler interface { - UseMemory(numBytes uint64) + UseMemory(numBytes int64) Sleep(sleepTime time.Duration) IsRunning() bool StopTest() @@ -44,15 +44,15 @@ func MemoryTests(logger logr.Logger, r *gin.RouterGroup, memoryTest MemoryGobble Error(c, http.StatusConflict, "memory test is already running") return } - var memoryMiB uint64 - var minutes uint64 + var memoryMiB int64 + var minutes int64 var err error - memoryMiB, err = strconv.ParseUint(c.Param("memoryMiB"), 10, 64) + memoryMiB, err = strconv.ParseInt(c.Param("memoryMiB"), 10, 64) if err != nil { Error(c, http.StatusBadRequest, "invalid memoryMiB: %s", err.Error()) return } - if minutes, err = strconv.ParseUint(c.Param("minutes"), 10, 64); err != nil { + if minutes, err = strconv.ParseInt(c.Param("minutes"), 10, 64); err != nil { Error(c, http.StatusBadRequest, "invalid minutes: %s", err.Error()) return } @@ -97,12 +97,12 @@ func Error(c *gin.Context, status int, descriptionf string, args ...any) { const chunkSize = 4 * Kibi -func (m *ListBasedMemoryGobbler) UseMemory(numBytes uint64) { +func (m *ListBasedMemoryGobbler) UseMemory(numBytes int64) { m.mu.Lock() defer m.mu.Unlock() m.isRunning = true m.used = list.New() - used := uint64(0) + used := int64(0) for used <= numBytes { m.used.PushBack(bytes.Repeat([]byte("X"), chunkSize)) // The bytes need to be non-zero to force memory allocation used += chunkSize diff --git a/src/acceptance/assets/app/go_app/internal/app/memory_test.go b/src/acceptance/assets/app/go_app/internal/app/memory_test.go index 854f62ebbd..82dc1e6d23 100644 --- a/src/acceptance/assets/app/go_app/internal/app/memory_test.go +++ b/src/acceptance/assets/app/go_app/internal/app/memory_test.go @@ -1,6 +1,7 @@ package app_test import ( + "math" "net/http" "runtime" "time" @@ -22,7 +23,7 @@ var _ = Describe("Memory tests", func() { Get("/memory/invalid/4"). Expect(GinkgoT()). Status(http.StatusBadRequest). - Body(`{"error":{"description":"invalid memoryMiB: strconv.ParseUint: parsing \"invalid\": invalid syntax"}}`). + Body(`{"error":{"description":"invalid memoryMiB: strconv.ParseInt: parsing \"invalid\": invalid syntax"}}`). End() }) It("should err if memory out of bounds", func() { @@ -30,7 +31,7 @@ var _ = Describe("Memory tests", func() { Get("/memory/100001010101010249032897287298719874687936483275648273632429479827398798271/4"). Expect(GinkgoT()). Status(http.StatusBadRequest). - Body(`{"error":{"description":"invalid memoryMiB: strconv.ParseUint: parsing \"100001010101010249032897287298719874687936483275648273632429479827398798271\": value out of range"}}`). + Body(`{"error":{"description":"invalid memoryMiB: strconv.ParseInt: parsing \"100001010101010249032897287298719874687936483275648273632429479827398798271\": value out of range"}}`). End() }) It("should err if memory not an int", func() { @@ -38,7 +39,7 @@ var _ = Describe("Memory tests", func() { Get("/memory/5/invalid"). Expect(GinkgoT()). Status(http.StatusBadRequest). - Body(`{"error":{"description":"invalid minutes: strconv.ParseUint: parsing \"invalid\": invalid syntax"}}`). + Body(`{"error":{"description":"invalid minutes: strconv.ParseInt: parsing \"invalid\": invalid syntax"}}`). End() }) It("should return ok and sleep correctDuration", func() { @@ -55,7 +56,7 @@ var _ = Describe("Memory tests", func() { // http-features (i.e. returing http-status-code 202 etc.) which would involve a lot of // new lines of code. Eventually(func() int { return fakeMemoryTest.UseMemoryCallCount() }).Should(Equal(1)) - Expect(fakeMemoryTest.UseMemoryArgsForCall(0)).To(Equal(uint64(5 * app.Mebi))) + Expect(fakeMemoryTest.UseMemoryArgsForCall(0)).To(Equal(int64(5 * app.Mebi))) Eventually(func() int { return fakeMemoryTest.SleepCallCount() }).Should(Equal(1)) Expect(fakeMemoryTest.SleepArgsForCall(0)).To(Equal(4 * time.Minute)) Eventually(func() int { return fakeMemoryTest.StopTestCallCount() }).Should(Equal(1)) @@ -63,7 +64,7 @@ var _ = Describe("Memory tests", func() { }) Context("memTest info tests", func() { It("should gobble memory and release when stopped", func() { - var allocInMebi uint64 = 50 * app.Mebi + var allocInMebi int64 = 50 * app.Mebi oldMem := getTotalMemoryUsage("before memTest info test") @@ -95,7 +96,7 @@ var _ = Describe("Memory tests", func() { }) }) -func getTotalMemoryUsage(action string) uint64 { +func getTotalMemoryUsage(action string) int64 { GinkgoHelper() runtime.GC() @@ -106,7 +107,7 @@ func getTotalMemoryUsage(action string) uint64 { result := m.Alloc GinkgoWriter.Printf("total memory usage %s: %d MiB\n", action, result/app.Mebi) - return result + return clampUint64ToInt64(result) } // HeapInuse minus HeapAlloc estimates the amount of memory @@ -114,7 +115,7 @@ func getTotalMemoryUsage(action string) uint64 { // not currently being used. This is an upper bound on // fragmentation, but in general this memory can be reused // efficiently. -func getMemorySlack() uint64 { +func getMemorySlack() int64 { runtime.GC() var ms runtime.MemStats runtime.ReadMemStats(&ms) @@ -123,5 +124,16 @@ func getMemorySlack() uint64 { GinkgoWriter.Printf("slack: %d MiB\n", slack/app.Mebi) - return slack + return clampUint64ToInt64(slack) +} + +func clampUint64ToInt64(value uint64) int64 { + var result int64 + + if value > math.MaxInt64 { + result = math.MaxInt64 + } else { + result = int64(value) //#nosec G115 -- https://github.com/securego/gosec/issues/1187 + } + return result } diff --git a/src/acceptance/assets/app/go_app/internal/app/responsetime.go b/src/acceptance/assets/app/go_app/internal/app/responsetime.go index b42a87c12b..cd97101a11 100644 --- a/src/acceptance/assets/app/go_app/internal/app/responsetime.go +++ b/src/acceptance/assets/app/go_app/internal/app/responsetime.go @@ -20,9 +20,9 @@ var _ TimeWaster = Sleeper{} func ResponseTimeTests(logger logr.Logger, r *gin.RouterGroup, timeWaster TimeWaster) *gin.RouterGroup { r.GET("/slow/:delayInMS", func(c *gin.Context) { - var milliseconds uint64 + var milliseconds int64 var err error - if milliseconds, err = strconv.ParseUint(c.Param("delayInMS"), 10, 64); err != nil { + if milliseconds, err = strconv.ParseInt(c.Param("delayInMS"), 10, 64); err != nil { Error(c, http.StatusBadRequest, "invalid milliseconds: %s", err.Error()) return } diff --git a/src/acceptance/assets/app/go_app/internal/app/responsetime_test.go b/src/acceptance/assets/app/go_app/internal/app/responsetime_test.go index bf0f00d076..0c64906eb8 100644 --- a/src/acceptance/assets/app/go_app/internal/app/responsetime_test.go +++ b/src/acceptance/assets/app/go_app/internal/app/responsetime_test.go @@ -19,7 +19,7 @@ var _ = Describe("Responsetime tests", func() { Get("/responsetime/slow/yes"). Expect(GinkgoT()). Status(http.StatusBadRequest). - Body(`{"error":{"description":"invalid milliseconds: strconv.ParseUint: parsing \"yes\": invalid syntax"}}`). + Body(`{"error":{"description":"invalid milliseconds: strconv.ParseInt: parsing \"yes\": invalid syntax"}}`). End() }) It("should err if memory out of bounds", func() { @@ -27,7 +27,7 @@ var _ = Describe("Responsetime tests", func() { Get("/responsetime/slow/100001010101010249032897287298719874687936483275648273632429479827398798271"). Expect(GinkgoT()). Status(http.StatusBadRequest). - Body(`{"error":{"description":"invalid milliseconds: strconv.ParseUint: parsing \"100001010101010249032897287298719874687936483275648273632429479827398798271\": value out of range"}}`). + Body(`{"error":{"description":"invalid milliseconds: strconv.ParseInt: parsing \"100001010101010249032897287298719874687936483275648273632429479827398798271\": value out of range"}}`). End() }) diff --git a/src/acceptance/assets/app/go_app/internal/custommetrics/basic_auth_transport.go b/src/acceptance/assets/app/go_app/internal/custommetrics/basic_auth_transport.go index e0f311562d..22abb1addb 100644 --- a/src/acceptance/assets/app/go_app/internal/custommetrics/basic_auth_transport.go +++ b/src/acceptance/assets/app/go_app/internal/custommetrics/basic_auth_transport.go @@ -25,8 +25,7 @@ func (bat *BasicAuthTransport) Client() *http.Client { } func NewBasicAuthTransport(credentials CustomMetricsCredentials) *BasicAuthTransport { - /* #nosec G402 -- test app that shall run on dev foundations without proper certs */ - //nolint:gosec // #nosec G402 -- due to https://github.com/securego/gosec/issues/1105 + //#nosec G402 -- test app that shall run on dev foundations without proper certs tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } diff --git a/src/autoscaler/api/broker/broker.go b/src/autoscaler/api/broker/broker.go index c3bd81b975..05d15baada 100644 --- a/src/autoscaler/api/broker/broker.go +++ b/src/autoscaler/api/broker/broker.go @@ -737,7 +737,7 @@ func (b *Broker) planDefinitionExceeded(policy *models.ScalingPolicy, planID str return apiresponses.NewFailureResponse(errors.New("error validating policy"), http.StatusInternalServerError, "failed to check policy for plan adherence") } if !ok { - b.logger.Error("policy did not adhere to plan", fmt.Errorf(checkResult), lager.Data{"instanceID": instanceID, "policy": policy}) + b.logger.Error("policy did not adhere to plan", errors.New(checkResult), lager.Data{"instanceID": instanceID, "policy": policy}) return apiresponses.NewFailureResponse(fmt.Errorf("error: policy did not adhere to plan: %s", checkResult), http.StatusBadRequest, "policy did not adhere to plan") } return nil diff --git a/src/autoscaler/api/config/config.go b/src/autoscaler/api/config/config.go index a9a286f4a9..33ae26ca4f 100644 --- a/src/autoscaler/api/config/config.go +++ b/src/autoscaler/api/config/config.go @@ -11,6 +11,7 @@ import ( "golang.org/x/crypto/bcrypt" "github.com/xeipuuv/gojsonschema" + "gopkg.in/errgo.v2/fmt/errors" "gopkg.in/yaml.v3" "code.cloudfoundry.org/app-autoscaler/src/autoscaler/db" @@ -267,7 +268,7 @@ func (c *Config) Validate() error { } } errString += "}" - return fmt.Errorf(errString) + return errors.New(errString) } return nil diff --git a/src/autoscaler/api/policyvalidator/policy_validator.go b/src/autoscaler/api/policyvalidator/policy_validator.go index 966107234b..6f55d2c0ef 100644 --- a/src/autoscaler/api/policyvalidator/policy_validator.go +++ b/src/autoscaler/api/policyvalidator/policy_validator.go @@ -415,7 +415,7 @@ func (pv *PolicyValidator) validateOverlappingInRecurringSchedules(policy *model recScheds := policy.Schedules.RecurringSchedules for scheduleIndexB := 0; scheduleIndexB < length-1; scheduleIndexB++ { for scheduleIndexA := scheduleIndexB + 1; scheduleIndexA < length; scheduleIndexA++ { - if (recScheds[scheduleIndexA].DaysOfWeek != nil && len(recScheds[scheduleIndexA].DaysOfWeek) > 0) && (recScheds[scheduleIndexB].DaysOfWeek != nil && len(recScheds[scheduleIndexB].DaysOfWeek) > 0) { + if (len(recScheds[scheduleIndexA].DaysOfWeek) > 0) && (len(recScheds[scheduleIndexB].DaysOfWeek) > 0) { if hasIntersection(recScheds[scheduleIndexA].DaysOfWeek, recScheds[scheduleIndexB].DaysOfWeek) { if compareTimesGTEQ(recScheds[scheduleIndexB].EndTime, recScheds[scheduleIndexA].StartTime) && compareTimesGTEQ(recScheds[scheduleIndexA].EndTime, recScheds[scheduleIndexB].StartTime) && compareDatesGTEQ(recScheds[scheduleIndexB].EndDate, recScheds[scheduleIndexA].StartDate) && compareDatesGTEQ(recScheds[scheduleIndexA].EndDate, recScheds[scheduleIndexB].StartDate) { @@ -432,7 +432,7 @@ func (pv *PolicyValidator) validateOverlappingInRecurringSchedules(policy *model } } - if (recScheds[scheduleIndexA].DaysOfMonth != nil && len(recScheds[scheduleIndexA].DaysOfMonth) > 0) && (recScheds[scheduleIndexB].DaysOfMonth != nil && len(recScheds[scheduleIndexB].DaysOfMonth) > 0) { + if (len(recScheds[scheduleIndexA].DaysOfMonth) > 0) && (len(recScheds[scheduleIndexB].DaysOfMonth) > 0) { if hasIntersection(recScheds[scheduleIndexA].DaysOfMonth, recScheds[scheduleIndexB].DaysOfMonth) { if compareTimesGTEQ(recScheds[scheduleIndexB].EndTime, recScheds[scheduleIndexA].StartTime) && compareTimesGTEQ(recScheds[scheduleIndexA].EndTime, recScheds[scheduleIndexB].StartTime) && compareDatesGTEQ(recScheds[scheduleIndexB].EndDate, recScheds[scheduleIndexA].StartDate) && compareDatesGTEQ(recScheds[scheduleIndexA].EndDate, recScheds[scheduleIndexB].StartDate) { diff --git a/src/autoscaler/cf/oauth.go b/src/autoscaler/cf/oauth.go index 8fe6c938dc..f5c37196e7 100644 --- a/src/autoscaler/cf/oauth.go +++ b/src/autoscaler/cf/oauth.go @@ -17,8 +17,8 @@ const ( ) var ( - ErrUnauthorized = fmt.Errorf(http.StatusText(http.StatusUnauthorized)) - ErrInvalidTokenFormat = fmt.Errorf("Invalid token format") + ErrUnauthorized = errors.New(http.StatusText(http.StatusUnauthorized)) + ErrInvalidTokenFormat = errors.New("invalid token format") ) func (c *Client) IsUserSpaceDeveloper(userToken string, appId Guid) (bool, error) { diff --git a/src/autoscaler/envelopeprocessor/envelope_processor.go b/src/autoscaler/envelopeprocessor/envelope_processor.go index a29f6865dd..78686d544e 100644 --- a/src/autoscaler/envelopeprocessor/envelope_processor.go +++ b/src/autoscaler/envelopeprocessor/envelope_processor.go @@ -112,7 +112,7 @@ func getResponsetimeInstanceMetrics(envelopes []*loggregator_v2.Envelope, appID responseTimeMetric := models.AppInstanceMetric{ AppId: appID, - InstanceIndex: uint32(instanceIndex), + InstanceIndex: instanceIndex, Name: models.MetricNameResponseTime, Unit: models.UnitMilliseconds, Value: fmt.Sprintf("%d", int64(math.Ceil(float64(sumResponseTime)/float64(numReq*1000*1000)))), @@ -145,7 +145,7 @@ func getThroughputInstanceMetrics(envelopes []*loggregator_v2.Envelope, appID st throughputMetric := models.AppInstanceMetric{ AppId: appID, - InstanceIndex: uint32(instanceIndex), + InstanceIndex: instanceIndex, Name: models.MetricNameThroughput, Unit: models.UnitRPS, Value: fmt.Sprintf("%d", int(math.Ceil(float64(numReq)/collectionInterval.Seconds()))), @@ -196,13 +196,13 @@ func isContainerMetricEnvelope(e *loggregator_v2.Envelope) bool { func processContainerMetrics(e *loggregator_v2.Envelope, currentTimeStamp int64) []models.AppInstanceMetric { var metrics []models.AppInstanceMetric appID := e.SourceId - instanceIndex, _ := strconv.ParseInt(e.InstanceId, 10, 32) + instanceIndex, _ := strconv.ParseUint(e.InstanceId, 10, 64) g := e.GetGauge() timestamp := e.Timestamp baseAppInstanceMetric := models.AppInstanceMetric{ AppId: appID, - InstanceIndex: uint32(instanceIndex), + InstanceIndex: instanceIndex, CollectedAt: currentTimeStamp, Timestamp: timestamp, } @@ -296,12 +296,12 @@ func getCPUEntitlementInstanceMetric(cpuEntitlementValue float64) models.AppInst func processCustomMetrics(e *loggregator_v2.Envelope, currentTimestamp int64) []models.AppInstanceMetric { var metrics []models.AppInstanceMetric - instanceIndex, _ := strconv.ParseInt(e.InstanceId, 10, 32) + instanceIndex, _ := strconv.ParseUint(e.InstanceId, 10, 64) for n, v := range e.GetGauge().GetMetrics() { metrics = append(metrics, models.AppInstanceMetric{ AppId: e.SourceId, - InstanceIndex: uint32(instanceIndex), + InstanceIndex: instanceIndex, CollectedAt: currentTimestamp, Name: n, Unit: v.Unit, diff --git a/src/autoscaler/eventgenerator/aggregator/appManager.go b/src/autoscaler/eventgenerator/aggregator/appManager.go index abdb50b3ec..ccfe7574b1 100644 --- a/src/autoscaler/eventgenerator/aggregator/appManager.go +++ b/src/autoscaler/eventgenerator/aggregator/appManager.go @@ -103,6 +103,7 @@ func (am *AppManager) retrievePolicies() ([]*models.PolicyJson, error) { } func (am *AppManager) isEventgeneratorRespForApp(appID string) bool { + // #nosec G115 -- nodes will be in the range of a dozen max - no need to worry about integer overflow return helpers.FNVHash(appID)%uint32(am.nodeNum) == uint32(am.nodeIndex) } diff --git a/src/autoscaler/eventgenerator/metric/fetcher.go b/src/autoscaler/eventgenerator/metric/fetcher.go index 1ab423957f..98a020fea2 100644 --- a/src/autoscaler/eventgenerator/metric/fetcher.go +++ b/src/autoscaler/eventgenerator/metric/fetcher.go @@ -116,7 +116,7 @@ func (l *logCacheFetcher) getMetricsPromQLAPI(appId string, metricType string, c return []models.AppInstanceMetric{}, fmt.Errorf("sample does not contain a point") } - instanceId := uint32(instanceIdUInt) + instanceId := instanceIdUInt valueWithoutDecimalsRoundedToCeiling := fmt.Sprintf("%.0f", math.Ceil(point.GetValue())) metrics = append(metrics, models.AppInstanceMetric{ diff --git a/src/autoscaler/eventgenerator/metric/fetcher_factory_test.go b/src/autoscaler/eventgenerator/metric/fetcher_factory_test.go index a830db8118..c408c7f412 100644 --- a/src/autoscaler/eventgenerator/metric/fetcher_factory_test.go +++ b/src/autoscaler/eventgenerator/metric/fetcher_factory_test.go @@ -129,5 +129,6 @@ var _ = Describe("logCacheFetcherFactory", func() { func getUnexportedField(name string, client metric.LogCacheClient) interface{} { field := reflect.ValueOf(client).Elem().FieldByName(name) + // #nosec G115 -- test code return reflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())).Elem().Interface() } diff --git a/src/autoscaler/eventgenerator/metric/fetcher_test.go b/src/autoscaler/eventgenerator/metric/fetcher_test.go index cccf3bd8fe..79324454b3 100644 --- a/src/autoscaler/eventgenerator/metric/fetcher_test.go +++ b/src/autoscaler/eventgenerator/metric/fetcher_test.go @@ -77,7 +77,7 @@ var _ = Describe("logCacheFetcher", func() { Expect(err).ToNot(HaveOccurred()) Expect(metrics).To(HaveLen(1)) Expect(metrics[0].AppId).To(Equal("app-id")) - Expect(metrics[0].InstanceIndex).To(Equal(uint32(0))) + Expect(metrics[0].InstanceIndex).To(Equal(uint64(0))) Expect(metrics[0].Name).To(Equal("throughput")) Expect(metrics[0].Unit).To(Equal("rps")) Expect(metrics[0].Value).To(Equal("0")) @@ -178,13 +178,13 @@ var _ = Describe("logCacheFetcher", func() { Expect(err).ToNot(HaveOccurred()) Expect(metrics).To(HaveLen(2)) Expect(metrics[0].AppId).To(Equal("app-id")) - Expect(metrics[0].InstanceIndex).To(Equal(uint32(0))) + Expect(metrics[0].InstanceIndex).To(Equal(uint64(0))) Expect(metrics[0].Name).To(Equal("responsetime")) Expect(metrics[0].Unit).To(Equal("ms")) Expect(metrics[0].Value).To(Equal("200")) Expect(metrics[1].AppId).To(Equal("app-id")) - Expect(metrics[1].InstanceIndex).To(Equal(uint32(1))) + Expect(metrics[1].InstanceIndex).To(Equal(uint64(1))) Expect(metrics[1].Name).To(Equal("responsetime")) Expect(metrics[1].Unit).To(Equal("ms")) Expect(metrics[1].Value).To(Equal("300")) @@ -227,13 +227,13 @@ var _ = Describe("logCacheFetcher", func() { Expect(metrics).To(HaveLen(2)) Expect(metrics[0].AppId).To(Equal("app-id")) - Expect(metrics[0].InstanceIndex).To(Equal(uint32(0))) + Expect(metrics[0].InstanceIndex).To(Equal(uint64(0))) Expect(metrics[0].Name).To(Equal("throughput")) Expect(metrics[0].Unit).To(Equal("rps")) Expect(metrics[0].Value).To(Equal("123")) Expect(metrics[1].AppId).To(Equal("app-id")) - Expect(metrics[1].InstanceIndex).To(Equal(uint32(1))) + Expect(metrics[1].InstanceIndex).To(Equal(uint64(1))) Expect(metrics[1].Name).To(Equal("throughput")) Expect(metrics[1].Unit).To(Equal("rps")) Expect(metrics[1].Value).To(Equal("321")) diff --git a/src/autoscaler/go.mod b/src/autoscaler/go.mod index 99e5113fe7..8e764b65a9 100644 --- a/src/autoscaler/go.mod +++ b/src/autoscaler/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( code.cloudfoundry.org/cfhttp/v2 v2.1.0 code.cloudfoundry.org/clock v1.2.0 - code.cloudfoundry.org/go-log-cache/v3 v3.0.1 + code.cloudfoundry.org/go-log-cache/v3 v3.0.3 code.cloudfoundry.org/go-loggregator/v10 v10.0.0 code.cloudfoundry.org/lager/v3 v3.0.3 code.cloudfoundry.org/loggregator-agent-release/src v0.0.0-20240730181045-a0abd75d08df @@ -24,7 +24,7 @@ require ( github.com/jmoiron/sqlx v1.4.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 github.com/ogen-go/ogen v1.3.0 - github.com/onsi/ginkgo/v2 v2.20.0 + github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.34.1 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pivotal-cf/brokerapi/v11 v11.0.4 @@ -46,6 +46,7 @@ require ( golang.org/x/net v0.28.0 golang.org/x/time v0.5.0 google.golang.org/grpc v1.65.0 + gopkg.in/errgo.v2 v2.1.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -70,7 +71,7 @@ require ( github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect @@ -98,8 +99,8 @@ require ( golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/tools v0.24.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/src/autoscaler/go.sum b/src/autoscaler/go.sum index 355ff7cda4..a2fe42793a 100644 --- a/src/autoscaler/go.sum +++ b/src/autoscaler/go.sum @@ -598,8 +598,8 @@ code.cloudfoundry.org/clock v1.2.0 h1:1swXS7yPmQmhAdkTb1nJ2c0geOdf4LvibUleNCo2Hj code.cloudfoundry.org/clock v1.2.0/go.mod h1:foDbmVp5RIuIGlota90ot4FkJtx5m4+oKoWiVuu2FDg= code.cloudfoundry.org/go-diodes v0.0.0-20240723012033-bf559dd3d0b1 h1:gkVwNAzYAZVEzaFKkiwGGP9+gETtFocX+lP6nm1fqPk= code.cloudfoundry.org/go-diodes v0.0.0-20240723012033-bf559dd3d0b1/go.mod h1:KZrwsjqkXOSxz4iNcMasnXU77a7nFWFYKvScRZqxR+8= -code.cloudfoundry.org/go-log-cache/v3 v3.0.1 h1:+6Lg5IQMCzqZw4aMF2hwjRar7z1SfSUop08+n21g8Xk= -code.cloudfoundry.org/go-log-cache/v3 v3.0.1/go.mod h1:NkNQXq92zrE64fFTqsLjO4qn5gs3ijiznUzbte8FDl4= +code.cloudfoundry.org/go-log-cache/v3 v3.0.3 h1:lmmGxF13Lxxc4bV1BfQkf7i4Dz5VVFPoBHNOp2FHdZg= +code.cloudfoundry.org/go-log-cache/v3 v3.0.3/go.mod h1:fDvHiI+ulXb+DjUjuYy0b6PhgmFv0F8t7HZKITD4xBI= code.cloudfoundry.org/go-loggregator/v10 v10.0.0 h1:7tSJp4QFh8064jp13zNGoKoIuu8a2GhoGkr53nr9uu0= code.cloudfoundry.org/go-loggregator/v10 v10.0.0/go.mod h1:gRbT/3OQzBaXtII0vMmCVnF52B0Fvz9XZcCXUrcXpkg= code.cloudfoundry.org/go-metric-registry v0.0.0-20240604201903-7cef498efb7a h1:XpebbxgIBBy7SrwIGW+gREZuAtnJ9PHWC4Y+k7yje2I= @@ -847,8 +847,8 @@ github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWS github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= @@ -939,8 +939,8 @@ github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxm github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= github.com/onsi/ginkgo/v2 v2.9.4/go.mod h1:gCQYp2Q+kSoIj7ykSVb9nskRSsR6PUj4AiLywzIhbKM= -github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw= -github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= +github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo= +github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= @@ -1673,10 +1673,10 @@ google.golang.org/genproto v0.0.0-20230323212658-478b75c54725/go.mod h1:UUQDJDOl google.golang.org/genproto v0.0.0-20230330154414-c0448cd141ea/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f h1:b1Ln/PG8orm0SsBbHZWke8dDp2lrCD4jSmfglFpTZbk= -google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f h1:RARaIm8pxYuxyNPbBQf5igT7XdOyCNtat1qAT2ZxjU4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed h1:3RgNmBoI9MZhsj3QxC+AP/qQhNwpCLOvYDYYsFrhFt0= +google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:OCdP9MfskevB/rbYvHTsXTtKC+3bHWajPdoKgjcYkfo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed h1:J6izYgfBXAI3xTKLgxzTmUltdYaLsuBxFCgDHWJ/eXg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1746,6 +1746,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= diff --git a/src/autoscaler/models/metrics.go b/src/autoscaler/models/metrics.go index 8a45269b4b..797887d513 100644 --- a/src/autoscaler/models/metrics.go +++ b/src/autoscaler/models/metrics.go @@ -27,7 +27,7 @@ const ( type AppInstanceMetric struct { AppId string `json:"app_id" db:"app_id"` - InstanceIndex uint32 `json:"instance_index" db:"instance_index"` + InstanceIndex uint64 `json:"instance_index" db:"instance_index"` CollectedAt int64 `json:"collected_at" db:"collected_at"` Name string `json:"name" db:"name"` Unit string `json:"unit" db:"unit"` diff --git a/src/autoscaler/scalingengine/striped_lock.go b/src/autoscaler/scalingengine/striped_lock.go index baf9a34d7e..5a1ca9cd6a 100644 --- a/src/autoscaler/scalingengine/striped_lock.go +++ b/src/autoscaler/scalingengine/striped_lock.go @@ -30,5 +30,5 @@ func (sl *StripedLock) GetLock(key string) *sync.Mutex { if err != nil { return nil } - return sl.locks[h.Sum32()%uint32(len(sl.locks))] + return sl.locks[int(h.Sum32())%len(sl.locks)] } diff --git a/src/autoscaler/testhelpers/gomega_extensions.go b/src/autoscaler/testhelpers/gomega_extensions.go index a8c41d0e22..596306b676 100644 --- a/src/autoscaler/testhelpers/gomega_extensions.go +++ b/src/autoscaler/testhelpers/gomega_extensions.go @@ -10,34 +10,27 @@ var noOpHandler = func(_ http.ResponseWriter, _ *http.Request) { } func RespondWithMultiple(handlers ...http.HandlerFunc) http.HandlerFunc { - var responseNumber int32 = 0 + var responseNumber int64 = 0 if len(handlers) > 0 { return func(w http.ResponseWriter, req *http.Request) { - responseNum := atomic.LoadInt32(&responseNumber) - handlerNumber := Min(responseNum, int32(len(handlers)-1)) + responseNum := atomic.LoadInt64(&responseNumber) + handlerNumber := min(responseNum, int64(len(handlers)-1)) handlers[handlerNumber](w, req) - atomic.AddInt32(&responseNumber, 1) + atomic.AddInt64(&responseNumber, 1) } } return noOpHandler } func RoundRobinWithMultiple(handlers ...http.HandlerFunc) http.HandlerFunc { - var responseNumber int32 = 0 + var responseNumber int64 = 0 if len(handlers) > 0 { return func(w http.ResponseWriter, req *http.Request) { - handlerNumber := atomic.LoadInt32(&responseNumber) % int32(len(handlers)) + handlerNumber := atomic.LoadInt64(&responseNumber) % int64(len(handlers)) handlers[handlerNumber](w, req) - atomic.AddInt32(&responseNumber, 1) + atomic.AddInt64(&responseNumber, 1) } } return noOpHandler } - -func Min(one, two int32) int32 { - if one < two { - return one - } - return two -} diff --git a/src/changelog/github/github.go b/src/changelog/github/github.go index b581c45383..26c5b619b4 100644 --- a/src/changelog/github/github.go +++ b/src/changelog/github/github.go @@ -238,7 +238,7 @@ func (g GitHub) FetchPullRequests(startingCommitSHA, lastCommitSHA string) ([]Pu } } -func (g GitHub) FetchLabelsForPullRequest(owner, repo string, pullRequestNumber int) ([]string, error) { +func (g GitHub) FetchLabelsForPullRequest(owner, repo string, pullRequestNumber int32) ([]string, error) { var PullRequestlabelsQuery struct { Repository struct { PullRequest struct {