Skip to content

Commit

Permalink
brians's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tejal29 committed May 4, 2020
1 parent 735e963 commit 9a2f0ff
Show file tree
Hide file tree
Showing 8 changed files with 677 additions and 638 deletions.
411 changes: 203 additions & 208 deletions docs/content/en/api/skaffold.swagger.json

Large diffs are not rendered by default.

103 changes: 54 additions & 49 deletions docs/content/en/docs/references/api/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ Describes all the methods for the Skaffold API



<a name="proto.ActionableErr"></a>
#### ActionableErr
`ErrDef` defines an error occurred along with an optional suggestions


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| errCode | [ErrorCode](#proto.ErrorCode) | | error code representing the error |
| message | [string](#string) | | message describing the error. |
| suggestions | [string](#string) | repeated | a list of suggestions for the error. |







<a name="proto.BuildEvent"></a>
#### BuildEvent
`BuildEvent` describes the build status per artifact, and will be emitted by Skaffold anytime a build starts or finishes, successfully or not.
Expand All @@ -77,7 +60,7 @@ If the build fails, an error will be attached to the event.
| artifact | [string](#string) | | artifact name |
| status | [string](#string) | | artifact build status oneof: InProgress, Completed, Failed |
| err | [string](#string) | | error when build status is Failed. |
| errCode | [ErrorCode](#proto.ErrorCode) | | error code representing the error |
| statusCode | [StatusCode](#proto.StatusCode) | | status code representing success or failure |



Expand Down Expand Up @@ -214,7 +197,7 @@ anytime a deployment starts or completes, successfully or not.
| ----- | ---- | ----- | ----------- |
| status | [string](#string) | | deployment status oneof: InProgress, Completed, Failed |
| err | [string](#string) | | error when status is Failed |
| errCode | [ErrorCode](#proto.ErrorCode) | | error code representing the error |
| statusCode | [StatusCode](#proto.StatusCode) | | status code representing success or failure |



Expand Down Expand Up @@ -276,9 +259,25 @@ anytime a deployment starts or completes, successfully or not.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| iteration | [int32](#int32) | | dev loop iteration |
| iteration | [int32](#int32) | | dev loop iteration. 0 represents initialization loop. |
| status | [string](#string) | | dev loop status oneof: In Progress, Completed, Failed |
| err | [ActionableErr](#proto.ActionableErr) | | actionable error message |
| err | [ErrDef](#proto.ErrDef) | | actionable error message |







<a name="proto.ErrDef"></a>
#### ErrDef
`ErrDef` defines an error occurred along with an optional suggestions


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| errCode | [StatusCode](#proto.StatusCode) | | error code representing the error |
| message | [string](#string) | | message describing the error. |



Expand Down Expand Up @@ -321,7 +320,7 @@ FileSyncEvent describes the sync status.
| image | [string](#string) | | the container image to which files are sycned. |
| status | [string](#string) | | status of file sync. one of: Not Started, In progress, Succeeded, Failed. |
| err | [string](#string) | | error in case of status failed. |
| errCode | [ErrorCode](#proto.ErrorCode) | | error code representing the error |
| statusCode | [StatusCode](#proto.StatusCode) | | status code representing success or failure |



Expand Down Expand Up @@ -564,7 +563,7 @@ will be sent with the new status.
| status | [string](#string) | | |
| message | [string](#string) | | |
| err | [string](#string) | | |
| errCode | [ErrorCode](#proto.ErrorCode) | | error code representing the error |
| statusCode | [StatusCode](#proto.StatusCode) | | status code representing success or failure |



Expand Down Expand Up @@ -679,36 +678,42 @@ Enum indicating deploy tools used



<a name="proto.ErrorCode"></a>
<a name="proto.StatusCode"></a>

### ErrorCode
Enum for error codes
### StatusCode
Enum for Status codes
These error codes are prepended by Phase Name e.g.
BUILD, DEPLOY, STATUSCHECK, DEVINIT

| Name | Number | Description |
| ---- | ------ | ----------- |
| COULD_NOT_DETERMINE | 0 | Could not determine error |
| STATUS_CHECK_NO_ERROR | 200 | Status Check Success |
| STATUS_CHECK_IMAGE_PULL_ERR | 300 | Container image pull error |
| STATUS_CHECK_CONTAINER_CREATING | 301 | Container creating error |
| STATUS_CHECK_RUN_CONTAINER_ERR | 302 | Container run error |
| STATUS_CHECK_CONTAINER_TERMINATED | 303 | Container is already terminated |
| STATUS_CHECK_CONTAINER_RESTARTING | 356 | Container restarting error |
| STATUS_CHECK_NODE_MEMORY_PRESSURE | 400 | Node memory pressure error |
| STATUS_CHECK_NODE_DISK_PRESSURE | 401 | Node disk pressure error |
| STATUS_CHECK_NODE_NETWORK_UNAVAILABLE | 402 | Node network unavailable error |
| STATUS_CHECK_NODE_PID_PRESSURE | 403 | Node PID pressure error |
| STATUS_CHECK_NODE_UNSCHEDULABLE | 404 | Node unschedulable error |
| STATUS_CHECK_NODE_UNREACHABLE | 405 | Node unreachable error |
| STATUS_CHECK_NODE_NOT_READY | 406 | Node not ready error |
| ErrorCode_UNKNOWN | 501 | Unknown Error Codes |
| STATUS_CHECK_UNKNOWN | 502 | Status Check error unknown |
| STATUS_CHECK_UNKNOWN_UNSCHEDULABLE | 503 | Container is unschedulable due to unknown reasons |
| STATUS_CHECK_CONTAINER_WAITING_UNKNOWN | 504 | Container is waiting due to unknown reason |
| FILE_SYNC_INIT_ERROR | 601 | File Sync Initialize failure |
| DEV_REGISTER_BUILD_DEPS | 701 | Failed to configure watcher for build dependencies in dev loop |
| DEV_REGISTER_TEST_DEPS | 702 | Failed to configure watcher for test dependencies in dev loop |
| DEV_REGISTER_DEPLOY_DEPS | 703 | Failed to configure watcher for deploy dependencies in dev loop |
| DEV_REGISTER_CONFIG_DEP | 704 | Failed to configure watcher for Skaffold configuration file. |
| UNKNOWN_ERROR | 0 | Could not determine error and phase |
| STATUSCHECK_SUCCESS | 200 | Status Check Success |
| STATUSCHECK_IMAGE_PULL_ERR | 300 | Container image pull error |
| STATUSCHECK_CONTAINER_CREATING | 301 | Container creating error |
| STATUSCHECK_RUN_CONTAINER_ERR | 302 | Container run error |
| STATUSCHECK_CONTAINER_TERMINATED | 303 | Container is already terminated |
| STATUSCHECK_CONTAINER_RESTARTING | 356 | Container restarting error |
| STATUSCHECK_NODE_MEMORY_PRESSURE | 400 | Node memory pressure error |
| STATUSCHECK_NODE_DISK_PRESSURE | 401 | Node disk pressure error |
| STATUSCHECK_NODE_NETWORK_UNAVAILABLE | 402 | Node network unavailable error |
| STATUSCHECK_NODE_PID_PRESSURE | 403 | Node PID pressure error |
| STATUSCHECK_NODE_UNSCHEDULABLE | 404 | Node unschedulable error |
| STATUSCHECK_NODE_UNREACHABLE | 405 | Node unreachable error |
| STATUSCHECK_NODE_NOT_READY | 406 | Node not ready error |
| STATUSCHECK_UNKNOWN | 501 | Status Check error unknown |
| STATUSCHECK_UNKNOWN_UNSCHEDULABLE | 502 | Container is unschedulable due to unknown reasons |
| STATUSCHECK_CONTAINER_WAITING_UNKNOWN | 503 | Container is waiting due to unknown reason |
| DEPLOY_UNKNOWN | 504 | Deploy failed due to unknown reason |
| SYNC_UNKNOWN | 505 | SYNC failed due to known reason |
| BUILD_UNKNOWN | 506 | Build failed due to unknown reason |
| DEVINIT_UNKNOWN | 507 | Dev Init failed due to unknown reason |
| CLEANUP_UNKNOWN | 508 | Cleanup failed due to unknown reason |
| SYNC_INIT_ERROR | 601 | File Sync Initialize failure |
| DEVINIT_REGISTER_BUILD_DEPS | 701 | Failed to configure watcher for build dependencies in dev loop |
| DEVINIT_REGISTER_TEST_DEPS | 702 | Failed to configure watcher for test dependencies in dev loop |
| DEVINIT_REGISTER_DEPLOY_DEPS | 703 | Failed to configure watcher for deploy dependencies in dev loop |
| DEVINIT_REGISTER_CONFIG_DEP | 704 | Failed to configure watcher for Skaffold configuration file. |


<!-- end enums -->
Expand Down
22 changes: 19 additions & 3 deletions pkg/skaffold/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,32 @@ import (
"github.com/GoogleContainerTools/skaffold/proto"
)

// These are phases in a DevLoop
const (
Build = Phase("Build")
Deploy = Phase("Deploy")
StatusCheck = Phase("StatusCheck")
FileSync = Phase("FileSync")
Dev = Phase("Dev")
DevInit = Phase("DevInit")
Cleanup = Phase("Cleanup")
)

type Phase string

func ErrorCodeFromError(_ Phase, _ error) proto.ErrorCode {
return proto.ErrorCode_ErrorCode_UNKNOWN
func ErrorCodeFromError(phase Phase, _ error) proto.StatusCode {
switch phase {
case Build:
return proto.StatusCode_BUILD_UNKNOWN
case Deploy:
return proto.StatusCode_DEPLOY_UNKNOWN
case StatusCheck:
return proto.StatusCode_STATUSCHECK_UNKNOWN
case FileSync:
return proto.StatusCode_SYNC_UNKNOWN
case DevInit:
return proto.StatusCode_DEVINIT_UNKNOWN
case Cleanup:
return proto.StatusCode_CLEANUP_UNKNOWN
}
return proto.StatusCode_UNKNOWN_ERROR
}
36 changes: 18 additions & 18 deletions pkg/skaffold/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func DeployInProgress() {

// DeployFailed notifies that non-fatal errors were encountered during a deployment.
func DeployFailed(err error) {
errCode := sErrors.ErrorCodeFromError(sErrors.Deploy, err)
handler.handleDeployEvent(&proto.DeployEvent{Status: Failed, Err: err.Error(), ErrCode: errCode})
statusCode := sErrors.ErrorCodeFromError(sErrors.Deploy, err)
handler.handleDeployEvent(&proto.DeployEvent{Status: Failed, Err: err.Error(), StatusCode: statusCode})
}

// DeployEvent notifies that a deployment of non fatal interesting errors during deploy.
Expand All @@ -182,11 +182,11 @@ func StatusCheckEventSucceeded() {
}

func StatusCheckEventFailed(err error) {
errCode := sErrors.ErrorCodeFromError(sErrors.StatusCheck, err)
statusCode := sErrors.ErrorCodeFromError(sErrors.StatusCheck, err)
handler.handleStatusCheckEvent(&proto.StatusCheckEvent{
Status: Failed,
Err: err.Error(),
ErrCode: errCode,
Status: Failed,
Err: err.Error(),
StatusCode: statusCode,
})
}

Expand Down Expand Up @@ -239,8 +239,8 @@ func BuildInProgress(imageName string) {

// BuildFailed notifies that a build has failed.
func BuildFailed(imageName string, err error) {
errCode := sErrors.ErrorCodeFromError(sErrors.Build, err)
handler.handleBuildEvent(&proto.BuildEvent{Artifact: imageName, Status: Failed, Err: err.Error(), ErrCode: errCode})
statusCode := sErrors.ErrorCodeFromError(sErrors.Build, err)
handler.handleBuildEvent(&proto.BuildEvent{Artifact: imageName, Status: Failed, Err: err.Error(), StatusCode: statusCode})
}

// BuildComplete notifies that a build has completed.
Expand All @@ -254,20 +254,20 @@ func DevLoopInProgress(i int) {
}

// DevLoopFailed notifies that a dev loop has failed with an error code
func DevLoopFailedWithErrorCode(i int, errCode proto.ErrorCode, err error) {
func DevLoopFailedWithErrorCode(i int, errCode proto.StatusCode, err error) {
handler.handleDevLoopEvent(&proto.DevLoopEvent{
Iteration: int32(i),
Status: Failed,
Err: &proto.ActionableErr{
Err: &proto.ErrDef{
ErrCode: errCode,
Message: err.Error(),
}})
}

// DevLoopFailed notifies that a dev loop has failed in a given phase
func DevLoopFailedInPhase(iteration int, phase sErrors.Phase, err error) {
errCode := sErrors.ErrorCodeFromError(phase, err)
DevLoopFailedWithErrorCode(iteration, errCode, err)
statusCode := sErrors.ErrorCodeFromError(phase, err)
DevLoopFailedWithErrorCode(iteration, statusCode, err)
}

// DevLoopComplete notifies that a dev loop has completed.
Expand All @@ -282,8 +282,8 @@ func FileSyncInProgress(fileCount int, image string) {

// FileSyncFailed notifies that a file sync has failed.
func FileSyncFailed(fileCount int, image string, err error) {
errCode := sErrors.ErrorCodeFromError(sErrors.FileSync, err)
handler.handleFileSyncEvent(&proto.FileSyncEvent{FileCount: int32(fileCount), Image: image, Status: Failed, Err: err.Error(), ErrCode: errCode})
statusCode := sErrors.ErrorCodeFromError(sErrors.FileSync, err)
handler.handleFileSyncEvent(&proto.FileSyncEvent{FileCount: int32(fileCount), Image: image, Status: Failed, Err: err.Error(), StatusCode: statusCode})
}

// FileSyncSucceeded notifies that a file sync has succeeded.
Expand Down Expand Up @@ -532,11 +532,11 @@ func (ev *eventHandler) handle(event *proto.Event) {
de := e.DevLoopEvent
switch de.Status {
case InProgress:
logEntry.Entry = fmt.Sprintf("Dev Iteration %d in progress", de.Iteration)
logEntry.Entry = fmt.Sprintf("DevInit Iteration %d in progress", de.Iteration)
case Succeeded:
logEntry.Entry = fmt.Sprintf("Dev Iteration %d successful", de.Iteration)
default:
logEntry.Entry = fmt.Sprintf("Dev Iteration %d failed with error code %v", de.Iteration, de.Err.ErrCode)
logEntry.Entry = fmt.Sprintf("DevInit Iteration %d successful", de.Iteration)
case Failed:
logEntry.Entry = fmt.Sprintf("DevInit Iteration %d failed with error code %v", de.Iteration, de.Err.ErrCode)
}
default:
return
Expand Down
Loading

0 comments on commit 9a2f0ff

Please sign in to comment.