1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 06:28:42 +01:00

feat: tries to use swarm node id if exists then machine-id (#3097)

This commit is contained in:
Amir Raminfar
2024-07-11 12:09:49 -07:00
committed by GitHub
parent 8277902020
commit c5771fa9a4
3 changed files with 15 additions and 9 deletions

View File

@@ -87,18 +87,19 @@ func NewClient(cli DockerCLI, filters filters.Args, host Host) Client {
filters: filters,
host: host,
}
var err error
client.info, err = cli.Info(context.Background())
if err != nil {
log.Errorf("unable to get docker info: %v", err)
}
if host.MemTotal == 0 || host.NCPU == 0 {
var err error
client.info, err = cli.Info(context.Background())
if err != nil {
log.Errorf("unable to get docker info: %v", err)
}
host.NCPU = client.info.NCPU
host.MemTotal = client.info.MemTotal
}
log.Debugf("Creating a client with host: %+v", host)
return client
}
@@ -124,8 +125,13 @@ func NewLocalClient(f map[string][]string, hostname string) (Client, error) {
return nil, err
}
id := info.ID
if info.Swarm.NodeID != "" {
id = info.Swarm.NodeID
}
host := Host{
ID: info.ID,
ID: id,
Name: info.Name,
MemTotal: info.MemTotal,
NCPU: info.NCPU,