Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
network: Sort endpoints by name
Browse files Browse the repository at this point in the history
Sort endpoints by name to control the order in which
they are passed to the VM as the interface name inside
the VM depends on the order in which it is passed.

Long term we should come up with a more robust approach.

Fixes #785

Signed-off-by: Archana Shinde <[email protected]>
(cherry picked from commit 8f1b28d)
  • Loading branch information
amshinde committed Oct 11, 2018
1 parent a786643 commit d267da7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions virtcontainers/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -1356,6 +1357,12 @@ func createEndpointsFromScan(networkNSPath string, config NetworkConfig) ([]Endp
idx++
}

sort.Slice(endpoints, func(i, j int) bool {
return endpoints[i].Name() < endpoints[j].Name()
})

networkLogger().WithField("endpoints", endpoints).Info("Endpoints found after scan")

return endpoints, nil
}

Expand Down

0 comments on commit d267da7

Please sign in to comment.