mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Fixing various bugs related to windows.
This changes the crictl template for issues with the socket information. It also addresses a typo in the socket address. Last it makes tweaks to configuration that aren't required or had incorrect logic. Signed-off-by: Jamie Phillips <jamie.phillips@suse.com> spelling
This commit is contained in:
parent
4be912b9c5
commit
a62d143936
@ -10,5 +10,5 @@ import (
|
||||
|
||||
func applyContainerdStateAndAddress(nodeConfig *config.Node) {
|
||||
nodeConfig.Containerd.State = filepath.Join(nodeConfig.Containerd.Root, "state")
|
||||
nodeConfig.Containerd.Address = "npipe://///./pipe/containerd-containerd"
|
||||
nodeConfig.Containerd.Address = "npipe:////./pipe/containerd-containerd"
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package templates
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/url"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
@ -18,7 +19,7 @@ required_plugins = []
|
||||
oom_score = 0
|
||||
|
||||
[grpc]
|
||||
address = "{{ replace .NodeConfig.Containerd.Address }}"
|
||||
address = "{{ deschemify .NodeConfig.Containerd.Address }}"
|
||||
tcp_address = ""
|
||||
tcp_tls_cert = ""
|
||||
tcp_tls_key = ""
|
||||
@ -165,6 +166,16 @@ func ParseTemplateFromConfig(templateBuffer string, config interface{}) (string,
|
||||
"replace": func(s string) string {
|
||||
return strings.ReplaceAll(s, "\\", "\\\\")
|
||||
},
|
||||
"deschemify": func(s string) string {
|
||||
if strings.HasPrefix(s, "npipe:") {
|
||||
u, err := url.Parse(s)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return u.Path
|
||||
}
|
||||
return s
|
||||
},
|
||||
}
|
||||
t := template.Must(template.New("compiled_template").Funcs(funcs).Parse(templateBuffer))
|
||||
if err := t.Execute(out, config); err != nil {
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
|
||||
const (
|
||||
unixPrefix = "unix://"
|
||||
windowsPrefix = "npipe:"
|
||||
windowsPrefix = "npipe://"
|
||||
)
|
||||
|
||||
func Agent(config *config.Agent) error {
|
||||
|
@ -16,8 +16,12 @@ import (
|
||||
"k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes"
|
||||
)
|
||||
|
||||
var (
|
||||
NetworkName string = "vxlan0"
|
||||
)
|
||||
|
||||
func checkRuntimeEndpoint(cfg *config.Agent, argsMap map[string]string) {
|
||||
if strings.HasPrefix(argsMap["container-runtime-endpoint"], windowsPrefix) {
|
||||
if strings.HasPrefix(cfg.RuntimeSocket, windowsPrefix) {
|
||||
argsMap["container-runtime-endpoint"] = cfg.RuntimeSocket
|
||||
} else {
|
||||
argsMap["container-runtime-endpoint"] = windowsPrefix + cfg.RuntimeSocket
|
||||
@ -35,9 +39,7 @@ func kubeProxyArgs(cfg *config.Agent) map[string]string {
|
||||
argsMap["hostname-override"] = cfg.NodeName
|
||||
}
|
||||
|
||||
argsMap["feature-gates"] = addFeatureGate(argsMap["feature-gates"], "WinOverlay=true")
|
||||
|
||||
if sourceVip := waitForManagementIp("vxlan0"); sourceVip != "" {
|
||||
if sourceVip := waitForManagementIp(NetworkName); sourceVip != "" {
|
||||
argsMap["source-vip"] = sourceVip
|
||||
}
|
||||
|
||||
@ -133,7 +135,7 @@ func waitForManagementIp(networkName string) string {
|
||||
for range time.Tick(time.Second * 5) {
|
||||
network, err := hcsshim.GetHNSEndpointByName(networkName)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Warning("can't find %s, retrying", networkName)
|
||||
logrus.WithError(err).Warning("can't find HNS endpoint for network, retrying", networkName)
|
||||
continue
|
||||
}
|
||||
return network.IPAddress.String()
|
||||
|
47
pkg/daemons/agent/agent_windows_test.go
Normal file
47
pkg/daemons/agent/agent_windows_test.go
Normal file
@ -0,0 +1,47 @@
|
||||
// +build windows
|
||||
|
||||
package agent
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rancher/k3s/pkg/daemons/config"
|
||||
)
|
||||
|
||||
func TestCheckRuntimeEndpoint(t *testing.T) {
|
||||
type args struct {
|
||||
cfg *config.Agent
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Runtime endpoint unaltered",
|
||||
args: args{
|
||||
cfg: &config.Agent{RuntimeSocket: "npipe:////./pipe/containerd-containerd"},
|
||||
},
|
||||
want: "npipe:////./pipe/containerd-containerd",
|
||||
},
|
||||
{
|
||||
name: "Runtime endpoint altered",
|
||||
args: args{
|
||||
cfg: &config.Agent{RuntimeSocket: "//./pipe/containerd-containerd"},
|
||||
},
|
||||
want: "npipe:////./pipe/containerd-containerd",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
argsMap := map[string]string{}
|
||||
checkRuntimeEndpoint(tt.args.cfg, argsMap)
|
||||
if argsMap["container-runtime-endpoint"] != tt.want {
|
||||
got := argsMap["container-runtime-endpoint"]
|
||||
t.Errorf("error, input was " + tt.args.cfg.RuntimeSocket + " should be " + tt.want + ", but got " + got)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user