Merge pull request #73976 from jennybuckley/apply-errors

Make server-side apply's conflict errors more human readable

Kubernetes-commit: 62734d36705f3b0bb2a1a6fc9cf00b5206fede20
This commit is contained in:
Kubernetes Publisher
2019-02-14 17:05:21 -08:00
27 changed files with 216 additions and 3897 deletions
+2 -12
View File
@@ -27,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field"
"sigs.k8s.io/structured-merge-diff/merge"
)
const (
@@ -186,16 +185,7 @@ func NewConflict(qualifiedResource schema.GroupResource, name string, err error)
}
// NewApplyConflict returns an error including details on the requests apply conflicts
func NewApplyConflict(conflicts merge.Conflicts) *StatusError {
causes := make([]metav1.StatusCause, 0, len(conflicts))
for _, conflict := range conflicts {
causes = append(causes, metav1.StatusCause{
Type: metav1.CauseType("conflict"),
Message: conflict.Error(),
Field: conflict.Path.String(),
})
}
func NewApplyConflict(causes []metav1.StatusCause, message string) *StatusError {
return &StatusError{ErrStatus: metav1.Status{
Status: metav1.StatusFailure,
Code: http.StatusConflict,
@@ -204,7 +194,7 @@ func NewApplyConflict(conflicts merge.Conflicts) *StatusError {
// TODO: Get obj details here?
Causes: causes,
},
Message: fmt.Sprintf("Apply failed with %d conflicts: %s", len(conflicts), conflicts.Error()),
Message: message,
}}
}
+3
View File
@@ -825,6 +825,9 @@ const (
// without the expected return type. The presence of this cause indicates the error may be
// due to an intervening proxy or the server software malfunctioning.
CauseTypeUnexpectedServerResponse CauseType = "UnexpectedServerResponse"
// FieldManagerConflict is used to report when another client claims to manage this field,
// It should only be returned for a request using server-side apply.
CauseTypeFieldManagerConflict CauseType = "FieldManagerConflict"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object