mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
fix: machine name for failed machines in 'uc ps'
This commit is contained in:
+7
-7
@@ -205,18 +205,12 @@ func collectContainers(ctx context.Context, cli *client.Client) ([]containerInfo
|
|||||||
|
|
||||||
var containers []containerInfo
|
var containers []containerInfo
|
||||||
for _, msc := range machineContainers {
|
for _, msc := range machineContainers {
|
||||||
machineName := "unknown"
|
|
||||||
|
|
||||||
// Metadata can be nil if the request was broadcasted to only one machine.
|
// Metadata can be nil if the request was broadcasted to only one machine.
|
||||||
if msc.Metadata == nil && len(machineContainers) > 1 {
|
if msc.Metadata == nil && len(machineContainers) > 1 {
|
||||||
return nil, fmt.Errorf("something went wrong with gRPC proxy: metadata is missing for a machine response")
|
return nil, fmt.Errorf("something went wrong with gRPC proxy: metadata is missing for a machine response")
|
||||||
}
|
}
|
||||||
if msc.Metadata != nil && msc.Metadata.Error != "" {
|
|
||||||
client.PrintWarning(fmt.Sprintf("failed to list containers on machine %s: %s", machineName,
|
|
||||||
msc.Metadata.Error))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
|
machineName := "unknown"
|
||||||
if msc.Metadata != nil {
|
if msc.Metadata != nil {
|
||||||
var ok bool
|
var ok bool
|
||||||
machineName, ok = machinesNamesByIP[msc.Metadata.Machine]
|
machineName, ok = machinesNamesByIP[msc.Metadata.Machine]
|
||||||
@@ -231,6 +225,12 @@ func collectContainers(ctx context.Context, cli *client.Client) ([]containerInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if msc.Metadata != nil && msc.Metadata.Error != "" {
|
||||||
|
client.PrintWarning(fmt.Sprintf("failed to list containers on machine %s: %s", machineName,
|
||||||
|
msc.Metadata.Error))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
for _, ctr := range msc.Containers {
|
for _, ctr := range msc.Containers {
|
||||||
if ctr.Container.State == nil || ctr.Container.Config == nil {
|
if ctr.Container.State == nil || ctr.Container.Config == nil {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user