jiebi/CodeConvo huggingface dataset:
return controller } <del> // newTestPods creates a list of pods (specification) for test. func newTestPods(numPods int, volume bool, imageName, podType string) []*v1.Pod { </del> <ins> // newDensityTestPods creates a list of pods (specification) for test. func newDensityTestPods(numPods int, volume bool, imageName, podType string) []*v1.Pod { </ins> var pods []*v1.Pod for i := 0; i < numPods; i++ { podName := "test-" + string(uuid.NewUUID()) <del> labels := map[string]string{ "type": podType, "name": podName, </del> <ins> pod := v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: podName, Labels: map[string]string{ "type": podType, "name": podName, }, }, Spec: v1.PodSpec{ // Restart policy is always (default). Containers: []v1.Container{ { Image: imageName, Name:  podName, }, }, NodeSelector: map[string]string{ "beta.kubernetes.io/os": "windows", }, }, </ins> } if volume { <del> pods = append(pods, &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name:   podName, Labels: labels, }, Spec: v1.PodSpec{ // Restart policy is always (default). Containers: []v1.Container{ { Image: imageName, Name:  podName, VolumeMounts: []v1.VolumeMount{ {MountPath: "/test-volume-mnt", Name: podName + "-volume"}, }, }, }, NodeSelector: map[string]string{ "beta.kubernetes.io/os": "windows", }, Volumes: []v1.Volume{ {Name: podName + "-volume", VolumeSource: v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}}, }, }, }) } else { pods = append(pods, &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name:   podName, Labels: labels, }, Spec: v1.PodSpec{ // Restart policy is always (default). Containers: []v1.Container{ { Image: imageName, Name:  podName, }, }, NodeSelector: map[string]string{ "beta.kubernetes.io/os": "windows", }, }, }) </del> <ins> pod.Spec.Containers[0].VolumeMounts = []v1.VolumeMount{ {MountPath: "/test-volume-mnt", Name: podName + "-volume"}, } pod.Spec.Volumes = []v1.Volume{ {Name: podName + "-volume", VolumeSource: v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}}, } </ins> } <ins> pods = append(pods, &pod) </ins> } return pods }
loadBalancer = createResponse.LoadBalancers[0] // Create Target Groups <del> addTagsInput := &elbv2.AddTagsInput{ ResourceArns: []*string{}, Tags:         []*elbv2.Tag{}, } </del> <ins> resourceArns := make([]*string, 0, len(mappings)) </ins> for i := range mappings { // It is easier to keep track of updates by having possibly
if err != nil { return nil, fmt.Errorf("Error creating listener: %q", err) } <del> addTagsInput.ResourceArns = append(addTagsInput.ResourceArns, targetGroupArn) </del> <ins> resourceArns = append(resourceArns, targetGroupArn) </ins> } // Add tags to targets <ins> targetGroupTags := make([]*elbv2.Tag, 0, len(tags)) </ins> for k, v := range tags { <del> addTagsInput.Tags = append(addTagsInput.Tags, &elbv2.Tag{ </del> <ins> targetGroupTags = append(targetGroupTags, &elbv2.Tag{ </ins> Key: aws.String(k), Value: aws.String(v), }) } <del> if len(addTagsInput.ResourceArns) > 0 && len(addTagsInput.Tags) > 0 { _, err = c.elbv2.AddTags(addTagsInput) if err != nil { return nil, fmt.Errorf("Error adding tags after creating Load Balancer: %q", err) </del> <ins> if len(resourceArns) > 0 && len(targetGroupTags) > 0 { // elbv2.AddTags doesn't allow to tag multiple resources at once for _, arn := range resourceArns { _, err = c.elbv2.AddTags(&elbv2.AddTagsInput{ ResourceArns: []*string{arn}, Tags:         targetGroupTags, }) if err != nil { return nil, fmt.Errorf("Error adding tags after creating Load Balancer: %q", err) } </ins> } } } else {
} if _, exists := configMap.Data[keyName]; exists { <del> return fmt.Errorf("cannot add key %s, another key by that name already exists in data: %v", keyName, configMap.Data) </del> <ins> return fmt.Errorf("cannot add key %q, another key by that name already exists in Data for ConfigMap %q", keyName, configMap.Name) </ins> } if _, exists := configMap.BinaryData[keyName]; exists { <del> return fmt.Errorf("cannot add key %s, another key by that name already exists in binaryData: %v", keyName, configMap.BinaryData) </del> <ins> return fmt.Errorf("cannot add key %q, another key by that name already exists in BinaryData for ConfigMap %q", keyName, configMap.Name) </ins> } return nil }
driverNodeID, maxVolumePerNode, accessibleTopology, err := csi.NodeGetInfo(ctx) if err != nil { <del> klog.Error(log("registrationHandler.RegisterPlugin failed at CSI.NodeGetInfo: %v", err)) </del> if unregErr := unregisterDriver(pluginName); unregErr != nil { klog.Error(log("registrationHandler.RegisterPlugin failed to unregister plugin due to previous error: %v", unregErr)) <del> return unregErr </del> } return err } err = nim.InstallCSIDriver(pluginName, driverNodeID, maxVolumePerNode, accessibleTopology) if err != nil { <del> klog.Error(log("registrationHandler.RegisterPlugin failed at AddNodeInfo: %v", err)) </del> if unregErr := unregisterDriver(pluginName); unregErr != nil { klog.Error(log("registrationHandler.RegisterPlugin failed to unregister plugin due to previous error: %v", unregErr)) <del> return unregErr </del> } return err }
// Images used for ConformanceContainer are not added into NodeImageWhiteList, because this test is // testing image pulling, these images don't need to be prepulled. The ImagePullPolicy // is v1.PullAlways, so it won't be blocked by framework image white list check. <del> imagePullTest := func(image string, hasSecret bool, expectedPhase v1.PodPhase, expectedPullStatus bool) { </del> <ins> imagePullTest := func(image string, hasSecret bool, expectedPhase v1.PodPhase, expectedPullStatus bool, windowsImage bool) { command := []string{"/bin/sh", "-c", "while true; do sleep 1; done"} if windowsImage { // -t: Ping the specified host until stopped. command = []string{"ping", "-t", "localhost"} } </ins> container := ConformanceContainer{ PodClient: f.PodClient(), Container: v1.Container{ Name:            "image-pull-test", Image:           image, <del> Command:         []string{"/bin/sh", "-c", "while true; do sleep 1; done"}, </del> <ins> Command:         command, </ins> ImagePullPolicy: v1.PullAlways, }, RestartPolicy: v1.RestartPolicyNever,
It("should not be able to pull image from invalid registry [NodeConformance]", func() { image := "invalid.com/invalid/alpine:3.1" <del> imagePullTest(image, false, v1.PodPending, true) </del> <ins> imagePullTest(image, false, v1.PodPending, true, false) </ins> }) It("should not be able to pull non-existing image from gcr.io [NodeConformance]", func() { image := "k8s.gcr.io/invalid-image:invalid-tag" <del> imagePullTest(image, false, v1.PodPending, true) </del> <ins> imagePullTest(image, false, v1.PodPending, true, false) </ins> }) <del> // TODO(claudiub): Add a Windows equivalent test. </del> It("should be able to pull image from gcr.io [LinuxOnly] [NodeConformance]", func() { image := "gcr.io/google-containers/debian-base:0.4.1" <del> imagePullTest(image, false, v1.PodRunning, false) </del> <ins> imagePullTest(image, false, v1.PodRunning, false, false) }) It("should be able to pull image from gcr.io [NodeConformance]", func() { framework.SkipUnlessNodeOSDistroIs("windows") image := "gcr.io/kubernetes-e2e-test-images/windows-nanoserver:v1" imagePullTest(image, false, v1.PodRunning, false, true) </ins> }) It("should be able to pull image from docker hub [LinuxOnly] [NodeConformance]", func() { image := "alpine:3.7" <del> imagePullTest(image, false, v1.PodRunning, false) </del> <ins> imagePullTest(image, false, v1.PodRunning, false, false) </ins> }) <del> It("should be able to pull image from docker hub [WindowsOnly] [NodeConformance]", func() { </del> <ins> It("should be able to pull image from docker hub [NodeConformance]", func() { </ins> framework.SkipUnlessNodeOSDistroIs("windows") <ins> // TODO(claudiub): Switch to nanoserver image manifest list. </ins> image := "e2eteam/busybox:1.29" <del> imagePullTest(image, false, v1.PodRunning, false) </del> <ins> imagePullTest(image, false, v1.PodRunning, false, true) </ins> }) It("should not be able to pull from private registry without secret [NodeConformance]", func() { image := "gcr.io/authenticated-image-pulling/alpine:3.7" <del> imagePullTest(image, false, v1.PodPending, true) </del> <ins> imagePullTest(image, false, v1.PodPending, true, false) </ins> }) It("should be able to pull from private registry with secret [LinuxOnly] [NodeConformance]", func() { image := "gcr.io/authenticated-image-pulling/alpine:3.7" <del> imagePullTest(image, true, v1.PodRunning, false) </del> <ins> imagePullTest(image, true, v1.PodRunning, false, false) }) It("should be able to pull from private registry with secret [NodeConformance]", func() { framework.SkipUnlessNodeOSDistroIs("windows") image := "gcr.io/authenticated-image-pulling/windows-nanoserver:v1" imagePullTest(image, true, v1.PodRunning, false, true) </ins> }) }) })
podsDir string) (volumetypes.GeneratedOperations, error) { var pluginName string <del> if useCSIPlugin(og.volumePluginMgr, volumeToUnmount.VolumeSpec) { </del> <ins> if volumeToUnmount.VolumeSpec != nil && useCSIPlugin(og.volumePluginMgr, volumeToUnmount.VolumeSpec) { </ins> pluginName = csi.CSIPluginName } else { pluginName = volumeToUnmount.PluginName
"//vendor/k8s.io/utils/mount:go_default_library", "//vendor/k8s.io/utils/net:go_default_library", "//vendor/k8s.io/utils/path:go_default_library", <ins> "//vendor/k8s.io/utils/strings:go_default_library", </ins> ] + select({ "@io_bazel_rules_go//go/platform:windows": [ "//pkg/kubelet/winstats:go_default_library",
if err != nil { return volumes, fmt.Errorf("could not read directory %s: %v", volumePluginPath, err) } <del> for _, volumeDir := range volumeDirs { volumes = append(volumes, filepath.Join(volumePluginPath, volumeDir)) </del> <ins> unescapePluginName := utilstrings.UnescapeQualifiedName(volumePluginName) if unescapePluginName != csi.CSIPluginName { for _, volumeDir := range volumeDirs { volumes = append(volumes, filepath.Join(volumePluginPath, volumeDir)) } } else { // For CSI volumes, the mounted volume path has an extra sub path "/mount", so also add it // to the list if the mounted path exists. for _, volumeDir := range volumeDirs { path := filepath.Join(volumePluginPath, volumeDir) csimountpath := csi.GetCSIMounterPath(path) if pathExists, _ := mount.PathExists(csimountpath); pathExists { volumes = append(volumes, csimountpath) } } </ins> } } return volumes, nil
if err != nil { return mountedVolumes, err } <ins> // Only use IsLikelyNotMountPoint to check might not cover all cases. For CSI volumes that // either: 1) don't mount or 2) bind mount in the rootfs, the mount check will not work as expected. // We plan to remove this mountpoint check as a condition before deleting pods since it is // not reliable and the condition might be different for different types of volumes. But it requires // a reliable way to clean up unused volume dir to avoid problems during pod deletion. See discussion in issue #74650 </ins> for _, volumePath := range volumePaths { isNotMount, err := kl.mounter.IsLikelyNotMountPoint(volumePath) if err != nil { <del> return mountedVolumes, err </del> <ins> return mountedVolumes, fmt.Errorf("fail to check mount point %q: %v", volumePath, err) </ins> } if !isNotMount { mountedVolumes = append(mountedVolumes, volumePath)
v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" <ins> "k8s.io/apimachinery/pkg/types" </ins> _ "k8s.io/kubernetes/pkg/apis/core/install" <ins> "k8s.io/utils/mount" </ins> ) func validateDirExists(dir string) error {
}) } } <ins> func TestPodVolumesExistWithMount(t *testing.T) { poduid := types.UID("poduid") testCases := map[string]struct { prepareFunc func(kubelet *Kubelet) error expected    bool }{ "noncsivolume-dir-not-exist": { prepareFunc: func(kubelet *Kubelet) error { return nil }, expected: false, }, "noncsivolume-dir-exist-noplugins": { prepareFunc: func(kubelet *Kubelet) error { podDir := kubelet.getPodDir(poduid) return os.MkdirAll(filepath.Join(podDir, "volumes/"), 0750) }, expected: false, }, "noncsivolume-dir-exist-nomount": { prepareFunc: func(kubelet *Kubelet) error { podDir := kubelet.getPodDir(poduid) return os.MkdirAll(filepath.Join(podDir, "volumes/plugin/name"), 0750) }, expected: false, }, "noncsivolume-dir-exist-with-mount": { prepareFunc: func(kubelet *Kubelet) error { podDir := kubelet.getPodDir(poduid) volumePath := filepath.Join(podDir, "volumes/plugin/name") if err := os.MkdirAll(volumePath, 0750); err != nil { return err } fm := mount.NewFakeMounter( []mount.MountPoint{ {Device: "/dev/sdb", Path: volumePath}, }) kubelet.mounter = fm return nil }, expected: true, }, "noncsivolume-dir-exist-nomount-withcsimountpath": { prepareFunc: func(kubelet *Kubelet) error { podDir := kubelet.getPodDir(poduid) volumePath := filepath.Join(podDir, "volumes/plugin/name/mount") if err := os.MkdirAll(volumePath, 0750); err != nil { return err } fm := mount.NewFakeMounter( []mount.MountPoint{ {Device: "/dev/sdb", Path: volumePath}, }) kubelet.mounter = fm return nil }, expected: false, }, "csivolume-dir-exist-nomount": { prepareFunc: func(kubelet *Kubelet) error { podDir := kubelet.getPodDir(poduid) volumePath := filepath.Join(podDir, "volumes/kubernetes.io~csi/name") return os.MkdirAll(volumePath, 0750) }, expected: false, }, "csivolume-dir-exist-mount-nocsimountpath": { prepareFunc: func(kubelet *Kubelet) error { podDir := kubelet.getPodDir(poduid) volumePath := filepath.Join(podDir, "volumes/kubernetes.io~csi/name/mount") return os.MkdirAll(volumePath, 0750) }, expected: false, }, "csivolume-dir-exist-withcsimountpath": { prepareFunc: func(kubelet *Kubelet) error { podDir := kubelet.getPodDir(poduid) volumePath := filepath.Join(podDir, "volumes/kubernetes.io~csi/name/mount") if err := os.MkdirAll(volumePath, 0750); err != nil { return err } fm := mount.NewFakeMounter( []mount.MountPoint{ {Device: "/dev/sdb", Path: volumePath}, }) kubelet.mounter = fm return nil }, expected: true, }, } for name, tc := range testCases { t.Run(name, func(t *testing.T) { testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) defer testKubelet.Cleanup() kubelet := testKubelet.kubelet if tc.prepareFunc != nil { if err := tc.prepareFunc(kubelet); err != nil { t.Fatalf("%s failed preparation: %v", name, err) } } exist := kubelet.podVolumesExist(poduid) if tc.expected != exist { t.Errorf("%s failed: expected %t, got %t", name, tc.expected, exist) } }) } } </ins>
var _ volume.Volume = &csiMountMgr{} func (c *csiMountMgr) GetPath() string { <del> dir := filepath.Join(getTargetPath(c.podUID, c.specVolumeID, c.plugin.host), "/mount") </del> <ins> dir := GetCSIMounterPath(filepath.Join(getTargetPath(c.podUID, c.specVolumeID, c.plugin.host))) </ins> klog.V(4).Info(log("mounter.GetPath generated [%s]", dir)) return dir }
By("creating a file in subpath") cmd := "touch /volume_mount/mypath/foo/test.log" <del> _, err = framework.RunHostCmd(pod.Namespace, pod.Name, cmd) </del> <ins> _, _, err = f.ExecShellInPodWithFullOutput(pod.Name, cmd) </ins> if err != nil { framework.Failf("expected to be able to write to subpath") } By("test for file in mounted path") cmd = "test -f /subpath_mount/test.log" <del> _, err = framework.RunHostCmd(pod.Namespace, pod.Name, cmd) </del> <ins> _, _, err = f.ExecShellInPodWithFullOutput(pod.Name, cmd) </ins> if err != nil { framework.Failf("expected to be able to verify file") }
By("test for subpath mounted with old value") cmd := "test -f /volume_mount/foo/test.log" <del> _, err = framework.RunHostCmd(pod.Namespace, pod.Name, cmd) </del> <ins> _, _, err = f.ExecShellInPodWithFullOutput(pod.Name, cmd) </ins> if err != nil { framework.Failf("expected to be able to verify old file exists") } cmd = "test ! -f /volume_mount/newsubpath/test.log" <del> _, err = framework.RunHostCmd(pod.Namespace, pod.Name, cmd) </del> <ins> _, _, err = f.ExecShellInPodWithFullOutput(pod.Name, cmd) </ins> if err != nil { framework.Failf("expected to be able to verify new file does not exist") }
func waitForPodContainerRestart(f *framework.Framework, pod *v1.Pod, volumeMount string) { By("Failing liveness probe") <del> out, err := framework.RunKubectl("exec", fmt.Sprintf("--namespace=%s", pod.Namespace), pod.Name, "--container", pod.Spec.Containers[0].Name, "--", "/bin/sh", "-c", fmt.Sprintf("rm %v", volumeMount)) </del> <ins> stdout, stderr, err := f.ExecShellInPodWithFullOutput(pod.Name, fmt.Sprintf("rm %v", volumeMount)) </ins> <del> framework.Logf("Pod exec output: %v", out) </del> <ins> framework.Logf("Pod exec output: %v / %v", stdout, stderr) </ins> Expect(err).ToNot(HaveOccurred(), "while failing liveness probe") // Check that container has restarted
// Fix liveness probe By("Rewriting the file") <del> out, err = framework.RunKubectl("exec", fmt.Sprintf("--namespace=%s", pod.Namespace), pod.Name, "--container", pod.Spec.Containers[0].Name, "--", "/bin/sh", "-c", fmt.Sprintf("echo test-after > %v", volumeMount)) framework.Logf("Pod exec output: %v", out) </del> <ins> stdout, _, err = f.ExecShellInPodWithFullOutput(pod.Name, fmt.Sprintf("echo test-after > %v", volumeMount)) framework.Logf("Pod exec output: %v", stdout) </ins> Expect(err).ToNot(HaveOccurred(), "while rewriting the probe file") // Wait for container restarts to stabilize
} return GetUUIDFromProviderID(node.Spec.ProviderID), nil } <ins> func GetVMUUID() (string, error) { uuidFromFile, err := getRawUUID() if err != nil { return "", fmt.Errorf("error retrieving vm uuid: %s", err) } //strip leading and trailing white space and new line char uuid := strings.TrimSpace(uuidFromFile) // check the uuid starts with "VMware-" if !strings.HasPrefix(uuid, UUIDPrefix) { return "", fmt.Errorf("Failed to match Prefix, UUID read from the file is %v", uuidFromFile) } // Strip the prefix and white spaces and - uuid = strings.Replace(uuid[len(UUIDPrefix):(len(uuid))], " ", "", -1) uuid = strings.Replace(uuid, "-", "", -1) if len(uuid) != 32 { return "", fmt.Errorf("Length check failed, UUID read from the file is %v", uuidFromFile) } // need to add dashes, e.g. "564d395e-d807-e18a-cb25-b79f65eb2b9f" uuid = fmt.Sprintf("%s-%s-%s-%s-%s", uuid[0:8], uuid[8:12], uuid[12:16], uuid[16:20], uuid[20:32]) return uuid, nil } </ins>
package vsphere import ( <del> "fmt" </del> "io/ioutil" <del> "strings" </del> ) <del> const ( UUIDPath   = "/sys/class/dmi/id/product_serial" UUIDPrefix = "VMware-" ) </del> <ins> const UUIDPath = "/sys/class/dmi/id/product_serial" </ins> <del> func GetVMUUID() (string, error) { </del> <ins> func getRawUUID() (string, error) { </ins> id, err := ioutil.ReadFile(UUIDPath) if err != nil { <del> return "", fmt.Errorf("error retrieving vm uuid: %s", err) } uuidFromFile := string(id[:]) //strip leading and trailing white space and new line char uuid := strings.TrimSpace(uuidFromFile) // check the uuid starts with "VMware-" if !strings.HasPrefix(uuid, UUIDPrefix) { return "", fmt.Errorf("Failed to match Prefix, UUID read from the file is %v", uuidFromFile) } // Strip the prefix and white spaces and - uuid = strings.Replace(uuid[len(UUIDPrefix):(len(uuid))], " ", "", -1) uuid = strings.Replace(uuid, "-", "", -1) if len(uuid) != 32 { return "", fmt.Errorf("Length check failed, UUID read from the file is %v", uuidFromFile) </del> <ins> return "", err </ins> } <del> // need to add dashes, e.g. "564d395e-d807-e18a-cb25-b79f65eb2b9f" uuid = fmt.Sprintf("%s-%s-%s-%s-%s", uuid[0:8], uuid[8:12], uuid[12:16], uuid[16:20], uuid[20:32]) return uuid, nil </del> <ins> return string(id), nil </ins> }
"strings" ) <del> func GetVMUUID() (string, error) { result, err := exec.Command("wmic", "csproduct", "get", "UUID").Output() </del> <ins> func getRawUUID() (string, error) { result, err := exec.Command("wmic", "bios", "get", "serialnumber").Output() </ins> if err != nil { <del> return "", fmt.Errorf("error retrieving vm uuid: %s", err) </del> <ins> return "", err </ins> } <del> fields := strings.Fields(string(result)) if len(fields) != 2 { </del> <ins> lines := strings.FieldsFunc(string(result), func(r rune) bool { switch r { case 'n', 'r': return true default: return false } }) if len(lines) != 2 { </ins> return "", fmt.Errorf("received unexpected value retrieving vm uuid: %q", string(result)) } <del> return fields[1], nil </del> <ins> return lines[1], nil </ins> }
priorityClassName: system-node-critical hostNetwork: true nodeSelector: <del> # TODO(liggitt): switch to node.kubernetes.io/kube-proxy-ds-ready in 1.16 beta.kubernetes.io/kube-proxy-ds-ready: "true" </del> <ins> node.kubernetes.io/kube-proxy-ds-ready: "true" </ins> tolerations: - operator: "Exists" effect: "NoExecute"
fieldPath: metadata.namespace # END_PROMETHEUS_TO_SD nodeSelector: <del> # TODO(liggitt): switch to cloud.google.com/metadata-proxy-ready=true in v1.16 beta.kubernetes.io/metadata-proxy-ready: "true" </del> <ins> cloud.google.com/metadata-proxy-ready: "true" </ins> beta.kubernetes.io/os: linux terminationGracePeriodSeconds: 30
if [[ ${ENABLE_METADATA_CONCEALMENT:-} == "true" ]]; then # Put the necessary label on the node so the daemonset gets scheduled. NODE_LABELS="${NODE_LABELS},cloud.google.com/metadata-proxy-ready=true" <del> # TODO(liggitt): remove this in v1.16 NODE_LABELS="${NODE_LABELS},beta.kubernetes.io/metadata-proxy-ready=true" </del> # Add to the provider custom variables. PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_METADATA_CONCEALMENT METADATA_CONCEALMENT_NO_FIREWALL" fi
if [[ "${KUBE_PROXY_DAEMONSET:-}" == "true" && "${master}" != "true" ]]; then # Add kube-proxy daemonset label to node to avoid situation during cluster # upgrade/downgrade when there are two instances of kube-proxy running on a node. <del> # TODO(liggitt): drop beta.kubernetes.io/kube-proxy-ds-ready in 1.16 node_labels="node.kubernetes.io/kube-proxy-ds-ready=true,beta.kubernetes.io/kube-proxy-ds-ready=true" </del> <ins> node_labels="node.kubernetes.io/kube-proxy-ds-ready=true" </ins> fi if [[ -n "${NODE_LABELS:-}" ]]; then node_labels="${node_labels:+${node_labels},}${NODE_LABELS}"
"k8s.io/apimachinery/pkg/util/sets" utilfeature "k8s.io/apiserver/pkg/util/feature" cliflag "k8s.io/component-base/cli/flag" <del> "k8s.io/klog" </del> "k8s.io/kubelet/config/v1beta1" "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/features"
} } if len(unknownLabels) > 0 { <del> // TODO(liggitt): in 1.16, return an error klog.Warningf("unknown 'kubernetes.io' or 'k8s.io' labels specified with --node-labels: %v", unknownLabels.List()) klog.Warningf("in 1.16, --node-labels in the 'kubernetes.io' namespace must begin with an allowed prefix (%s) or be in the specifically allowed set (%s)", strings.Join(kubeletapis.KubeletLabelNamespaces(), ", "), strings.Join(kubeletapis.KubeletLabels(), ", ")) </del> <ins> return fmt.Errorf("unknown 'kubernetes.io' or 'k8s.io' labels specified with --node-labels: %vn--node-labels in the 'kubernetes.io' namespace must begin with an allowed prefix (%s) or be in the specifically allowed set (%s)", unknownLabels.List(), strings.Join(kubeletapis.KubeletLabelNamespaces(), ", "), strings.Join(kubeletapis.KubeletLabels(), ", ")) </ins> } return nil
}) return args } <ins> func TestValidateKubeletFlags(t *testing.T) { tests := []struct { name   string error  bool labels map[string]string }{ { name:  "Invalid kubernetes.io label", error: true, labels: map[string]string{ "beta.kubernetes.io/metadata-proxy-ready": "true", }, }, { name:  "Valid label outside of kubernetes.io and k8s.io", error: false, labels: map[string]string{ "cloud.google.com/metadata-proxy-ready": "true", }, }, { name:   "Empty label list", error:  false, labels: map[string]string{}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := ValidateKubeletFlags(&KubeletFlags{ NodeLabels: tt.labels, }) if tt.error && err == nil { t.Errorf("ValidateKubeletFlags should have failed with labels: %+v", tt.labels) } if !tt.error && err != nil { t.Errorf("ValidateKubeletFlags should not have failed with labels: %+v", tt.labels) } }) } } </ins>
addProfilingFlags(flags) <del> kubeConfigFlags := genericclioptions.NewConfigFlags(true) </del> <ins> kubeConfigFlags := genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag() </ins> kubeConfigFlags.AddFlags(flags) matchVersionKubeConfigFlags := cmdutil.NewMatchVersionFlags(kubeConfigFlags) matchVersionKubeConfigFlags.AddFlags(cmds.PersistentFlags())