Skip to content
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

Update k8s dependencies to 4.14 and controller-runtime to v0.15 #376

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

ranakan19
Copy link
Contributor

@ranakan19 ranakan19 commented Mar 20, 2024

Updates k8s dependencies to 0.27 and controller-runtime to v0.15.
With the update to controller-runtime v0.15 (changes in release detailed here), this PR has following changes to combat the breaking changes:

Changes wrt - https://issues.redhat.com/browse/SANDBOX-558
DO NOT MERGE (All the PRs related to version updates need to be merged at once, but these PR are for early feedback so that there are not a lot of changes to review at once)

Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 76.19048% with 5 lines in your changes missing coverage. Please review.

Project coverage is 77.51%. Comparing base (f768864) to head (007ae28).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/test/client.go 75.00% 4 Missing ⚠️
...resources/toolchaincluster_resources_controller.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #376      +/-   ##
==========================================
+ Coverage   77.47%   77.51%   +0.03%     
==========================================
  Files          49       49              
  Lines        2007     2019      +12     
==========================================
+ Hits         1555     1565      +10     
- Misses        398      400       +2     
  Partials       54       54              
Files with missing lines Coverage Δ
controllers/label_event_handler.go 100.00% <100.00%> (ø)
...resources/toolchaincluster_resources_controller.go 38.09% <0.00%> (ø)
pkg/test/client.go 75.00% <75.00%> (+0.96%) ⬆️

@@ -16,13 +16,14 @@ import (
)

// NewFakeClient creates a fake K8s client with ability to override specific Get/List/Create/Update/StatusUpdate/Delete functions
func NewFakeClient(t T, initObjs ...runtime.Object) *FakeClient {
func NewFakeClient(t T, initObjs ...client.Object) *FakeClient {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes initObjs type from runtime.Object to client.Object - see discussion here
WithStatusSubresource can only accept client.Object was a major reason to consider making this change.

Copy link
Contributor

@mfrancisc mfrancisc left a comment

Choose a reason for hiding this comment

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

Nice Job!

I have only few minor comments.

@@ -15,6 +16,7 @@ func TestLabelMapper(t *testing.T) {

t.Run("resource with expected label", func(t *testing.T) {
// given
ctx := context.TODO()
Copy link
Contributor

Choose a reason for hiding this comment

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

minor - we could move the context creation up in the parent test

created.Status.Replicas = 2
require.NoError(t, fclient.Status().Update(context.TODO(), created))
require.NoError(t, fclient.Get(context.TODO(), types.NamespacedName{Namespace: "somenamespace", Name: created.Name}, retrieved))
assert.EqualValues(t, 2, retrieved.Status.Replicas) // replicas count changed to 2
Copy link
Contributor

Choose a reason for hiding this comment

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

should we check that generation is 1 or it doesn't bring any benefit ?

Copy link

sonarcloud bot commented May 1, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
5.0% Duplication on New Code

See analysis details on SonarCloud

s := scheme.Scheme
err := toolchainv1alpha1.AddToScheme(s)
require.NoError(t, err)
cl := fake.NewClientBuilder().
WithScheme(s).
WithRuntimeObjects(initObjs...).
WithObjects(initObjs...).
WithStatusSubresource(initObjs...).
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to our discussion in the host-operator PR, we could try to improve this logic to register status sub-resource for all "toolchain" resources. In this way we would know that, the status sub-resource is registered for all objects we manage.
So, could you go through all toolchain GVKs and add them to the client builder as objects with the status sub-resource? Try to use a generic logic using the scheme and GVKs, we don't want to update the logic as soon as we add or remove a CRD.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in 6dfea01

Copy link
Collaborator

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

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

Looks good overall. Just one minor comment. And +1 to @MatousJobanek's suggestion regarding registering status sub resources for all our API.

pkg/test/client_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

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

Nice!

pkg/configuration/cache_test.go Outdated Show resolved Hide resolved
pkg/test/client.go Outdated Show resolved Hide resolved
pkg/test/client.go Outdated Show resolved Hide resolved
Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

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

Thanks for addressing/answering my comments 👍

Copy link

sonarcloud bot commented Sep 23, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants