Skip to content

Commit

Permalink
zedrouter/appcontainer: fix connectivity to the VM docker
Browse files Browse the repository at this point in the history
From some version of the docker/client library the .NewClient()
call was deprecated, which caused the following error:

  "getAppContainers: Container list error Cannot connect to the Docker daemon at tcp://$IP:2375. Is the docker daemon running?"

because by default the connectivity was established through
the unix docker.sock socket.

This patch fixes the problem by passing the HTTP client to
the constructor of the docker client.

The main motiviation of this fix is the "Unknown" state of
"Modules" visible on the UI of the controller, because
statistics was never collected from the docker.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
  • Loading branch information
rouming authored and eriknordmark committed Jun 10, 2023
1 parent 977f42b commit b0b4777
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/pillar/cmd/zedrouter/appcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"encoding/json"
"io"
"net"
"net/http"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -324,7 +325,10 @@ func getAppContainerLogs(ctx *zedrouterContext, status types.AppNetworkStatus, l

func getAppContainers(status types.AppNetworkStatus) (*client.Client, []apitypes.Container, error) {
containerEndpoint := "tcp://" + status.GetStatsIPAddr.String() + ":" + strconv.Itoa(DOCKERAPIPORT)
cli, err := client.NewClient(containerEndpoint, DOCKERAPIVERSION, nil, nil)
cli, err := client.NewClientWithOpts(
client.WithHost(containerEndpoint),
client.WithVersion(DOCKERAPIVERSION),
client.WithHTTPClient(&http.Client{}))
if err != nil {
log.Errorf("getAppContainers: client create failed, error %v", err)
return nil, nil, err
Expand Down

0 comments on commit b0b4777

Please sign in to comment.