Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pkg/webhook/preflight/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,15 @@ type namedResult struct {
}

func (h *WebhookHandler) Handle(ctx context.Context, req admission.Request) admission.Response {
log := ctrl.LoggerFrom(ctx)

if req.Operation == admissionv1.Delete {
log.V(5).Info("Skipping preflight checks for delete operation")
return admission.Allowed("")
}

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

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

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

Expand Down Expand Up @@ -230,8 +236,6 @@ func run(ctx context.Context,
ctrl.LoggerFrom(ctx).V(5).Info(
"running preflight check",
"checkName", check.Name(),
"clusterName", cluster.Name,
"clusterNamespace", cluster.Namespace,
)
if skipEvaluator.For(check.Name()) {
resultsOrderedByCheck[j] = namedResult{
Expand Down Expand Up @@ -275,8 +279,6 @@ func run(ctx context.Context,
fmt.Errorf("preflight check panic"),
fmt.Sprintf("%v", r),
"checkName", check.Name(),
"clusterName", cluster.Name,
"clusterNamespace", cluster.Namespace,
"stackTrace", string(debug.Stack()),
)
}
Expand Down
Loading