Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 17 additions & 5 deletions pkg/webhook/preflight/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (h *WebhookHandler) Handle(ctx context.Context, req admission.Request) admi
return admission.Allowed("")
}

if req.Operation == admissionv1.Update {
return admission.Allowed("")
}

cluster := &clusterv1.Cluster{}
err := h.decoder.Decode(req, cluster)
if err != nil {
Expand Down Expand Up @@ -131,11 +135,13 @@ func (h *WebhookHandler) Handle(ctx context.Context, req admission.Request) admi
resp.Allowed = false
}
for _, cause := range result.Causes {
resp.Result.Details.Causes = append(resp.Result.Details.Causes, metav1.StatusCause{
Type: metav1.CauseType(fmt.Sprintf("FailedPreflight%s", result.Name)),
Message: cause.Message,
Field: cause.Field,
})
resp.Result.Details.Causes = append(resp.Result.Details.Causes,
metav1.StatusCause{
Type: metav1.CauseType(result.Name),
Message: cause.Message,
Field: cause.Field,
},
)
}
resp.Warnings = append(resp.Warnings, result.Warnings...)
}
Expand Down Expand Up @@ -185,6 +191,12 @@ func run(ctx context.Context,

checksWG := sync.WaitGroup{}
for j, check := range checks {
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{
Name: check.Name(),
Expand Down
10 changes: 5 additions & 5 deletions pkg/webhook/preflight/preflight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func TestHandle(t *testing.T) {
Details: &metav1.StatusDetails{
Causes: []metav1.StatusCause{
{
Type: "FailedPreflightTest1",
Type: "Test1",
Field: "spec.test",
Message: "test failed",
},
Expand Down Expand Up @@ -342,11 +342,11 @@ func TestHandle(t *testing.T) {
Details: &metav1.StatusDetails{
Causes: []metav1.StatusCause{
{
Type: "FailedPreflightTest2",
Type: "Test2",
Message: "check failed",
},
{
Type: "FailedPreflightTest1",
Type: "Test1",
Message: "internal error",
},
},
Expand Down Expand Up @@ -475,11 +475,11 @@ func TestHandleCancelledContext(t *testing.T) {
Details: &metav1.StatusDetails{
Causes: []metav1.StatusCause{
{
Type: "FailedPreflightTest1",
Type: "Test1",
Message: "context cancelled",
},
{
Type: "FailedPreflightTest2",
Type: "Test2",
Message: "context cancelled",
},
},
Expand Down
Loading