Skip to content

Commit

Permalink
Changing DetermineNodename to return when priority name is found
Browse files Browse the repository at this point in the history
  • Loading branch information
insequent committed Nov 12, 2018
1 parent 65c254c commit 7b51b13
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions internal/pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,23 @@ func Min(a, b int) int {
// 2. Nodename from the file /var/lib/calico/nodename
// 3. Hostname field in NetConf (DEPRECATED).
// 4. OS Hostname.
func DetermineNodename(conf types.NetConf) string {
nodename, _ := names.Hostname()
if conf.Hostname != "" {
nodename = conf.Hostname
logrus.Warn("Configuration option 'hostname' is deprecated, use 'nodename' instead.")
}
if nff := nodenameFromFile(); nff != "" {
logrus.Debugf("Read node name from file: %s", nff)
nodename = nff
}
func DetermineNodename(conf types.NetConf) (nodename string) {
if conf.Nodename != "" {
logrus.Debugf("Read node name from CNI conf: %s", conf.Nodename)
nodename = conf.Nodename
} else if nff := nodenameFromFile(); nff != "" {
logrus.Debugf("Read node name from file: %s", nff)
nodename = nff
} else if conf.Hostname != "" {
nodename = conf.Hostname
logrus.Warn("Configuration option 'hostname' is deprecated, use 'nodename' instead")
} else {
nodename, _ = names.Hostname()
logrus.Debugf("Read node name from OS Hostname")
}

logrus.Debugf("Using node name %s", nodename)
return nodename
return
}

// nodenameFromFile reads the /var/lib/calico/nodename file if it exists and
Expand Down

0 comments on commit 7b51b13

Please sign in to comment.