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
3 changes: 0 additions & 3 deletions cfn-resources/util/cluster_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ func HandleClusterError(err error, resp *http.Response) *handler.ProgressEvent {
if resp != nil && resp.StatusCode == http.StatusBadRequest && strings.Contains(err.Error(), constants.Duplicate) {
pe.HandlerErrorCode = string(types.HandlerErrorCodeAlreadyExists)
}
if resp != nil && resp.StatusCode == http.StatusNotFound {
Copy link
Copy Markdown
Member Author

@lantoli lantoli Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant as it's already done in GetFailedEventByResponse at the beginning of the func

pe.HandlerErrorCode = string(types.HandlerErrorCodeNotFound)
}
if strings.Contains(err.Error(), "not exist") || strings.Contains(err.Error(), "being deleted") {
pe.HandlerErrorCode = string(types.HandlerErrorCodeNotFound)
}
Expand Down
33 changes: 5 additions & 28 deletions cfn-resources/util/progressevent/failed_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ import (
)

func getHandlerErrorCode(response *http.Response) string {
if response == nil {
return string(types.HandlerErrorCodeInternalFailure)
}
switch response.StatusCode {
case http.StatusBadRequest:
return string(types.HandlerErrorCodeInvalidRequest)
case http.StatusNotFound:
return string(types.HandlerErrorCodeNotFound)
case http.StatusConflict:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved logic from GetFailedEventByResponse for StatusConflict

return string(types.HandlerErrorCodeAlreadyExists)
case http.StatusInternalServerError:
return string(types.HandlerErrorCodeServiceInternalError)
case http.StatusPaymentRequired, http.StatusUnauthorized:
Expand All @@ -37,34 +42,6 @@ func getHandlerErrorCode(response *http.Response) string {
}

func GetFailedEventByResponse(message string, response *http.Response) handler.ProgressEvent {
if response == nil {
return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: message,
HandlerErrorCode: string(types.HandlerErrorCodeHandlerInternalFailure)}
}

if response.StatusCode == http.StatusConflict {
return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: message,
HandlerErrorCode: string(types.HandlerErrorCodeAlreadyExists)}
}

if response.StatusCode == http.StatusUnauthorized {
return handler.ProgressEvent{
Copy link
Copy Markdown
Member Author

@lantoli lantoli Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong mapping, and already handled in getHandlerErrorCode

OperationStatus: handler.Failed,
Message: "Not found",
HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}
}

if response.StatusCode == http.StatusBadRequest {
return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: message,
HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}
Copy link
Copy Markdown
Member Author

@lantoli lantoli Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong mapping, and already handled in getHandlerErrorCode

}

return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: message,
Expand Down
Loading