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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃尡 Fix patch errors not being logged #9224

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

AndiDog
Copy link
Contributor

@AndiDog AndiDog commented Aug 17, 2023

What this PR does / why we need it:

  • Log which KubeadmConfig gets reconciled so that every log line is easier to reason about
  • Fix patch errors not being logged (rerr vs. err)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

n/a


/area logging
/area provider/bootstrap-kubeadm

@k8s-ci-robot k8s-ci-robot added area/logging Issues or PRs related to logging area/provider/bootstrap-kubeadm Issues or PRs related to CAPBK cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 17, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @AndiDog. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 17, 2023
Copy link
Contributor

@killianmuldoon killianmuldoon 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 this!

/ok-to-test

related to #6994

@@ -173,9 +173,11 @@ func (r *KubeadmConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}
log = log.WithValues(configOwner.GetKind(), klog.KRef(configOwner.GetNamespace(), configOwner.GetName()), "resourceVersion", configOwner.GetResourceVersion())

log = log.WithValues("Cluster", klog.KRef(configOwner.GetNamespace(), configOwner.ClusterName()))
log = log.WithValues("Cluster", klog.KRef(configOwner.GetNamespace(), configOwner.ClusterName()), "KubeadmConfig", klog.KRef(config.GetNamespace(), config.GetName()))
Copy link
Contributor

Choose a reason for hiding this comment

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

This pair should already be included at this point when controller runtime sets up the logger.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean KubeadmConfig which I added? I definitely don't see it in a failing test's log, so that's why I wanted to have it.

Example before:

I0817 15:10:42.545337   55146 kubeadmconfig_controller.go:179]  "msg"="Reconciling KubeadmConfig" "Cluster"={"name":"cluster","namespace":"default"} "MachinePool"={"name":"worker-machinepool","namespace":"default"} "resourceVersion"="999"

I found controller-runtime to actually fill it for production controller logs (namely in func (blder *Builder) doController(r reconcile.Reconciler) error):

kubeadmconfig_controller.go:314] "Refreshing token until the infrastructure has a chance to consume it" controller="kubeadmconfig" controllerGroup="bootstrap.cluster.x-k8s.io" controllerKind="KubeadmConfig" KubeadmConfig="mynamespace/my-nodepool0"

So my problem is that tests never use the controller-runtime builder but construct KubeadmConfigReconciler{...} directly. Not worth fixing this as I did, so I'll revert. Overall though, having the object logged in the test logs would help the developer experience.

Copy link
Member

Choose a reason for hiding this comment

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

Didn't look at the code but potentially we could try to use the builder in tests as well (i.e. via our SetupWithManager func)

Copy link
Member

Choose a reason for hiding this comment

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

Hm probably more complicated then that

Copy link
Contributor

Choose a reason for hiding this comment

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

That would fix it - currently most of the KCP tests set up the controller using the raw reconciler e.g.

		r := &KubeadmControlPlaneReconciler{

Not sure it's worth it for tests where you can set things up to get info on which cluster etc. is involved in the test code. But would be fine with it if someone wanted to make the changes

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 17, 2023
@killianmuldoon killianmuldoon removed the area/provider/bootstrap-kubeadm Issues or PRs related to CAPBK label Aug 17, 2023
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

Thanks!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: da08bacbf57728e6d6e3cef9be047fa2fc4540b9

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2023
@AndiDog AndiDog changed the title 馃尡 Logging improvements for KubeadmConfigReconciler 馃尡 Fix patch errors not being logged Aug 17, 2023
@sbueringer
Copy link
Member

One suggestion #9224 (comment)

@sbueringer
Copy link
Member

Thx!

/lgtm

/assign @killianmuldoon

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 13c06738c6240fe5b673812a1f0a8c8f5b61107f

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Thanks!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: killianmuldoon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 17, 2023
@k8s-ci-robot k8s-ci-robot merged commit 62d734c into kubernetes-sigs:main Aug 17, 2023
19 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.6 milestone Aug 17, 2023
@sbueringer
Copy link
Member

/cherry-pick release-1.5

@sbueringer
Copy link
Member

/cherry-pick release-1.4

@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #9234

In response to this:

/cherry-pick release-1.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #9235

In response to this:

/cherry-pick release-1.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/logging Issues or PRs related to logging cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants