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]>
  • Loading branch information
amshinde committed Oct 11, 2018
1 parent c3cfe82 commit 8f1b28d
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 @@ -16,6 +16,7 @@ import (
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -1670,6 +1671,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 8f1b28d

Please sign in to comment.