mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #16628 from caesarxuchao/change-error-type
Auto commit by PR queue bot
This commit is contained in:
commit
55f5e48047
@ -558,6 +558,10 @@ The following HTTP status codes may be returned by the API.
|
||||
* * If updating an existing resource:
|
||||
* See `Conflict` from the `status` response section below on how to retrieve more information about the nature of the conflict.
|
||||
* GET and compare the fields in the pre-existing object, merge changes (if still valid according to preconditions), and retry with the updated request (including `ResourceVersion`).
|
||||
* `410 StatusGone`
|
||||
* Indicates that the item is no longer available at the server and no forwarding address is known.
|
||||
* Suggested client recovery behavior
|
||||
* Do not retry. Fix the request.
|
||||
* `422 StatusUnprocessableEntity`
|
||||
* Indicates that the requested create or update operation cannot be completed due to invalid data provided as part of the request.
|
||||
* Suggested client recovery behavior
|
||||
|
@ -157,6 +157,16 @@ func NewConflict(kind, name string, err error) error {
|
||||
}}
|
||||
}
|
||||
|
||||
// NewGone returns an error indicating the item no longer available at the server and no forwarding address is known.
|
||||
func NewGone(message string) error {
|
||||
return &StatusError{unversioned.Status{
|
||||
Status: unversioned.StatusFailure,
|
||||
Code: http.StatusGone,
|
||||
Reason: unversioned.StatusReasonGone,
|
||||
Message: message,
|
||||
}}
|
||||
}
|
||||
|
||||
// NewInvalid returns an error indicating the item is invalid and cannot be processed.
|
||||
func NewInvalid(kind, name string, errs validation.ErrorList) error {
|
||||
causes := make([]unversioned.StatusCause, 0, len(errs))
|
||||
|
@ -183,6 +183,11 @@ const (
|
||||
// Status code 409
|
||||
StatusReasonConflict StatusReason = "Conflict"
|
||||
|
||||
// StatusReasonGone means the item is no longer available at the server and no
|
||||
// forwarding address is known.
|
||||
// Status code 410
|
||||
StatusReasonGone StatusReason = "Gone"
|
||||
|
||||
// StatusReasonInvalid means the requested create or update operation cannot be
|
||||
// completed due to invalid data provided as part of the request. The client may
|
||||
// need to alter the request. When set, the client may use the StatusDetails
|
||||
|
@ -277,7 +277,7 @@ func (w *watchCache) GetAllEventsSinceThreadUnsafe(resourceVersion uint64) ([]wa
|
||||
return result, nil
|
||||
}
|
||||
if resourceVersion < oldest {
|
||||
return nil, errors.NewInternalError(fmt.Errorf("too old resource version: %d (%d)", resourceVersion, oldest))
|
||||
return nil, errors.NewGone(fmt.Sprintf("too old resource version: %d (%d)", resourceVersion, oldest))
|
||||
}
|
||||
|
||||
// Binary seatch the smallest index at which resourceVersion is not smaller than
|
||||
|
Loading…
Reference in New Issue
Block a user