Skip to content

Commit

Permalink
feature: use 'uname -n' instead of 'hostname' to get hostname
Browse files Browse the repository at this point in the history
fixes: #2194

- The `hostname` command may need to be downloaded on some machines,
but the `uname` command is always present.

- add comment for GetHostName

Signed-off-by: Pengda Yang <daz-3ux@proton.me>
  • Loading branch information
Daz-3ux committed Apr 25, 2023
1 parent 035b662 commit 05fcaa8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/infradriver/infradriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type InfraDriver interface {

// GetPlatform Get remote platform
GetPlatform(host net.IP) (v1.Platform, error)

// Gethostname Get remote host name
GetHostName(host net.IP) (string, error)
// Ping Ping remote host
Ping(host net.IP) error
Expand Down
2 changes: 1 addition & 1 deletion pkg/infradriver/ssh_infradriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (d *SSHInfraDriver) GetClusterLaunchApps() []string {
}

func (d *SSHInfraDriver) GetHostName(hostIP net.IP) (string, error) {
hostName, err := d.CmdToString(hostIP, nil, "hostname", "")
hostName, err := d.CmdToString(hostIP, nil, "uname -n", "")
if err != nil {
return "", err
}
Expand Down

0 comments on commit 05fcaa8

Please sign in to comment.