Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
k8s.io/apimachinery v0.34.1
k8s.io/client-go v0.34.1
k8s.io/component-base v0.34.1
sigs.k8s.io/controller-runtime v0.21.0
sigs.k8s.io/controller-runtime v0.22.1
sigs.k8s.io/yaml v1.6.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOP
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=
Expand Down
8 changes: 7 additions & 1 deletion internal/controller/runtime/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package runtime
import (
"context"

"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -26,20 +27,25 @@ 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
ClientDeleteAll func(context.Context, client.Object, ...client.DeleteAllOfOption) error
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{}
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/runtime/pod_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions internal/upgradecheck/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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\"}]}`))
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Loading