From e795d0fa55a073dfe76a8c7f63cd325bc0b22517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Tue, 10 Oct 2023 17:01:32 -0400 Subject: [PATCH] cmd/incusd: Properly forward rebuild requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- cmd/incusd/instance_rebuild.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/incusd/instance_rebuild.go b/cmd/incusd/instance_rebuild.go index 344eeae9880..15e77718c88 100644 --- a/cmd/incusd/instance_rebuild.go +++ b/cmd/incusd/instance_rebuild.go @@ -70,6 +70,21 @@ func instanceRebuildPost(d *Daemon, r *http.Request) response.Response { return response.BadRequest(fmt.Errorf("Invalid instance name")) } + instanceType, err := urlInstanceTypeDetect(r) + if err != nil { + return response.SmartError(err) + } + + // Handle requests targeted to a container on a different node + resp, err := forwardedResponseIfInstanceIsRemote(s, r, targetProjectName, name, instanceType) + if err != nil { + return response.SmartError(err) + } + + if resp != nil { + return resp + } + // Parse the request req := api.InstanceRebuildPost{} err = json.NewDecoder(r.Body).Decode(&req)