mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Merge pull request #49743 from euank/hostname
Automatic merge from submit-queue (batch tested with PRs 49847, 49743, 49853, 50225, 50479) cloudprovider/photon: remove unneeded bash exec **Release note**: ```release-note NONE ```
This commit is contained in:
commit
1f2185fbfb
@ -31,7 +31,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
@ -268,18 +267,11 @@ func newPCCloud(cfg PCConfig) (*PCCloud, error) {
|
|||||||
vmID := cfg.Global.VMID
|
vmID := cfg.Global.VMID
|
||||||
|
|
||||||
// Get local hostname
|
// Get local hostname
|
||||||
cmd := exec.Command("bash", "-c", `echo $HOSTNAME`)
|
hostname, err := os.Hostname()
|
||||||
out, err := cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Photon Cloud Provider: get local hostname bash command failed. Error[%v]", err)
|
glog.Errorf("Photon Cloud Provider: get hostname failed. Error[%v]", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(out) == 0 {
|
|
||||||
glog.Errorf("unable to retrieve hostname for Instance ID")
|
|
||||||
return nil, fmt.Errorf("unable to retrieve hostname for Instance ID")
|
|
||||||
}
|
|
||||||
hostname := strings.TrimRight(string(out), "\n")
|
|
||||||
|
|
||||||
pc := PCCloud{
|
pc := PCCloud{
|
||||||
cfg: &cfg,
|
cfg: &cfg,
|
||||||
localInstanceID: vmID,
|
localInstanceID: vmID,
|
||||||
|
Loading…
Reference in New Issue
Block a user