From 578f3b757d6b57f97fe956bc565c492e2497e6d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Sep 2025 06:42:32 +0000 Subject: [PATCH 1/8] CLOUD-727: Bump sigs.k8s.io/controller-runtime from 0.21.0 to 0.22.1 Bumps [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) from 0.21.0 to 0.22.1. - [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases) - [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.21.0...v0.22.1) --- updated-dependencies: - dependency-name: sigs.k8s.io/controller-runtime dependency-version: 0.22.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 28438fa02..af1272188 100644 --- a/go.mod +++ b/go.mod @@ -35,8 +35,8 @@ require ( k8s.io/api v0.34.1 k8s.io/apimachinery v0.34.1 k8s.io/client-go v0.34.1 - k8s.io/component-base v0.33.4 - sigs.k8s.io/controller-runtime v0.21.0 + k8s.io/component-base v0.34.0 + sigs.k8s.io/controller-runtime v0.22.1 sigs.k8s.io/yaml v1.6.0 ) @@ -139,7 +139,7 @@ require ( google.golang.org/protobuf v1.36.7 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.33.4 + k8s.io/apiextensions-apiserver v0.34.0 k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 diff --git a/go.sum b/go.sum index a746e80b0..86b3cccf1 100644 --- a/go.sum +++ b/go.sum @@ -362,22 +362,22 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM= k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk= -k8s.io/apiextensions-apiserver v0.33.4 h1:rtq5SeXiDbXmSwxsF0MLe2Mtv3SwprA6wp+5qh/CrOU= -k8s.io/apiextensions-apiserver v0.33.4/go.mod h1:mWXcZQkQV1GQyxeIjYApuqsn/081hhXPZwZ2URuJeSs= +k8s.io/apiextensions-apiserver v0.34.0 h1:B3hiB32jV7BcyKcMU5fDaDxk882YrJ1KU+ZSkA9Qxoc= +k8s.io/apiextensions-apiserver v0.34.0/go.mod h1:hLI4GxE1BDBy9adJKxUxCEHBGZtGfIg98Q+JmTD7+g0= k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4= k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= k8s.io/client-go v0.34.1 h1:ZUPJKgXsnKwVwmKKdPfw4tB58+7/Ik3CrjOEhsiZ7mY= k8s.io/client-go v0.34.1/go.mod h1:kA8v0FP+tk6sZA0yKLRG67LWjqufAoSHA2xVGKw9Of8= -k8s.io/component-base v0.33.4 h1:Jvb/aw/tl3pfgnJ0E0qPuYLT0NwdYs1VXXYQmSuxJGY= -k8s.io/component-base v0.33.4/go.mod h1:567TeSdixWW2Xb1yYUQ7qk5Docp2kNznKL87eygY8Rc= +k8s.io/component-base v0.34.0 h1:bS8Ua3zlJzapklsB1dZgjEJuJEeHjj8yTu1gxE2zQX8= +k8s.io/component-base v0.34.0/go.mod h1:RSCqUdvIjjrEm81epPcjQ/DS+49fADvGSCkIP3IC6vg= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA= k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.21.0 h1:CYfjpEuicjUecRk+KAeyYh+ouUBn4llGyDYytIGcJS8= -sigs.k8s.io/controller-runtime v0.21.0/go.mod h1:OSg14+F65eWqIu4DceX7k/+QRAbTTvxeQSNSOQpukWM= +sigs.k8s.io/controller-runtime v0.22.1 h1:Ah1T7I+0A7ize291nJZdS1CabF/lB4E++WizgV24Eqg= +sigs.k8s.io/controller-runtime v0.22.1/go.mod h1:FwiwRjkRPbiN+zp2QRp7wlTCzbUXxZ/D4OzuQUDwBHY= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= From 727d93fff3f951500fc945de02c66f194451eadc Mon Sep 17 00:00:00 2001 From: George Kechagias Date: Mon, 29 Sep 2025 12:10:13 +0300 Subject: [PATCH 2/8] introduce ToUnstructured for PITRestoreDateTime --- pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go index 5e0fd6d3f..92be7a6d4 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go @@ -137,6 +137,13 @@ func (t *PITRestoreDateTime) MarshalJSON() ([]byte, error) { return json.Marshal(t.Time.Format("2006-01-02 15:04:05.000000-0700")) } +func (t *PITRestoreDateTime) ToUnstructured() interface{} { + if t.Time == nil { + return nil + } + return t.Time.ToUnstructured() +} + type PGBackupStorageType string const ( From 8681569f7f34e74c5d353942a1476220aad8cfb2 Mon Sep 17 00:00:00 2001 From: George Kechagias Date: Mon, 29 Sep 2025 12:31:05 +0300 Subject: [PATCH 3/8] fixes on client.go of runtime and pod client for unstructed --- internal/controller/runtime/client.go | 8 +++++++- internal/controller/runtime/pod_client.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/controller/runtime/client.go b/internal/controller/runtime/client.go index 4cc05c983..3e2cb681d 100644 --- a/internal/controller/runtime/client.go +++ b/internal/controller/runtime/client.go @@ -7,6 +7,7 @@ package runtime import ( "context" + "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -26,6 +27,7 @@ var _ client.Reader = ClientReader{} // Types that implement single methods of the [client.Writer] interface. type ( + ClientApply func(context.Context, runtime.ApplyConfiguration, ...client.ApplyOption) error ClientCreate func(context.Context, client.Object, ...client.CreateOption) error ClientDelete func(context.Context, client.Object, ...client.DeleteOption) error ClientPatch func(context.Context, client.Object, client.Patch, ...client.PatchOption) error @@ -33,13 +35,17 @@ type ( ClientUpdate func(context.Context, client.Object, ...client.UpdateOption) error ) -// ClientWriter implements [client.Writer] by composing assignable functions. type ClientWriter struct { ClientCreate ClientDelete ClientDeleteAll ClientPatch ClientUpdate + ClientApply +} + +func (fn ClientApply) Apply(ctx context.Context, obj runtime.ApplyConfiguration, opts ...client.ApplyOption) error { + return fn(ctx, obj, opts...) } var _ client.Writer = ClientWriter{} diff --git a/internal/controller/runtime/pod_client.go b/internal/controller/runtime/pod_client.go index 4122303bf..739749836 100644 --- a/internal/controller/runtime/pod_client.go +++ b/internal/controller/runtime/pod_client.go @@ -31,7 +31,7 @@ func newPodClient(config *rest.Config) (rest.Interface, error) { if err != nil { return nil, err } - return apiutil.RESTClientForGVK(gvk, false, config, codecs, httpClient) + return apiutil.RESTClientForGVK(gvk, false, false, config, codecs, httpClient) } // +kubebuilder:rbac:groups="",resources="pods/exec",verbs={create} From 9448d38a0bff753d4b7a7614939b9e22f25b6a85 Mon Sep 17 00:00:00 2001 From: George Kechagias Date: Mon, 29 Sep 2025 13:12:29 +0300 Subject: [PATCH 4/8] fixes for scheduler test --- internal/upgradecheck/http_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/upgradecheck/http_test.go b/internal/upgradecheck/http_test.go index c50b92c41..bae74b1ce 100644 --- a/internal/upgradecheck/http_test.go +++ b/internal/upgradecheck/http_test.go @@ -208,8 +208,8 @@ func TestCheckForUpgradesScheduler(t *testing.T) { }, nil } - // Set loop time to 1s and sleep for 2s before sending the done signal - ctx, cancel := context.WithTimeout(ctx, 2*time.Second) + // Set loop time to 1s and sleep for 5s before sending the done signal + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() s := CheckForUpgradesScheduler{ Client: fakeClient, @@ -220,7 +220,7 @@ func TestCheckForUpgradesScheduler(t *testing.T) { // Sleeping leads to some non-deterministic results, but we expect at least 2 executions // plus one log for the failure to apply the configmap - assert.Assert(t, len(calls) >= 4) + assert.Assert(t, len(calls) >= 4, fmt.Sprintf("expected at least 4 calls, got %d", len(calls))) assert.Assert(t, cmp.Contains(calls[1], `{\"pgo_versions\":[{\"tag\":\"v5.0.4\"},{\"tag\":\"v5.0.3\"},{\"tag\":\"v5.0.2\"},{\"tag\":\"v5.0.1\"},{\"tag\":\"v5.0.0\"}]}`)) assert.Assert(t, cmp.Contains(calls[3], `{\"pgo_versions\":[{\"tag\":\"v5.0.4\"},{\"tag\":\"v5.0.3\"},{\"tag\":\"v5.0.2\"},{\"tag\":\"v5.0.1\"},{\"tag\":\"v5.0.0\"}]}`)) From 00ba9d7242abdc9ef0fd078bd9d8de08632873c1 Mon Sep 17 00:00:00 2001 From: George Kechagias Date: Mon, 29 Sep 2025 13:22:56 +0300 Subject: [PATCH 5/8] log calls for debug --- internal/upgradecheck/http_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/upgradecheck/http_test.go b/internal/upgradecheck/http_test.go index bae74b1ce..948f366e4 100644 --- a/internal/upgradecheck/http_test.go +++ b/internal/upgradecheck/http_test.go @@ -184,6 +184,8 @@ func TestCheckForUpgradesScheduler(t *testing.T) { } s.check(ctx) + fmt.Println(calls) + assert.Equal(t, len(calls), 2) assert.Assert(t, cmp.Contains(calls[1], `encountered panic in upgrade check`)) }) From a39a30a91c4be68ce7c31d99259a7c68a145e135 Mon Sep 17 00:00:00 2001 From: George Kechagias Date: Mon, 29 Sep 2025 13:49:26 +0300 Subject: [PATCH 6/8] more debug --- internal/upgradecheck/http_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/upgradecheck/http_test.go b/internal/upgradecheck/http_test.go index 948f366e4..e201a88e2 100644 --- a/internal/upgradecheck/http_test.go +++ b/internal/upgradecheck/http_test.go @@ -183,6 +183,7 @@ func TestCheckForUpgradesScheduler(t *testing.T) { Config: cfg, } s.check(ctx) + time.Sleep(5 * time.Second) fmt.Println(calls) From cde7b52bf66e3103a029b3dbfe2cd37c94835a16 Mon Sep 17 00:00:00 2001 From: George Kechagias Date: Mon, 29 Sep 2025 15:21:06 +0300 Subject: [PATCH 7/8] restore fmt and sleep --- internal/upgradecheck/http_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/internal/upgradecheck/http_test.go b/internal/upgradecheck/http_test.go index e201a88e2..bae74b1ce 100644 --- a/internal/upgradecheck/http_test.go +++ b/internal/upgradecheck/http_test.go @@ -183,9 +183,6 @@ func TestCheckForUpgradesScheduler(t *testing.T) { Config: cfg, } s.check(ctx) - time.Sleep(5 * time.Second) - - fmt.Println(calls) assert.Equal(t, len(calls), 2) assert.Assert(t, cmp.Contains(calls[1], `encountered panic in upgrade check`)) From b040993872e83a4645698e9edffd9d935ac45727 Mon Sep 17 00:00:00 2001 From: George Kechagias Date: Wed, 15 Oct 2025 18:44:49 +0300 Subject: [PATCH 8/8] test --- internal/upgradecheck/http_test.go | 59 +++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/internal/upgradecheck/http_test.go b/internal/upgradecheck/http_test.go index bae74b1ce..1b6277060 100644 --- a/internal/upgradecheck/http_test.go +++ b/internal/upgradecheck/http_test.go @@ -11,6 +11,8 @@ import ( "fmt" "io" "net/http" + "os" + "runtime" "strings" "testing" "time" @@ -163,18 +165,46 @@ func TestCheckForUpgradesScheduler(t *testing.T) { cfg := &rest.Config{Host: server.URL} t.Run("panic from checkForUpgrades doesn't bubble up", func(t *testing.T) { + // Debug: Print comprehensive environment information + t.Logf("=== ENVIRONMENT DEBUG INFO ===") + t.Logf("Go Version: %s", runtime.Version()) + t.Logf("GOOS: %s", runtime.GOOS) + t.Logf("GOARCH: %s", runtime.GOARCH) + t.Logf("NumCPU: %d", runtime.NumCPU()) + t.Logf("Compiler: %s", runtime.Compiler) + + // Log relevant environment variables + envVars := []string{ + "CI", "GITHUB_ACTIONS", "GITHUB_WORKFLOW", "GITHUB_RUN_ID", + "RUNNER_OS", "RUNNER_ARCH", "RUNNER_TEMP", + "GOMAXPROCS", "GODEBUG", "GOTRACEBACK", + "TEST_TMPDIR", "TMPDIR", "TMP", "TEMP", + } + for _, envVar := range envVars { + if val := os.Getenv(envVar); val != "" { + t.Logf("ENV %s=%s", envVar, val) + } + } + ctx := context.Background() // capture logs var calls []string + var loggerCallCount int ctx = logging.NewContext(ctx, funcr.NewJSON(func(object string) { + loggerCallCount++ + t.Logf("Logger callback invoked #%d: %s", loggerCallCount, object) calls = append(calls, object) }, funcr.Options{ Verbosity: 1, })) + // Track if panic was actually triggered + var panicTriggered bool // A panicking call funcFoo = func() (*http.Response, error) { + panicTriggered = true + t.Logf("funcFoo called - about to panic") panic(fmt.Errorf("oh no!")) } @@ -182,10 +212,35 @@ func TestCheckForUpgradesScheduler(t *testing.T) { Client: fakeClient, Config: cfg, } + + t.Logf("About to call s.check(ctx)") s.check(ctx) + t.Logf("s.check(ctx) returned normally") + + // Debug: Print all captured log calls + t.Logf("=== TEST RESULTS ===") + t.Logf("Panic was triggered: %v", panicTriggered) + t.Logf("Total logger callbacks: %d", loggerCallCount) + t.Logf("Total calls captured in slice: %d", len(calls)) + for i, call := range calls { + t.Logf("Call[%d]: %s", i, call) + } + + // Debug: Check environment differences + t.Logf("Server URL: %s", server.URL) + t.Logf("Config Host: %s", cfg.Host) - assert.Equal(t, len(calls), 2) - assert.Assert(t, cmp.Contains(calls[1], `encountered panic in upgrade check`)) + // Debug: Check scheduler state + t.Logf("Scheduler Client: %v", s.Client != nil) + t.Logf("Scheduler Config: %v", s.Config != nil) + + assert.Equal(t, len(calls), 2, "expected exactly 2 log calls") + if len(calls) > 1 { + assert.Assert(t, cmp.Contains(calls[1], `encountered panic in upgrade check`), + "expected second log to contain panic message, got: %s", calls[1]) + } else { + t.Fatalf("expected at least 2 calls but got %d", len(calls)) + } }) t.Run("successful log each loop, ticker works", func(t *testing.T) {