From 0ef7f0daa311d90189ae992a5d9589a12764589a Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Thu, 19 Dec 2024 10:58:22 +0000 Subject: [PATCH] lxd/instance/drivers/driver/lxc: Only call statusCode for local instances in Render Signed-off-by: Thomas Parrott --- lxd/instance/drivers/driver_lxc.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go index 43e60b5f2080..4a5748f5b868 100644 --- a/lxd/instance/drivers/driver_lxc.go +++ b/lxd/instance/drivers/driver_lxc.go @@ -3283,17 +3283,22 @@ func (d *lxc) Render(options ...func(response any) error) (state any, etag any, // Prepare the ETag etag = []any{d.architecture, d.localConfig, d.localDevices, d.ephemeral, d.profiles} - statusCode := d.statusCode() instState := api.Instance{ ExpandedConfig: d.expandedConfig, ExpandedDevices: d.expandedDevices.CloneNative(), Name: d.name, - Status: statusCode.String(), - StatusCode: statusCode, + StatusCode: api.Error, // Default to error status for remote instances that are unreachable. Location: d.node, Type: d.Type().String(), } + // If instance is local then request status. + if d.state.ServerName == d.Location() { + instState.StatusCode = d.statusCode() + } + + instState.Status = instState.StatusCode.String() + instState.Description = d.description instState.Architecture = architectureName instState.Config = d.localConfig