Skip to content
Merged
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 @@ -55,7 +55,7 @@ require (
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
layeh.com/gopher-json v0.0.0-20201124131017-552bb3c4c3bf
sigs.k8s.io/cluster-api v1.7.1
sigs.k8s.io/controller-runtime v0.21.0
sigs.k8s.io/controller-runtime v0.22.4
sigs.k8s.io/custom-metrics-apiserver v1.33.0
sigs.k8s.io/kind v0.29.0
sigs.k8s.io/mcs-api v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1
sigs.k8s.io/cluster-api v1.7.1 h1:JkMAbAMzBM+WBHxXLTJXTiCisv1PAaHRzld/3qrmLYY=
sigs.k8s.io/cluster-api v1.7.1/go.mod h1:V9ZhKLvQtsDODwjXOKgbitjyCmC71yMBwDcMyNNIov0=
sigs.k8s.io/controller-runtime v0.6.1/go.mod h1:XRYBPdbf5XJu9kpS84VJiZ7h/u1hF3gEORz0efEja7A=
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.4 h1:GEjV7KV3TY8e+tJ2LCTxUTanW4z/FmNB7l327UfMq9A=
sigs.k8s.io/controller-runtime v0.22.4/go.mod h1:+QX1XUpTXN4mLoblf4tqr5CQcyHPAki2HLXqQMY6vh8=
sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI=
sigs.k8s.io/custom-metrics-apiserver v1.33.0 h1:9uHgBT8ah8PZG+iMAhkXH25kIOmWs7JcrasFA0d83rI=
sigs.k8s.io/custom-metrics-apiserver v1.33.0/go.mod h1:7lxzUW4z5aEaXOtqOdzh8+pzJ/gT/E3B6LooxIP3tKc=
Expand Down
10 changes: 10 additions & 0 deletions pkg/controllers/execution/execution_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,16 @@ func (c *Controller) updateWorkDispatchingConditionIfNeeded(ctx context.Context,
return err
}

if work.GetObjectKind().GroupVersionKind().Empty() {
// In unit tests, we need to verify how many events are emitted. However, when using the fake client,
// the work object may not have TypeMeta (APIVersion/Kind) set, which prevents building a proper
// object reference and thus no event is actually emitted. This workaround ensures the GVK is set
// so event emission, and thereby event counting in unit tests, works as expected.
// Since controller-runtime v0.22.0, the group version kind is not set when using fake client.
// See https://github.com/kubernetes-sigs/controller-runtime/pull/3229 for more details.
work.SetGroupVersionKind(workv1alpha1.SchemeGroupVersion.WithKind("Work"))
}

obj, err := helper.ToUnstructured(work)
if err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions pkg/controllers/federatedhpa/federatedhpa_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func (m *MockClient) List(ctx context.Context, list client.ObjectList, opts ...c
return args.Error(0)
}

func (m *MockClient) Apply(ctx context.Context, obj runtime.ApplyConfiguration, opts ...client.ApplyOption) error {
args := m.Called(ctx, obj, opts)
return args.Error(0)
}

func (m *MockClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error {
args := m.Called(ctx, obj, opts)
return args.Error(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,11 @@ func (m *MockClient) List(ctx context.Context, list client.ObjectList, opts ...c
return args.Error(0)
}

func (m *MockClient) Apply(ctx context.Context, obj runtime.ApplyConfiguration, opts ...client.ApplyOption) error {
args := m.Called(ctx, obj, opts)
return args.Error(0)
}

func (m *MockClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error {
args := m.Called(ctx, obj, opts)
return args.Error(0)
Expand Down
8 changes: 8 additions & 0 deletions pkg/controllers/namespace/namespace_sync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques

return controllerruntime.Result{}, err
}
if namespace.GetObjectKind().GroupVersionKind().Empty() {
// In unit tests, we need to verify that a work object is created for the corresponding namespace.
// However, the fake client does not set TypeMeta information, which results in an incorrect generated work object name.
// This ensures correct GVK is set so work name generation in tests works as expected.
// Since controller-runtime v0.22.0, the group version kind is not set when using fake client.
// See https://github.com/kubernetes-sigs/controller-runtime/pull/3229 for more details.
namespace.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("Namespace"))
}

if !namespace.DeletionTimestamp.IsZero() {
// Do nothing, just return as we have added owner reference to Work.
Expand Down
3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ sigs.k8s.io/cluster-api/errors
sigs.k8s.io/cluster-api/feature
sigs.k8s.io/cluster-api/util/certs
sigs.k8s.io/cluster-api/util/secret
# sigs.k8s.io/controller-runtime v0.21.0
# sigs.k8s.io/controller-runtime v0.22.4
## explicit; go 1.24.0
sigs.k8s.io/controller-runtime
sigs.k8s.io/controller-runtime/pkg/builder
Expand Down Expand Up @@ -1859,6 +1859,7 @@ sigs.k8s.io/controller-runtime/pkg/webhook
sigs.k8s.io/controller-runtime/pkg/webhook/admission
sigs.k8s.io/controller-runtime/pkg/webhook/admission/metrics
sigs.k8s.io/controller-runtime/pkg/webhook/conversion
sigs.k8s.io/controller-runtime/pkg/webhook/conversion/metrics
sigs.k8s.io/controller-runtime/pkg/webhook/internal/metrics
# sigs.k8s.io/custom-metrics-apiserver v1.33.0
## explicit; go 1.24.0
Expand Down
10 changes: 10 additions & 0 deletions vendor/sigs.k8s.io/controller-runtime/.golangci.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vendor/sigs.k8s.io/controller-runtime/OWNERS_ALIASES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/sigs.k8s.io/controller-runtime/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/sigs.k8s.io/controller-runtime/VERSIONING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 88 additions & 5 deletions vendor/sigs.k8s.io/controller-runtime/pkg/cache/cache.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading