mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-21 13:23:07 +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:
|
||||
dozzle:
|
||||
image: amir20/dozzle:agent
|
||||
image: amir20/dozzle:pr-3097
|
||||
environment:
|
||||
- DOZZLE_LEVEL=debug
|
||||
- DOZZLE_MODE=swarm
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -114,7 +114,7 @@ func NewSwarmService(localClient docker.Client, certificates tls.Certificate) *M
|
||||
}
|
||||
|
||||
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 {
|
||||
log.Warnf("error closing agent: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user