mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-21 21:33:18 +01:00
feat: tries to use swarm node id if exists then machine-id (#3097)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
dozzle:
|
dozzle:
|
||||||
image: amir20/dozzle:agent
|
image: amir20/dozzle:pr-3097
|
||||||
environment:
|
environment:
|
||||||
- DOZZLE_LEVEL=debug
|
- DOZZLE_LEVEL=debug
|
||||||
- DOZZLE_MODE=swarm
|
- DOZZLE_MODE=swarm
|
||||||
|
|||||||
@@ -87,18 +87,19 @@ func NewClient(cli DockerCLI, filters filters.Args, host Host) Client {
|
|||||||
filters: filters,
|
filters: filters,
|
||||||
host: host,
|
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 {
|
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.NCPU = client.info.NCPU
|
||||||
host.MemTotal = client.info.MemTotal
|
host.MemTotal = client.info.MemTotal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("Creating a client with host: %+v", host)
|
||||||
|
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,8 +125,13 @@ func NewLocalClient(f map[string][]string, hostname string) (Client, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id := info.ID
|
||||||
|
if info.Swarm.NodeID != "" {
|
||||||
|
id = info.Swarm.NodeID
|
||||||
|
}
|
||||||
|
|
||||||
host := Host{
|
host := Host{
|
||||||
ID: info.ID,
|
ID: id,
|
||||||
Name: info.Name,
|
Name: info.Name,
|
||||||
MemTotal: info.MemTotal,
|
MemTotal: info.MemTotal,
|
||||||
NCPU: info.NCPU,
|
NCPU: info.NCPU,
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ func NewSwarmService(localClient docker.Client, certificates tls.Certificate) *M
|
|||||||
}
|
}
|
||||||
|
|
||||||
func closeAgent(agent *agent.Client) {
|
func closeAgent(agent *agent.Client) {
|
||||||
log.Debugf("closing agent %s", agent.Host().ID)
|
log.Tracef("closing agent %s", agent.Host())
|
||||||
if err := agent.Close(); err != nil {
|
if err := agent.Close(); err != nil {
|
||||||
log.Warnf("error closing agent: %v", err)
|
log.Warnf("error closing agent: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user