Skip to content

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)

@codecov
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.23%. Comparing base (f8850b6) to head (0fc2715).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...resources/toolchaincluster_resources_controller.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #376      +/-   ##
==========================================
+ Coverage   77.61%   78.23%   +0.61%     
==========================================
  Files          49       49              
  Lines        2426     2444      +18     
==========================================
+ Hits         1883     1912      +29     
+ Misses        489      478      -11     
  Partials       54       54              
Files with missing lines Coverage Δ
controllers/label_event_handler.go 100.00% <100.00%> (ø)
pkg/test/client.go 81.75% <100.00%> (+10.98%) ⬆️
...resources/toolchaincluster_resources_controller.go 42.42% <0.00%> (ø)


// 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.


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 ?

@sonarqubecloud
Copy link

sonarqubecloud 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

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.

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!

@ranakan19 ranakan19 requested a review from MatousJobanek August 7, 2024 19:46
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 👍


t.Run("status create fails", func(t *testing.T) {
_, retrieved := createAndGetDeployment(t, fclient)
require.EqualError(t, fclient.Status().Create(context.TODO(), retrieved, retrieved), "fakeSubResourceWriter does not support create for status")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonarqubecloud
Copy link

@ranakan19 ranakan19 merged commit a6a8525 into codeready-toolchain:master Nov 14, 2024
9 checks passed
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