Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
tejal29 committed Nov 30, 2020
1 parent 75862c2 commit 14c2e36
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 249 deletions.
4 changes: 2 additions & 2 deletions docs/content/en/api/skaffold.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2262,7 +2262,7 @@
"FIX_USER_BUILD_ERR",
"DOCKER_BUILD_RETRY",
"FIX_CACHE_FROM_ARTIFACT_CONFIG",
"FIX_DOCKERFILE_CONFIG",
"FIX_SKAFFOLD_CONFIG_DOCKERFILE",
"FIX_JIB_PLUGIN_CONFIGURATION",
"CHECK_CLUSTER_CONNECTION",
"CHECK_MINIKUBE_STATUS",
Expand All @@ -2284,7 +2284,7 @@
"OPEN_ISSUE"
],
"default": "NIL",
"description": "Enum for Suggestion codes\n- NIL: default nil suggestion.\nThis is usually set when no error happens.\n - ADD_DEFAULT_REPO: Add Default Repo\n - CHECK_DEFAULT_REPO: Verify Default Repo\n - CHECK_DEFAULT_REPO_GLOBAL_CONFIG: Verify default repo in the global config\n - GCLOUD_DOCKER_AUTH_CONFIGURE: run gcloud docker auth configure\n - DOCKER_AUTH_CONFIGURE: Run docker auth configure\n - CHECK_GCLOUD_PROJECT: Verify Gcloud Project\n - CHECK_DOCKER_RUNNING: Check if docker is running\n - FIX_USER_BUILD_ERR: Fix User Build Error\n - DOCKER_BUILD_RETRY: Docker build internal error, try again\n - FIX_CACHE_FROM_ARTIFACT_CONFIG: Fix `cacheFrom` config for given artifact and try again\n - FIX_DOCKERFILE_CONFIG: Fix `dockerfile` config for a given artifact and try again.\n - FIX_JIB_PLUGIN_CONFIGURATION: Use a supported Jib plugin type\n - CHECK_CLUSTER_CONNECTION: Check cluster connection\n - CHECK_MINIKUBE_STATUS: Check minikube status\n - CHECK_CONTAINER_LOGS: Container run error\n - CHECK_READINESS_PROBE: Pod Health check error\n - CHECK_CONTAINER_IMAGE: Check Container image\n - ADDRESS_NODE_MEMORY_PRESSURE: Node pressure error\n - ADDRESS_NODE_DISK_PRESSURE: Node disk pressure error\n - ADDRESS_NODE_NETWORK_UNAVAILABLE: Node network unavailable error\n - ADDRESS_NODE_PID_PRESSURE: Node PID pressure error\n - ADDRESS_NODE_UNSCHEDULABLE: Node unschedulable error\n - ADDRESS_NODE_UNREACHABLE: Node unreachable error\n - ADDRESS_NODE_NOT_READY: Node not ready error\n - ADDRESS_FAILED_SCHEDULING: Scheduler failure error\n - CHECK_HOST_CONNECTION: Cluster Connectivity error\n - START_MINIKUBE: Minikube is stopped: use `minikube start`\n - UNPAUSE_MINIKUBE: Minikube is paused: use `minikube unpause`\n - RUN_DOCKER_PULL: Run Docker pull for the image with v1 manifest and try again.\n - OPEN_ISSUE: Open an issue so this situation can be diagnosed"
"description": "Enum for Suggestion codes\n- NIL: default nil suggestion.\nThis is usually set when no error happens.\n - ADD_DEFAULT_REPO: Add Default Repo\n - CHECK_DEFAULT_REPO: Verify Default Repo\n - CHECK_DEFAULT_REPO_GLOBAL_CONFIG: Verify default repo in the global config\n - GCLOUD_DOCKER_AUTH_CONFIGURE: run gcloud docker auth configure\n - DOCKER_AUTH_CONFIGURE: Run docker auth configure\n - CHECK_GCLOUD_PROJECT: Verify Gcloud Project\n - CHECK_DOCKER_RUNNING: Check if docker is running\n - FIX_USER_BUILD_ERR: Fix User Build Error\n - DOCKER_BUILD_RETRY: Docker build internal error, try again\n - FIX_CACHE_FROM_ARTIFACT_CONFIG: Fix `cacheFrom` config for given artifact and try again\n - FIX_SKAFFOLD_CONFIG_DOCKERFILE: Fix `dockerfile` config for a given artifact and try again.\n - FIX_JIB_PLUGIN_CONFIGURATION: Use a supported Jib plugin type\n - CHECK_CLUSTER_CONNECTION: Check cluster connection\n - CHECK_MINIKUBE_STATUS: Check minikube status\n - CHECK_CONTAINER_LOGS: Container run error\n - CHECK_READINESS_PROBE: Pod Health check error\n - CHECK_CONTAINER_IMAGE: Check Container image\n - ADDRESS_NODE_MEMORY_PRESSURE: Node pressure error\n - ADDRESS_NODE_DISK_PRESSURE: Node disk pressure error\n - ADDRESS_NODE_NETWORK_UNAVAILABLE: Node network unavailable error\n - ADDRESS_NODE_PID_PRESSURE: Node PID pressure error\n - ADDRESS_NODE_UNSCHEDULABLE: Node unschedulable error\n - ADDRESS_NODE_UNREACHABLE: Node unreachable error\n - ADDRESS_NODE_NOT_READY: Node not ready error\n - ADDRESS_FAILED_SCHEDULING: Scheduler failure error\n - CHECK_HOST_CONNECTION: Cluster Connectivity error\n - START_MINIKUBE: Minikube is stopped: use `minikube start`\n - UNPAUSE_MINIKUBE: Minikube is paused: use `minikube unpause`\n - RUN_DOCKER_PULL: Run Docker pull for the image with v1 manifest and try again.\n - OPEN_ISSUE: Open an issue so this situation can be diagnosed"
},
"protoTerminationEvent": {
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs/references/api/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ Enum for Suggestion codes
| FIX_USER_BUILD_ERR | 107 | Fix User Build Error |
| DOCKER_BUILD_RETRY | 108 | Docker build internal error, try again |
| FIX_CACHE_FROM_ARTIFACT_CONFIG | 109 | Fix `cacheFrom` config for given artifact and try again |
| FIX_DOCKERFILE_CONFIG | 110 | Fix `dockerfile` config for a given artifact and try again. |
| FIX_SKAFFOLD_CONFIG_DOCKERFILE | 110 | Fix `dockerfile` config for a given artifact and try again. |
| FIX_JIB_PLUGIN_CONFIGURATION | 111 | Use a supported Jib plugin type |
| CHECK_CLUSTER_CONNECTION | 201 | Check cluster connection |
| CHECK_MINIKUBE_STATUS | 202 | Check minikube status |
Expand Down
12 changes: 7 additions & 5 deletions pkg/skaffold/build/docker/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/GoogleContainerTools/skaffold/proto"
)

