This commit is contained in:
Abhay Chaurasiya 2026-04-05 17:37:52 +03:00 committed by GitHub
commit 45cb563ff2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -1241,7 +1241,7 @@ func patchResourceServerSide(target *resource.Info, dryRun bool, forceConflicts
return fmt.Errorf("conflict occurred while applying object %s/%s %s: %w", target.Namespace, target.Name, target.Mapping.GroupVersionKind.String(), err)
}
return err
return fmt.Errorf("server-side apply failed for object %s/%s %s: %w", target.Namespace, target.Name, target.Mapping.GroupVersionKind.String(), err)
}
return target.Refresh(obj, true)

View file

@ -1802,6 +1802,23 @@ func TestPatchResourceServerSide(t *testing.T) {
},
ExpectedErrorContains: "the server reported a conflict",
},
"generic server-side apply error": {
Pods: newPodList("whale"),
DryRun: false,
ForceConflicts: false,
FieldValidationDirective: FieldValidationDirectiveStrict,
Callback: func(t *testing.T, _ testCase, _ []RequestResponseAction, _ *http.Request) (*http.Response, error) {
t.Helper()
return newResponse(http.StatusBadRequest, &metav1.Status{
Status: metav1.StatusFailure,
Message: `failed to create typed patch object: .spec.template.spec.containers[name="test"].env: duplicate entries for key [name="SERVER_CONTEXT_PATH"]`,
Reason: metav1.StatusReasonBadRequest,
Code: http.StatusBadRequest,
})
},
ExpectedErrorContains: "server-side apply failed for object default/whale /v1, Kind=Pod: failed to create typed patch object",
},
}
for name, tc := range testCases {