Skip to content

SANDBOX-808: update kube & openshift dependencies to 4.17 #1146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
25 changes: 25 additions & 0 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: govulncheck
on:
pull_request:
branches:
- master

jobs:
govulncheck:
name: govulncheck
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Generate Assets
run: |
make generate-assets

- name: Run govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-file: go.mod
go-package: ./...
repo-checkout: false
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is the CodeReady Toolchain Host Operator repository. It contains the OpenSh

== Build

Requires Go version 1.21.x (1.21.13 or higher) - download for your development environment https://golang.org/dl/[here].
Requires Go version 1.22.x (1.22.12 or higher) - download for your development environment https://golang.org/dl/[here].

This repository uses https://github.com/golang/go/wiki/Modules[Go modules].

Expand Down
4 changes: 2 additions & 2 deletions controllers/masteruserrecord/masteruserrecord_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

// watch UserAccounts in all the member clusters
for _, memberCluster := range memberClusters {
b = b.WatchesRawSource(source.Kind(memberCluster.Cache, &toolchainv1alpha1.UserAccount{}),
b = b.WatchesRawSource(source.Kind[runtimeclient.Object](memberCluster.Cache, &toolchainv1alpha1.UserAccount{},

Check warning on line 50 in controllers/masteruserrecord/masteruserrecord_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/masteruserrecord/masteruserrecord_controller.go#L50

Added line #L50 was not covered by tests
handler.EnqueueRequestsFromMapFunc(mapper.MapByResourceName(r.Namespace)),
)
))

Check warning on line 52 in controllers/masteruserrecord/masteruserrecord_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/masteruserrecord/masteruserrecord_controller.go#L52

Added line #L52 was not covered by tests
Comment on lines +50 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not really related to this particular case since the mapper is generic, but there a function

handler.TypedEnqueueRequestsFromMapFunc

that takes the type provided in the source.Kind function and use it as the generics to provide the same type down to the mapper and predicate. This can be very useful in the mappers and predicates that are specific to resource kind like this one:

func MapBannedUserToUserSignup(cl runtimeclient.Client) func(ctx context.Context, object runtimeclient.Object) []reconcile.Request {
var logger = ctrl.Log.WithName("BannedUserToUserSignupMapper")
return func(ctx context.Context, obj runtimeclient.Object) []reconcile.Request {
if bu, ok := obj.(*toolchainv1alpha1.BannedUser); ok {

or this one:
func MapToolchainStatusToSpaceProvisionerConfigs(cl runtimeclient.Client) func(context.Context, runtimeclient.Object) []reconcile.Request {
return func(ctx context.Context, obj runtimeclient.Object) []reconcile.Request {
if _, ok := obj.(*toolchainv1alpha1.ToolchainStatus); !ok {
return nil
}

and there will be a few more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean replacing EnqueueRequestsFromMapFunc with TypedEnqueueRequestsFromMapFunc on those calls and refactoring the code?

}
return b.Complete(r)
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/space/space_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@
func (r *Reconciler) SetupWithManager(mgr ctrl.Manager, memberClusters map[string]cluster.Cluster) error {
b := ctrl.NewControllerManagedBy(mgr).
// watch Spaces in the host cluster
For(&toolchainv1alpha1.Space{}, builder.WithPredicates(predicate.Or(predicate.GenerationChangedPredicate{}, predicate.AnnotationChangedPredicate{}))).
For(&toolchainv1alpha1.Space{}, builder.WithPredicates(predicate.Or[runtimeclient.Object](predicate.GenerationChangedPredicate{}, predicate.AnnotationChangedPredicate{}))).

Check warning on line 50 in controllers/space/space_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/space/space_controller.go#L50

Added line #L50 was not covered by tests
Watches(&toolchainv1alpha1.NSTemplateTier{},
handler.EnqueueRequestsFromMapFunc(MapNSTemplateTierToSpaces(r.Namespace, r.Client))).
Watches(&toolchainv1alpha1.SpaceBinding{},
handler.EnqueueRequestsFromMapFunc(MapSpaceBindingToParentAndSubSpaces(r.Client)))
// watch NSTemplateSets in all the member clusters
for _, memberCluster := range memberClusters {
b = b.WatchesRawSource(source.Kind(memberCluster.Cache, &toolchainv1alpha1.NSTemplateSet{}),
b = b.WatchesRawSource(source.Kind[runtimeclient.Object](memberCluster.Cache, &toolchainv1alpha1.NSTemplateSet{},

Check warning on line 57 in controllers/space/space_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/space/space_controller.go#L57

Added line #L57 was not covered by tests
handler.EnqueueRequestsFromMapFunc(mapper.MapByResourceName(r.Namespace)),
)
))

Check warning on line 59 in controllers/space/space_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/space/space_controller.go#L59

Added line #L59 was not covered by tests
}
return b.Complete(r)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -49,9 +48,9 @@
// Watch SpaceBindingRequests in all member clusters and all namespaces.
for _, memberCluster := range memberClusters {
b = b.WatchesRawSource(
source.Kind(memberCluster.Cache, &toolchainv1alpha1.SpaceBindingRequest{}),
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.GenerationChangedPredicate{}))
source.Kind[runtimeclient.Object](memberCluster.Cache, &toolchainv1alpha1.SpaceBindingRequest{},
&handler.EnqueueRequestForObject{},
predicate.GenerationChangedPredicate{}))

Check warning on line 53 in controllers/spacebindingrequest/spacebindingrequest_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/spacebindingrequest/spacebindingrequest_controller.go#L51-L53

Added lines #L51 - L53 were not covered by tests
Comment on lines +51 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, there are typed versions of the handlers and predicates, so you can use it:

source.Kind(memberCluster.Cache, &toolchainv1alpha1.SpaceBindingRequest{},
	&handler.TypedEnqueueRequestForObject[*toolchainv1alpha1.SpaceBindingRequest]{},
	predicate.TypedGenerationChangedPredicate[*toolchainv1alpha1.SpaceBindingRequest]{}))

but I'm not sure if it makes any sense in this particular case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I tried that way when I saw that we needed to refactor the code. It gives this error:

type predicate.TypedGenerationChangedPredicate[*v1alpha1.SpaceBindingRequest] of predicate.TypedGenerationChangedPredicate[*toolchainv1alpha1.SpaceBindingRequest]{} does not match predicate.TypedPredicate[T] (cannot infer T)compilerCannotInferTypeArgs

}
return b.Complete(r)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc, Is(Ready()), Has(ConsumedSpaceCount(3)), Has(ConsumedMemoryUsage(map[string]int{"worker": 50})))
})

