mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07: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"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
@ -268,18 +267,11 @@ func newPCCloud(cfg PCConfig) (*PCCloud, error) {
|
||||
vmID := cfg.Global.VMID
|
||||
|
||||
// Get local hostname
|
||||
cmd := exec.Command("bash", "-c", `echo $HOSTNAME`)
|
||||
out, err := cmd.CombinedOutput()
|
||||
hostname, err := os.Hostname()
|
||||
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
|
||||
}
|
||||
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{
|
||||
cfg: &cfg,
|
||||
localInstanceID: vmID,
|
||||
|
Loading…
Reference in New Issue
Block a user