Skip to content

Commit bf61856

Browse files
authored
Merge pull request #177 from unexist/main
Replaced generic error messages
2 parents 09a7043 + 8c44a1a commit bf61856

17 files changed

+19
-16
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ FEATURES:
1010
* config: Allow setting `image_pull_timeout` and `client_http_timeout ` [[GH-131](https://github.com/hashicorp/nomad-driver-podman/pull/131)]
1111
* runtime: Add support for host and CSI volumes and using podman tasks as CSI plugins [[GH-169](https://github.com/hashicorp/nomad-driver-podman/pull/169)][[GH-152](https://github.com/hashicorp/nomad-driver-podman/pull/152)]
1212

13+
IMPROVEMENTS:
14+
* log: Improve log messages on errors. [[GH-177](https://github.com/hashicorp/nomad-driver-podman/pull/177)]
15+
1316
BUG FIXES:
1417
* log: Use error key context to log errors rather than Go err style. [[GH-126](https://github.com/hashicorp/nomad-driver-podman/pull/126)]
1518
* telemetry: respect telemetry.collection_interval to reduce cpu churn when running many containers [[GH-130](https://github.com/hashicorp/nomad-driver-podman/pull/130)]

api/container_create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (c *API) ContainerCreate(ctx context.Context, create SpecGenerator) (Contai
2828

2929
if res.StatusCode != http.StatusCreated {
3030
body, _ := ioutil.ReadAll(res.Body)
31-
return response, fmt.Errorf("unknown error, status code: %d: %s", res.StatusCode, body)
31+
return response, fmt.Errorf("cannot create container, status code: %d: %s", res.StatusCode, body)
3232
}
3333

3434
body, err := ioutil.ReadAll(res.Body)

api/container_delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ func (c *API) ContainerDelete(ctx context.Context, name string, force bool, dele
2020
if res.StatusCode == http.StatusNoContent {
2121
return nil
2222
}
23-
return fmt.Errorf("unknown error, status code: %d", res.StatusCode)
23+
return fmt.Errorf("cannot delete container, status code: %d", res.StatusCode)
2424
}

api/container_inspect.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (c *API) ContainerInspect(ctx context.Context, name string) (InspectContain
2525
}
2626

2727
if res.StatusCode != http.StatusOK {
28-
return inspectData, fmt.Errorf("unknown error, status code: %d", res.StatusCode)
28+
return inspectData, fmt.Errorf("cannot inspect container, status code: %d", res.StatusCode)
2929
}
3030
body, err := ioutil.ReadAll(res.Body)
3131
if err != nil {

api/container_kill.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ func (c *API) ContainerKill(ctx context.Context, name string, signal string) err
1919
if res.StatusCode == http.StatusNoContent {
2020
return nil
2121
}
22-
return fmt.Errorf("unknown error, status code: %d", res.StatusCode)
22+
return fmt.Errorf("cannot kill container, status code: %d", res.StatusCode)
2323
}

api/container_logs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (c *API) ContainerLogs(ctx context.Context, name string, since time.Time, s
1919
}
2020

2121
if res.StatusCode != http.StatusOK {
22-
return fmt.Errorf("unknown error, status code: %d", res.StatusCode)
22+
return fmt.Errorf("cannot get logs from container, status code: %d", res.StatusCode)
2323
}
2424

2525
defer func() {

api/container_start.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (c *API) ContainerStart(ctx context.Context, name string) error {
2020

2121
if res.StatusCode != http.StatusNoContent {
2222
body, _ := ioutil.ReadAll(res.Body)
23-
return fmt.Errorf("unknown error, status code: %d: %s", res.StatusCode, body)
23+
return fmt.Errorf("cannot start container, status code: %d: %s", res.StatusCode, body)
2424
}
2525

2626
// wait max 10 seconds for running state

api/container_stats.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (c *API) ContainerStats(ctx context.Context, name string) (Stats, error) {
3131
return stats, ContainerWrongState
3232
}
3333
if res.StatusCode != http.StatusOK {
34-
return stats, fmt.Errorf("unknown error, status code: %d", res.StatusCode)
34+
return stats, fmt.Errorf("cannot get stats of container, status code: %d", res.StatusCode)
3535
}
3636

3737
body, err := ioutil.ReadAll(res.Body)

api/container_stop.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ func (c *API) ContainerStop(ctx context.Context, name string, timeout int, ignor
2626
if res.StatusCode == http.StatusNoContent {
2727
return nil
2828
}
29-
return fmt.Errorf("unknown error, status code: %d", res.StatusCode)
29+
return fmt.Errorf("cannot stop container, status code: %d", res.StatusCode)
3030
}

api/container_wait.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ func (c *API) ContainerWait(ctx context.Context, name string, conditions []strin
2020
if res.StatusCode == http.StatusOK {
2121
return nil
2222
}
23-
return fmt.Errorf("unknown error, status code: %d", res.StatusCode)
23+
return fmt.Errorf("cannot wait for container, status code: %d", res.StatusCode)
2424
}

api/exec_create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (c *API) ExecCreate(ctx context.Context, name string, config ExecConfig) (s
6969

7070
if res.StatusCode != http.StatusCreated {
7171
body, _ := ioutil.ReadAll(res.Body)
72-
return "", fmt.Errorf("unknown error, status code: %d: %s", res.StatusCode, body)
72+
return "", fmt.Errorf("cannot create exec session, status code: %d: %s", res.StatusCode, body)
7373
}
7474

7575
body, err := ioutil.ReadAll(res.Body)

api/exec_inspect.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (c *API) ExecInspect(ctx context.Context, sessionId string) (InspectExecSes
2121
defer res.Body.Close()
2222

2323
if res.StatusCode != http.StatusOK {
24-
return inspectData, fmt.Errorf("unknown error, status code: %d", res.StatusCode)
24+
return inspectData, fmt.Errorf("cannot inspect exec session, status code: %d", res.StatusCode)
2525
}
2626
body, err := ioutil.ReadAll(res.Body)
2727
if err != nil {

api/exec_resize.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func (c *API) ExecResize(ctx context.Context, execId string, height int, width i
1818

1919
if res.StatusCode != http.StatusCreated {
2020
body, _ := ioutil.ReadAll(res.Body)
21-
return fmt.Errorf("unknown error, status code: %d: %s", res.StatusCode, body)
21+
return fmt.Errorf("cannot resize exec session, status code: %d: %s", res.StatusCode, body)
2222
}
2323

2424
return err

api/image_inspect.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (c *API) ImageInspectID(ctx context.Context, image string) (string, error)
3434
}
3535

3636
if res.StatusCode != http.StatusOK {
37-
return "", fmt.Errorf("unknown error, status code: %d: %s", res.StatusCode, body)
37+
return "", fmt.Errorf("cannot inspect image, status code: %d: %s", res.StatusCode, body)
3838
}
3939
err = json.Unmarshal(body, &inspectData)
4040
if err != nil {

api/image_load.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (c *API) ImageLoad(ctx context.Context, path string) (string, error) {
3333
return "", err
3434
}
3535
if res.StatusCode != http.StatusOK {
36-
return "", fmt.Errorf("unknown error, status code: %d: %s", res.StatusCode, body)
36+
return "", fmt.Errorf("cannot load image, status code: %d: %s", res.StatusCode, body)
3737
}
3838
err = json.Unmarshal(body, &response)
3939
if err != nil {

api/image_pull.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (c *API) ImagePull(ctx context.Context, nameWithTag string, auth ImageAuthC
3232
defer res.Body.Close()
3333
if res.StatusCode != http.StatusOK {
3434
body, _ := ioutil.ReadAll(res.Body)
35-
return "", fmt.Errorf("unknown error, status code: %d: %s", res.StatusCode, body)
35+
return "", fmt.Errorf("cannot pull image, status code: %d: %s", res.StatusCode, body)
3636
}
3737

3838
dec := json.NewDecoder(res.Body)

api/system_info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (c *API) SystemInfo(ctx context.Context) (Info, error) {
2121
defer res.Body.Close()
2222

2323
if res.StatusCode != http.StatusOK {
24-
return infoData, fmt.Errorf("unknown error, status code: %d", res.StatusCode)
24+
return infoData, fmt.Errorf("cannot fetch Podman system info, status code: %d", res.StatusCode)
2525
}
2626
body, err := ioutil.ReadAll(res.Body)
2727
if err != nil {

0 commit comments

Comments
 (0)