The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7705
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From fe18cbdb747e1c802887a03d2d25aa210ab0e7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 28 Jul 2020 18:50:52 -0400 Subject: [PATCH 1/2] client: Move proxyMigration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- client/lxd_containers.go | 85 ---------------------------------------- client/lxd_instances.go | 85 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 85 deletions(-) diff --git a/client/lxd_containers.go b/client/lxd_containers.go index 6a65051d2a..61fa5a3b8a 100644 --- a/client/lxd_containers.go +++ b/client/lxd_containers.go @@ -499,91 +499,6 @@ func (r *ProtocolLXD) CopyContainer(source InstanceServer, container api.Contain return r.tryCreateContainer(req, info.Addresses) } -func (r *ProtocolLXD) proxyMigration(targetOp *operation, targetSecrets map[string]string, source InstanceServer, sourceOp *operation, sourceSecrets map[string]string) error { - // Sanity checks - for n := range targetSecrets { - _, ok := sourceSecrets[n] - if !ok { - return fmt.Errorf("Migration target expects the \"%s\" socket but source isn't providing it", n) - } - } - - if targetSecrets["control"] == "" { - return fmt.Errorf("Migration target didn't setup the required \"control\" socket") - } - - // Struct used to hold everything together - type proxy struct { - done chan bool - sourceConn *websocket.Conn - targetConn *websocket.Conn - } - - proxies := map[string]*proxy{} - - // Connect the control socket - sourceConn, err := source.GetOperationWebsocket(sourceOp.ID, sourceSecrets["control"]) - if err != nil { - return err - } - - targetConn, err := r.GetOperationWebsocket(targetOp.ID, targetSecrets["control"]) - if err != nil { - return err - } - - proxies["control"] = &proxy{ - done: shared.WebsocketProxy(sourceConn, targetConn), - sourceConn: sourceConn, - targetConn: targetConn, - } - - // Connect the data sockets - for name := range sourceSecrets { - if name == "control" { - continue - } - - // Handle resets (used for multiple objects) - sourceConn, err := source.GetOperationWebsocket(sourceOp.ID, sourceSecrets[name]) - if err != nil { - break - } - - targetConn, err := r.GetOperationWebsocket(targetOp.ID, targetSecrets[name]) - if err != nil { - break - } - - proxies[name] = &proxy{ - sourceConn: sourceConn, - targetConn: targetConn, - done: shared.WebsocketProxy(sourceConn, targetConn), - } - } - - // Cleanup once everything is done - go func() { - // Wait for control socket - <-proxies["control"].done - proxies["control"].sourceConn.Close() - proxies["control"].targetConn.Close() - - // Then deal with the others - for name, proxy := range proxies { - if name == "control" { - continue - } - - <-proxy.done - proxy.sourceConn.Close() - proxy.targetConn.Close() - } - }() - - return nil -} - // UpdateContainer updates the container definition func (r *ProtocolLXD) UpdateContainer(name string, container api.ContainerPut, ETag string) (Operation, error) { // Send the request diff --git a/client/lxd_instances.go b/client/lxd_instances.go index 8140aa1798..45d192760f 100644 --- a/client/lxd_instances.go +++ b/client/lxd_instances.go @@ -2216,3 +2216,88 @@ func (r *ProtocolLXD) GetInstanceBackupFile(instanceName string, name string, re return &resp, nil } + +func (r *ProtocolLXD) proxyMigration(targetOp *operation, targetSecrets map[string]string, source InstanceServer, sourceOp *operation, sourceSecrets map[string]string) error { + // Sanity checks + for n := range targetSecrets { + _, ok := sourceSecrets[n] + if !ok { + return fmt.Errorf("Migration target expects the \"%s\" socket but source isn't providing it", n) + } + } + + if targetSecrets["control"] == "" { + return fmt.Errorf("Migration target didn't setup the required \"control\" socket") + } + + // Struct used to hold everything together + type proxy struct { + done chan bool + sourceConn *websocket.Conn + targetConn *websocket.Conn + } + + proxies := map[string]*proxy{} + + // Connect the control socket + sourceConn, err := source.GetOperationWebsocket(sourceOp.ID, sourceSecrets["control"]) + if err != nil { + return err + } + + targetConn, err := r.GetOperationWebsocket(targetOp.ID, targetSecrets["control"]) + if err != nil { + return err + } + + proxies["control"] = &proxy{ + done: shared.WebsocketProxy(sourceConn, targetConn), + sourceConn: sourceConn, + targetConn: targetConn, + } + + // Connect the data sockets + for name := range sourceSecrets { + if name == "control" { + continue + } + + // Handle resets (used for multiple objects) + sourceConn, err := source.GetOperationWebsocket(sourceOp.ID, sourceSecrets[name]) + if err != nil { + break + } + + targetConn, err := r.GetOperationWebsocket(targetOp.ID, targetSecrets[name]) + if err != nil { + break + } + + proxies[name] = &proxy{ + sourceConn: sourceConn, + targetConn: targetConn, + done: shared.WebsocketProxy(sourceConn, targetConn), + } + } + + // Cleanup once everything is done + go func() { + // Wait for control socket + <-proxies["control"].done + proxies["control"].sourceConn.Close() + proxies["control"].targetConn.Close() + + // Then deal with the others + for name, proxy := range proxies { + if name == "control" { + continue + } + + <-proxy.done + proxy.sourceConn.Close() + proxy.targetConn.Close() + } + }() + + return nil +} From cb4270a313657b33fd5ef01247f1d43b05a47dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 28 Jul 2020 18:51:24 -0400 Subject: [PATCH 2/2] lxd: Port remaining calls to instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #7701 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/instance_post.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lxd/instance_post.go b/lxd/instance_post.go index fa8dcaeedf..8111451073 100644 --- a/lxd/instance_post.go +++ b/lxd/instance_post.go @@ -327,17 +327,17 @@ func containerPostClusteringMigrate(d *Daemon, c instance.Instance, oldName, new } // First make a copy on the new node of the container to be moved. - entry, _, err := source.GetContainer(oldName) + entry, _, err := source.GetInstance(oldName) if err != nil { return errors.Wrap(err, "Failed to get instance info") } - args := lxd.ContainerCopyArgs{ + args := lxd.InstanceCopyArgs{ Name: destName, Mode: "pull", } - copyOp, err := dest.CopyContainer(source, *entry, &args) + copyOp, err := dest.CopyInstance(source, *entry, &args) if err != nil { return errors.Wrap(err, "Failed to issue copy instance API request") } @@ -348,7 +348,7 @@ func containerPostClusteringMigrate(d *Daemon, c instance.Instance, oldName, new } // Delete the container on the original node. - deleteOp, err := source.DeleteContainer(oldName) + deleteOp, err := source.DeleteInstance(oldName) if err != nil { return errors.Wrap(err, "Failed to issue delete instance API request") }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel