mirror of
https://github.com/amir20/dozzle.git
synced 2026-01-02 19:17:37 +01:00
fix: fixes broken host info for remote hosts. fixes #3103
This commit is contained in:
@@ -82,25 +82,20 @@ type httpClient struct {
|
||||
}
|
||||
|
||||
func NewClient(cli DockerCLI, filters filters.Args, host Host) Client {
|
||||
client := &httpClient{
|
||||
cli: cli,
|
||||
filters: filters,
|
||||
host: host,
|
||||
}
|
||||
var err error
|
||||
client.info, err = cli.Info(context.Background())
|
||||
|
||||
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 {
|
||||
host.NCPU = client.info.NCPU
|
||||
host.MemTotal = client.info.MemTotal
|
||||
host.NCPU = info.NCPU
|
||||
host.MemTotal = info.MemTotal
|
||||
|
||||
return &httpClient{
|
||||
cli: cli,
|
||||
filters: filters,
|
||||
host: host,
|
||||
}
|
||||
|
||||
log.Debugf("Creating a client with host: %+v", host)
|
||||
|
||||
return client
|
||||
}
|
||||
|
||||
// NewClientWithFilters creates a new instance of Client with docker filters
|
||||
|
||||
@@ -24,7 +24,7 @@ type Host struct {
|
||||
}
|
||||
|
||||
func (h Host) String() string {
|
||||
return fmt.Sprintf("ID: %s, Endpoint: %s", h.ID, h.Endpoint)
|
||||
return fmt.Sprintf("ID: %s, Endpoint: %s, nCPU: %d, memTotal: %d", h.ID, h.Endpoint, h.NCPU, h.MemTotal)
|
||||
}
|
||||
|
||||
func ParseConnection(connection string) (Host, error) {
|
||||
|
||||
@@ -38,6 +38,8 @@ func NewMultiHostService(clients []ClientService) *MultiHostService {
|
||||
if _, ok := m.clients[client.Host().ID]; ok {
|
||||
log.Warnf("duplicate host %s found, skipping", client.Host())
|
||||
continue
|
||||
} else {
|
||||
log.Debugf("found a new host %s", client.Host())
|
||||
}
|
||||
m.clients[client.Host().ID] = client
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user