kubeadm: detect runtime socket as URL format

- Update defaults for v1beta2 and 3 to have URL scheme
- Raname DefaultUrlScheme to DefaultContainerRuntimeURLScheme
- Prepend a missing URL scheme to user sockets and warn them
that this might not be supported in the future
- Update socket validation to exclude IsAbs() testing
(This is broken on Windows). Assume the path is not empty and has
URL scheme at this point (validation happens after defaulting).
- Use net.Dial to open Unix sockets
- Update all related unit tests

Signed-off-by: pacoxu <paco.xu@daocloud.io>
Signed-off-by: Lubomir I. Ivanov <lubomirivanov@vmware.com>
This commit is contained in:
pacoxu
2021-06-11 16:05:41 +08:00
committed by Lubomir I. Ivanov
parent 7c013c3f64
commit 7594f0ef90
18 changed files with 99 additions and 84 deletions

View File

@@ -41,20 +41,20 @@ func TestAnnotateCRISocket(t *testing.T) {
{
name: "CRI-socket annotation missing",
currentCRISocketAnnotation: "",
newCRISocketAnnotation: "/run/containerd/containerd.sock",
expectedPatch: `{"metadata":{"annotations":{"kubeadm.alpha.kubernetes.io/cri-socket":"/run/containerd/containerd.sock"}}}`,
newCRISocketAnnotation: "unix:///run/containerd/containerd.sock",
expectedPatch: `{"metadata":{"annotations":{"kubeadm.alpha.kubernetes.io/cri-socket":"unix:///run/containerd/containerd.sock"}}}`,
},
{
name: "CRI-socket annotation already exists",
currentCRISocketAnnotation: "/run/containerd/containerd.sock",
newCRISocketAnnotation: "/run/containerd/containerd.sock",
currentCRISocketAnnotation: "unix:///run/containerd/containerd.sock",
newCRISocketAnnotation: "unix:///run/containerd/containerd.sock",
expectedPatch: `{}`,
},
{
name: "CRI-socket annotation needs to be updated",
currentCRISocketAnnotation: "/var/run/dockershim.sock",
newCRISocketAnnotation: "/run/containerd/containerd.sock",
expectedPatch: `{"metadata":{"annotations":{"kubeadm.alpha.kubernetes.io/cri-socket":"/run/containerd/containerd.sock"}}}`,
currentCRISocketAnnotation: "unix:///var/run/dockershim.sock",
newCRISocketAnnotation: "unix:///run/containerd/containerd.sock",
expectedPatch: `{"metadata":{"annotations":{"kubeadm.alpha.kubernetes.io/cri-socket":"unix:///run/containerd/containerd.sock"}}}`,
},
}