// newBuildError turns Docker-specific errors into actionable errors.
// The input errors are assumed to be from the Skaffold docker invocation.
func newBuildError(err error) error {
errU := errors.Unwrap(err)
if errU == nil {
Expand All @@ -35,7 +37,7 @@ func newBuildError(err error) error {

switch errU.(type) {
case *jsonmessage.JSONError:
return sErrors.NewError(
return sErrors.NewError(err,
proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_BUILD_USER_ERROR,
Expand All @@ -47,7 +49,7 @@ func newBuildError(err error) error {
},
})
default:
return sErrors.NewError(
return sErrors.NewError(err,
proto.ActionableErr{
Message: errU.Error(),
ErrCode: getErrorCode(errU),
Expand Down Expand Up @@ -93,13 +95,13 @@ func getErrorCode(err error) proto.StatusCode {
}

func dockerfileNotFound(err error, artifact string) error {
return sErrors.NewError(
return sErrors.NewError(err,
proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_BUILD_DOCKERFILE_NOT_FOUND,
Suggestions: []*proto.Suggestion{
{
SuggestionCode: proto.SuggestionCode_FIX_DOCKERFILE_CONFIG,
SuggestionCode: proto.SuggestionCode_FIX_SKAFFOLD_CONFIG_DOCKERFILE,
Action: fmt.Sprintf("Dockerfile not found. Please check config `dockerfile` for artifact %s."+
"\nRefer https://skaffold.dev/docs/references/yaml/#build-artifacts-docker for details.", artifact),
},
Expand All @@ -108,7 +110,7 @@ func dockerfileNotFound(err error, artifact string) error {
}

func cacheFromPullErr(err error, artifact string) error {
return sErrors.NewError(
return sErrors.NewError(err,
proto.ActionableErr{
Message: err.Error(),
ErrCode: proto.StatusCode_BUILD_DOCKER_CACHE_FROM_PULL_ERR,
Expand Down
16 changes: 0 additions & 16 deletions pkg/skaffold/errors/err_def.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/*
<<<<<<< HEAD
Copyright 2019 The Skaffold Authors
=======
Copyright 2020 The Skaffold Authors
>>>>>>> c0434f6aa (add tests)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -30,7 +26,6 @@ type Error interface {
Error() string
StatusCode() proto.StatusCode
Suggestions() []*proto.Suggestion
<<<<<<< HEAD
Unwrap() error
}

Expand All @@ -50,17 +45,6 @@ func (e ErrDef) Unwrap() error {
return e.err
}

type ErrDef struct {
ae proto.ActionableErr
}

func (e ErrDef) Error() string {
if s := concatSuggestions(e.Suggestions()); s != "" {
return fmt.Sprintf("%s. %s", e.ae.Message, concatSuggestions(e.Suggestions()))
}
return e.ae.Message
}

func (e ErrDef) StatusCode() proto.StatusCode {
return e.ae.ErrCode
}
Expand Down
Loading

0 comments on commit 14c2e36

Please sign in to comment.