mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Kubelet tests broken on Macs with uppercase names
Hostname behavior across operating systems is inconsistent (Macs can have uppercase host names, so can some other systems). In general, always strings.ToLower(os.Hostname()).
This commit is contained in:
parent
53ec66caf4
commit
0f87337667
@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
@ -367,5 +368,6 @@ func GeneratePodName(name string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
hostname = strings.ToLower(hostname)
|
||||
return fmt.Sprintf("%s-%s", name, hostname), nil
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
@ -172,6 +173,7 @@ func extractFromFile(filename string) (api.BoundPod, error) {
|
||||
if err != nil {
|
||||
return pod, err
|
||||
}
|
||||
hostname = strings.ToLower(hostname)
|
||||
|
||||
if len(pod.UID) == 0 {
|
||||
hasher := md5.New()
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -118,6 +119,7 @@ func TestExtractInvalidManifest(t *testing.T) {
|
||||
|
||||
func TestExtractFromHTTP(t *testing.T) {
|
||||
hostname, _ := os.Hostname()
|
||||
hostname = strings.ToLower(hostname)
|
||||
|
||||
var testCases = []struct {
|
||||
desc string
|
||||
|
@ -34,5 +34,5 @@ func GetHostname(hostnameOverride string) string {
|
||||
}
|
||||
hostname = fqdn
|
||||
}
|
||||
return strings.TrimSpace(string(hostname))
|
||||
return strings.ToLower(strings.TrimSpace(string(hostname)))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user