The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3706
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) === Make sure we always get the exact same order. Closes #2895 Signed-off-by: Stéphane Graber <[email protected]>
From 6f1114560a4818c5c6b2a170c1b89f332b997edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Tue, 22 Aug 2017 02:35:40 -0400 Subject: [PATCH] Fix sorting order of devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure we always get the exact same order. Closes #2895 Signed-off-by: Stéphane Graber <[email protected]> --- lxd/types/devices.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lxd/types/devices.go b/lxd/types/devices.go index 263f4c435..8f735715c 100644 --- a/lxd/types/devices.go +++ b/lxd/types/devices.go @@ -132,14 +132,19 @@ func (devices sortableDevices) Less(i, j int) bool { a := devices[i] b := devices[j] + // First sort by types + if a.device["type"] != b.device["type"] { + return a.device["type"] < b.device["type"] + } + + // Special case disk paths if a.device["type"] == "disk" && b.device["type"] == "disk" { - if a.device["path"] == b.device["path"] { - return a.name < b.name + if a.device["path"] != b.device["path"] { + return a.device["path"] < b.device["path"] } - - return a.device["path"] < b.device["path"] } + // Fallback to sorting by names return a.name < b.name }
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