Expand All @@ -74,7 +74,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Is(NotReadyWithReason(toolchainv1alpha1.SpaceProvisionerConfigDisabledReason)),
Has(UnknownConsumedCapacity()))
Expand All @@ -91,7 +91,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Is(NotReadyWithReason(toolchainv1alpha1.SpaceProvisionerConfigToolchainClusterNotFoundReason)),
Has(UnknownConsumedCapacity()))
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Is(NotReadyWithReason(toolchainv1alpha1.SpaceProvisionerConfigToolchainClusterNotFoundReason)),
Has(UnknownConsumedCapacity()))
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Is(NotReadyWithReason(toolchainv1alpha1.SpaceProvisionerConfigToolchainClusterNotReadyReason)),
Has(UnknownConsumedCapacity()))
Expand All @@ -172,7 +172,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Is(NotReadyWithReason(toolchainv1alpha1.SpaceProvisionerConfigInsufficientCapacityReason)),
Has(ConsumedSpaceCount(5)),
Expand All @@ -199,7 +199,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Is(NotReadyWithReason(toolchainv1alpha1.SpaceProvisionerConfigInsufficientCapacityReason)),
Has(ConsumedSpaceCount(3)),
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Is(NotReadyWithReason(toolchainv1alpha1.SpaceProvisionerConfigInsufficientCapacityReason)),
Has(ConsumedSpaceCount(3)),
Expand All @@ -245,7 +245,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Has(ReadyStatusAndReason(corev1.ConditionUnknown, toolchainv1alpha1.SpaceProvisionerConfigInsufficientCapacityReason)),
Has(UnknownConsumedCapacity()))
Expand All @@ -268,7 +268,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Has(ReadyStatusAndReason(corev1.ConditionUnknown, toolchainv1alpha1.SpaceProvisionerConfigInsufficientCapacityReason)),
Has(ConsumedSpaceCount(3)),
Expand All @@ -294,7 +294,7 @@ func TestSpaceProvisionerConfigReadinessTracking(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
AssertThat(t, spc,
Is(Ready()),
Has(ConsumedSpaceCount(3_000_000)),
Expand All @@ -318,7 +318,7 @@ func TestSpaceProvisionerConfigReEnqueing(t *testing.T) {
_, reconcileErr := r.Reconcile(context.TODO(), req)

// then
assert.ErrorIs(t, reconcileErr, expectedErr)
require.ErrorIs(t, reconcileErr, expectedErr)
})
t.Run("re-enqueues and reports error in status on failure to get ToolchainCluster", func(t *testing.T) {
// given
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestSpaceProvisionerConfigReEnqueing(t *testing.T) {
_, reconcileErr := r.Reconcile(context.TODO(), req)

// then
assert.ErrorIs(t, reconcileErr, expectedErr)
require.ErrorIs(t, reconcileErr, expectedErr)
})
t.Run("doesn't re-enqueue when object not found", func(t *testing.T) {
// given
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestSpaceProvisionerConfigReEnqueing(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
assert.False(t, res.Requeue)
assert.Empty(t, spc.Status.Conditions)
})
Expand All @@ -406,7 +406,7 @@ func TestSpaceProvisionerConfigReEnqueing(t *testing.T) {
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(spc), spc))

// then
assert.NoError(t, reconcileErr)
require.NoError(t, reconcileErr)
assert.False(t, res.Requeue)
assert.NotEmpty(t, spc.Status.Conditions)
})
Expand Down
7 changes: 3 additions & 4 deletions controllers/spacerequest/spacerequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/handler"
Expand Down Expand Up @@ -60,9 +59,9 @@
// Watch SpaceRequests in all member clusters and all namespaces.
for _, memberCluster := range memberClusters {
b = b.WatchesRawSource(
source.Kind(memberCluster.Cache, &toolchainv1alpha1.SpaceRequest{}),
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.GenerationChangedPredicate{}))
source.Kind[runtimeclient.Object](memberCluster.Cache, &toolchainv1alpha1.SpaceRequest{},
&handler.EnqueueRequestForObject{},
predicate.GenerationChangedPredicate{}))

Check warning on line 64 in controllers/spacerequest/spacerequest_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/spacerequest/spacerequest_controller.go#L62-L64

Added lines #L62 - L64 were not covered by tests
}
return b.Complete(r)
}
Expand Down
37 changes: 19 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ module github.com/codeready-toolchain/host-operator

require (
cloud.google.com/go/recaptchaenterprise/v2 v2.13.0
github.com/codeready-toolchain/api v0.0.0-20250304130838-c9c2ff18f4de
github.com/codeready-toolchain/toolchain-common v0.0.0-20250303095208-d379ee86d136
github.com/codeready-toolchain/api v0.0.0-20250313170542-4e3c4147cb80
github.com/codeready-toolchain/toolchain-common v0.0.0-20250313203311-0bce6563576f
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/go-logr/logr v1.4.1
github.com/gofrs/uuid v4.4.0+incompatible
github.com/mailgun/mailgun-go/v4 v4.8.1
// using latest commit from 'github.com/openshift/api branch release-4.16'
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094
// using latest commit from 'github.com/openshift/library-go branch release-4.16'
github.com/openshift/library-go v0.0.0-20240711192904-190fec8c3f09 // indirect
// using latest commit from 'github.com/openshift/api branch release-4.17'
github.com/openshift/api v0.0.0-20250214103856-0cfc958f642b
// using latest commit from 'github.com/openshift/library-go branch release-4.17'
github.com/openshift/library-go v0.0.0-20241118144106-bfd968d8eef4 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.18.0
github.com/redhat-cop/operator-utils v1.3.8
Expand All @@ -22,13 +22,13 @@ require (
go.uber.org/zap v1.26.0
gopkg.in/h2non/gock.v1 v1.0.14
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.29.2
k8s.io/apiextensions-apiserver v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
k8s.io/api v0.30.1
k8s.io/apiextensions-apiserver v0.30.1
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.110.1
sigs.k8s.io/controller-runtime v0.17.3
k8s.io/klog/v2 v2.120.1
sigs.k8s.io/controller-runtime v0.18.4
)

require (
Expand All @@ -46,7 +46,7 @@ require (
github.com/cloudflare/circl v1.3.7 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
Expand Down Expand Up @@ -115,10 +115,9 @@ require (
google.golang.org/protobuf v1.34.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/cli-runtime v0.29.2 // indirect
k8s.io/component-base v0.29.2 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/kubectl v0.29.2 // indirect
k8s.io/cli-runtime v0.30.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kubectl v0.30.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
Expand All @@ -127,4 +126,6 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

go 1.21
go 1.22.0

toolchain go1.22.12
Loading
Loading