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

🌱 WIP: Reformat logs/bootstrap #6110

Closed

Conversation

killianmuldoon
Copy link
Contributor

This PR is a work in progress and leads on from #5571. This is a poc to see how we should improve our logging overall and should not be merged.

Add extra key-value pairs and add logging levels to logs in the bootstrap package.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 11, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign neolit123 after the PR has been reviewed.
You can assign the PR to them by writing /assign @neolit123 in a comment when ready.

The full list of commands accepted by this bot can be found 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

@killianmuldoon killianmuldoon force-pushed the logs/bootstrap branch 3 times, most recently from 78c3a2d to 412c1c3 Compare February 16, 2022 12:24
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2022
@killianmuldoon killianmuldoon force-pushed the logs/bootstrap branch 2 times, most recently from 45590c2 to 9098dfc Compare February 23, 2022 12:39
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 23, 2022
@killianmuldoon killianmuldoon force-pushed the logs/bootstrap branch 3 times, most recently from cc83ff8 to 1edf198 Compare February 23, 2022 16:04
@killianmuldoon killianmuldoon force-pushed the logs/bootstrap branch 2 times, most recently from 75bcaeb to ee6b5b3 Compare February 23, 2022 19:26
@k8s-ci-robot
Copy link
Contributor

@killianmuldoon: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-verify-main dffc1ae link true /test pull-cluster-api-verify-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

Some nits, but i really like the direction of this PR

}

// Look up the owner of this kubeadm config if there is one
configOwner, err := bsutil.GetConfigOwner(ctx, r.Client, config)
if apierrors.IsNotFound(err) {
log.Info("Reconcile finished - waiting for KubeadmConfig owner to be set by Machine or MachinePool controller")
Copy link
Member

Choose a reason for hiding this comment

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

What about

Suggested change
log.Info("Reconcile finished - waiting for KubeadmConfig owner to be set by Machine or MachinePool controller")
log.Info(fmt.Sprintf("Waiting for %s owner to be set by Machine or MachinePool controller", klog.KObj(KubeadmConfig))

So it will read

  • Reconciling ...
  • Waiting for ... owner to be set by Machine or MachinePool controller
  • No changes to ...

If this is ok let's apply to other similar messages (drop "Reconcile finished", add obj name)

@@ -320,24 +331,26 @@ func (r *KubeadmConfigReconciler) rotateMachinePoolBootstrapToken(ctx context.Co
return ctrl.Result{}, err
}
if shouldRotate {
log.V(2).Info("Creating new bootstrap token")
Copy link
Member

Choose a reason for hiding this comment

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

I will keep this otherwise it won't be clear why a new token has been created; might be the message should be "Rotating the bootstrap token for the MachinePool"


// update the bootstrap data
return r.joinWorker(ctx, scope)
}

log.Info("Extending MachinePool token lifetime")
Copy link
Member

Choose a reason for hiding this comment

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

I would drop this given that we are not extending token lifecycle but creating new tokens

config.Spec.JoinConfiguration = &bootstrapv1.JoinConfiguration{}
}

// it's a control plane join
if configOwner.IsControlPlaneMachine() {
return r.joinControlplane(ctx, scope)
Copy link
Member

Choose a reason for hiding this comment

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

I think we can drop this change and L287

return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
}

// if the machine has not ClusterConfiguration and InitConfiguration, requeue
if scope.Config.Spec.InitConfiguration == nil && scope.Config.Spec.ClusterConfiguration == nil {
scope.Info("Control plane is not ready, requeing joining control planes until ready.")
log.Info("Reconcile finished - control plane is not ready, requeuing joining control planes until ready")
Copy link
Member

Choose a reason for hiding this comment

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

Note for a follow up PR
We should drop RequeAfter and instead watch for machines (and probably MachinePools); same at line 382.

Copy link
Member

Choose a reason for hiding this comment

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

Should this be "Waiting for control plane object to be ready before generating DataSecret for ..."?
~same for L382

@@ -508,6 +519,7 @@ func (r *KubeadmConfigReconciler) joinWorker(ctx context.Context, scope *Scope)
if res, err := r.reconcileDiscovery(ctx, scope.Cluster, scope.Config, certificates); err != nil {
return ctrl.Result{}, err
} else if !res.IsZero() {
log.Info("Reconcile finished - discovery configuration set")
Copy link
Member

Choose a reason for hiding this comment

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

I will drop this in favor of logging inside reconcileDiscovery when we return non zero values

return ctrl.Result{}, err
}

log.Info("Reconcile finished - bootstrap data generated for Machine")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this message; is this a duplicate of the side effect? if not, should this have the secret KObj?

Copy link
Member

Choose a reason for hiding this comment

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

Similar consideration applies to joinWorker/joinControlplane

@@ -114,26 +115,27 @@ func (c *ControlPlaneInitMutex) Lock(ctx context.Context, cluster *clusterv1.Clu
func (c *ControlPlaneInitMutex) Unlock(ctx context.Context, cluster *clusterv1.Cluster) bool {
sema := newSemaphore()
cmName := configMapName(cluster.Name)
log := c.log.WithValues("namespace", cluster.Namespace, "cluster-name", cluster.Name, "configmap-name", cmName)
log.Info("Checking for lock")
log := c.log.WithValues("ConfigMap", fmt.Sprintf("%s/%s", cluster.Namespace, cmName), "Cluster", newkObj(cluster))
Copy link
Member

Choose a reason for hiding this comment

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

Can we use KObj/KRef?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2022
@k8s-ci-robot
Copy link
Contributor

@killianmuldoon: PR needs rebase.

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-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 9, 2022
@vincepri
Copy link
Member

@killianmuldoon do you still want to pursue these changes, or shall we close?

@killianmuldoon
Copy link
Contributor Author

@killianmuldoon do you still want to pursue these changes, or shall we close?
I think I'll come back to this over the next few weeks.

@killianmuldoon
Copy link
Contributor Author

Closing this for now as the changes are stale / behind where we are on logging right now. Will possibly come back to this on a new PR, or open a new PR with similar changes.

/close

@k8s-ci-robot
Copy link
Contributor

@killianmuldoon: Closed this PR.

In response to this:

Closing this for now as the changes are stale / behind where we are on logging right now. Will possibly come back to this on a new PR, or open a new PR with similar changes.

/close

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
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants