Skip to content

Commit f6bd06b

Browse files
authored
refactor: Add more debug logs, remove redundant keys/values from log messages in preflight framework (#1246)
**What problem does this PR solve?**: Adds more debug logs, and removes redundant keys/values from log messages in the preflight framework. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 520a837 commit f6bd06b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/webhook/preflight/preflight.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,15 @@ type namedResult struct {
111111
}
112112

113113
func (h *WebhookHandler) Handle(ctx context.Context, req admission.Request) admission.Response {
114+
log := ctrl.LoggerFrom(ctx)
115+
114116
if req.Operation == admissionv1.Delete {
117+
log.V(5).Info("Skipping preflight checks for delete operation")
115118
return admission.Allowed("")
116119
}
117120

118121
if req.Operation == admissionv1.Update {
122+
log.V(5).Info("Skipping preflight checks for update operation")
119123
return admission.Allowed("")
120124
}
121125

@@ -139,6 +143,7 @@ func (h *WebhookHandler) Handle(ctx context.Context, req admission.Request) admi
139143
skipEvaluator := skip.New(cluster)
140144

141145
if skipEvaluator.ForAll() {
146+
log.V(5).Info("Skipping all preflight checks")
142147
// If the cluster has skipped all checks, return allowed.
143148
return admission.Allowed("").WithWarnings(
144149
"Cluster has skipped all preflight checks",
@@ -149,6 +154,7 @@ func (h *WebhookHandler) Handle(ctx context.Context, req admission.Request) admi
149154
// that we have time to summarize the results, and return a response.
150155
checkTimeout := Timeout - 2*time.Second
151156
checkCtx, checkCtxCancel := context.WithTimeout(ctx, checkTimeout)
157+
log.V(5).Info("Running preflight checks")
152158
resultsOrderedByCheckerAndCheck := run(checkCtx, h.client, cluster, skipEvaluator, h.checkers)
153159
checkCtxCancel()
154160

@@ -230,8 +236,6 @@ func run(ctx context.Context,
230236
ctrl.LoggerFrom(ctx).V(5).Info(
231237
"running preflight check",
232238
"checkName", check.Name(),
233-
"clusterName", cluster.Name,
234-
"clusterNamespace", cluster.Namespace,
235239
)
236240
if skipEvaluator.For(check.Name()) {
237241
resultsOrderedByCheck[j] = namedResult{
@@ -275,8 +279,6 @@ func run(ctx context.Context,
275279
fmt.Errorf("preflight check panic"),
276280
fmt.Sprintf("%v", r),
277281
"checkName", check.Name(),
278-
"clusterName", cluster.Name,
279-
"clusterNamespace", cluster.Namespace,
280282
"stackTrace", string(debug.Stack()),
281283
)
282284
}

0 commit comments

Comments
 (0)