podClient = f.PodClient() }) <del> ginkgo.Context("when creating a pod in the host PID namespace", func() { makeHostPidPod := func(podName, image string, command []string, hostPID bool) *v1.Pod { return &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: podName, }, Spec: v1.PodSpec{ RestartPolicy: v1.RestartPolicyNever, HostPID:       hostPID, Containers: []v1.Container{ { Image:   image, Name:    podName, Command: command, }, }, }, } } createAndWaitHostPidPod := func(podName string, hostPID bool) { podClient.Create(makeHostPidPod(podName, framework.BusyBoxImage, []string{"sh", "-c", "pidof nginx || true"}, hostPID, )) podClient.WaitForSuccess(podName, framework.PodStartTimeout) } nginxPid := "" ginkgo.BeforeEach(func() { nginxPodName := "nginx-hostpid-" + string(uuid.NewUUID()) podClient.CreateSync(makeHostPidPod(nginxPodName, imageutils.GetE2EImage(imageutils.Nginx), nil, true, )) output := f.ExecShellInContainer(nginxPodName, nginxPodName, "cat /var/run/nginx.pid") nginxPid = strings.TrimSpace(output) }) ginkgo.It("should show its pid in the host PID namespace [LinuxOnly] [NodeFeature:HostAccess]", func() { busyboxPodName := "busybox-hostpid-" + string(uuid.NewUUID()) createAndWaitHostPidPod(busyboxPodName, true) logs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, busyboxPodName, busyboxPodName) if err != nil { framework.Failf("GetPodLogs for pod %q failed: %v", busyboxPodName, err) } pids := strings.TrimSpace(logs) framework.Logf("Got nginx's pid %q from pod %q", pids, busyboxPodName) if pids == "" { framework.Failf("nginx's pid should be seen by hostpid containers") } pidSets := sets.NewString(strings.Split(pids, " ")...) if !pidSets.Has(nginxPid) { framework.Failf("nginx's pid should be seen by hostpid containers") } }) ginkgo.It("should not show its pid in the non-hostpid containers [LinuxOnly] [NodeFeature:HostAccess]", func() { busyboxPodName := "busybox-non-hostpid-" + string(uuid.NewUUID()) createAndWaitHostPidPod(busyboxPodName, false) logs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, busyboxPodName, busyboxPodName) if err != nil { framework.Failf("GetPodLogs for pod %q failed: %v", busyboxPodName, err) } pids := strings.TrimSpace(logs) framework.Logf("Got nginx's pid %q from pod %q", pids, busyboxPodName) pidSets := sets.NewString(strings.Split(pids, " ")...) if pidSets.Has(nginxPid) { framework.Failf("nginx's pid should not be seen by non-hostpid containers") } }) }) </del> ginkgo.Context("When creating a container with runAsUser", func() { makeUserPod := func(podName, image string, command []string, userid int64) *v1.Pod { return &v1.Pod{


return err } <ins> // ignoreStatusForbiddenFromError returns nil if the status code is StatusForbidden. // This happens when AuthorizationFailed is reported from Azure API. func ignoreStatusForbiddenFromError(err error) error { if err == nil { return nil } v, ok := err.(autorest.DetailedError) if ok && v.StatusCode == http.StatusForbidden { return nil } return err } </ins> /// getVirtualMachine calls 'VirtualMachinesClient.Get' with a timed cache /// The service side has throttling control that delays responses if there're multiple requests onto certain vm /// resource request in short period.


new.Spec.RequiresRepublish = &requiresRepublish }, }, <ins> { name: "StorageCapacity changed", modify: func(new *storage.CSIDriver) { new.Spec.StorageCapacity = &notStorageCapacity }, }, </ins> } for _, test := range successCases { t.Run(test.name, func(t *testing.T) {


if in.XEmbeddedResource { out.VendorExtensible.AddExtension("x-kubernetes-embedded-resource", true) } <del> if in.XIntOrString { out.VendorExtensible.AddExtension("x-kubernetes-int-or-string", true) } </del> return nil }


started = !exists } podStatus.ContainerStatuses[i].Started = &started <ins> if started { var ready bool if c.State.Running == nil { ready = false } else if result, ok := m.readinessManager.Get(kubecontainer.ParseContainerID(c.ContainerID)); ok { ready = result == results.Success } else { // The check whether there is a probe which hasn't run yet. _, exists := m.getWorker(podUID, c.Name, readiness) ready = !exists } podStatus.ContainerStatuses[i].Ready = ready } </ins> } // init containers are ready if they have exited with success or if a readiness probe has // succeeded.


%.png: %.seqdiag $(FONT) seqdiag --no-transparency -a -f '$(FONT)' $< <ins> # Build the stuff via a docker image .PHONY: docker docker: docker build -t clustering-seqdiag . docker run --rm clustering-seqdiag | tar xvf - docker-clean: docker rmi clustering-seqdiag || true docker images -q --filter "dangling=true" | xargs docker rmi fix-clock-skew: boot2docker ssh sudo date -u -D "%Y%m%d%H%M.%S" --set "$(shell date -u +%Y%m%d%H%M.%S)" </ins>


"log" "os" "os/exec" <ins> "os/signal" </ins> "path/filepath" "strings" "time"


}) It("should have all expected certs on the master", func() { <del> if testContext.Provider != "gce" && testContext.Provider != "gke" { </del> <ins> if !providerIs("gce", "gke") { </ins> By(fmt.Sprintf("Skipping MasterCerts test for cloud provider %s (only supported for gce and gke)", testContext.Provider)) return }


if ds.Status.DesiredNumberScheduled == desiredNumberScheduled && ds.Status.CurrentNumberScheduled == currentNumberScheduled && ds.Status.NumberMisscheduled == numberMisscheduled { return nil } var updateErr, getErr error for i := 0; i <= StatusUpdateRetries; i++ { ds.Status.DesiredNumberScheduled = desiredNumberScheduled


ObjectMeta: metav1.ObjectMeta{ Name: string(kl.nodeName), Labels: map[string]string{ <del> metav1.LabelHostname:       kl.hostname, metav1.LabelOS:             goruntime.GOOS, metav1.LabelArch:           goruntime.GOARCH, metav1.LabelFluentdDsReady: "true", </del> <ins> metav1.LabelHostname: kl.hostname, metav1.LabelOS:       goruntime.GOOS, metav1.LabelArch:     goruntime.GOARCH, </ins> }, }, Spec: v1.NodeSpec{


expectedPatchDataPattern: `{"status":{"$setElementOrder/conditions":[{"type":"currentType"}],"conditions":[{"lastProbeTime":"2020-05-13T01:01:01Z","message":"newMessage","reason":"newReason","type":"currentType"}]}}`, }, { <del> name: "Should make patch request if pod condition already exists and is identical but nominated node name is different", </del> <ins> name: "Should not make patch request if pod condition already exists and is identical and nominated node name is not set", </ins> currentPodConditions: []v1.PodCondition{ { Type:               "currentType",


MUST match to expected used and total allowed resource quota count within namespace. release: v1.16 file: test/e2e/apimachinery/resource_quota.go <ins> - testname: ResourceQuota, manage lifecycle of a ResourceQuota codename: '[sig-api-machinery] ResourceQuota should manage the lifecycle of a ResourceQuota [Conformance]' description: Attempt to create a ResourceQuota for CPU and Memory quota limits. Creation MUST be successful. Attempt to list all namespaces with a label selector which MUST succeed. One list MUST be found. The ResourceQuota when patched MUST succeed. Given the patching of the ResourceQuota, the fields MUST equal the new values. It MUST succeed at deleting a collection of ResourceQuota via a label selector. release: v1.25 file: test/e2e/apimachinery/resource_quota.go </ins> - testname: ResourceQuota, quota scope, BestEffort and NotBestEffort scope codename: '[sig-api-machinery] ResourceQuota should verify ResourceQuota with best effort scope. [Conformance]'


expectedErr:     true, }, { <del> desc:        "correct LUN and no error shall be returned if everything is good", vmList:      map[string]string{"vm1": "PowerState/Running"}, nodeName:    "vm1", existedDisk: compute.Disk{Name: to.StringPtr("disk-name"), DiskProperties: &compute.DiskProperties{Encryption: &compute.Encryption{DiskEncryptionSetID: &diskEncryptionSetID, Type: compute.EncryptionAtRestWithCustomerKey}}, Tags: testTags}, </del> <ins> desc:     "correct LUN and no error shall be returned if everything is good", vmList:   map[string]string{"vm1": "PowerState/Running"}, nodeName: "vm1", existedDisk: compute.Disk{Name: to.StringPtr("disk-name"), DiskProperties: &compute.DiskProperties{ Encryption: &compute.Encryption{DiskEncryptionSetID: &diskEncryptionSetID, Type: compute.EncryptionAtRestWithCustomerKey}, DiskSizeGB: to.Int32Ptr(4096), }, Tags: testTags}, </ins> expectedLun: 1, expectedErr: false, },


sanitizedSpecVolID := kstrings.EscapeQualifiedNameForDisk(specVolID) return path.Join(host.GetVolumeDevicePluginDir(csiPluginName), sanitizedSpecVolID, "data") } <ins> // hasReadWriteOnce returns true if modes contains v1.ReadWriteOnce func hasReadWriteOnce(modes []api.PersistentVolumeAccessMode) bool { if modes == nil { return false } for _, mode := range modes { if mode == api.ReadWriteOnce { return true } } return false } </ins>


new_storage_version=${test_data[5]} kube::log::status "Verifying ${resource}/${namespace}/${name} has updated storage version ${new_storage_version} in etcd" <del> curl -s http://${ETCD_HOST}:${ETCD_PORT}/v2/keys/registry/${resource}/${namespace}/${name} | grep ${new_storage_version} </del> <ins> curl -s http://${ETCD_HOST}:${ETCD_PORT}/v2/keys/${ETCD_PREFIX}/${resource}/${namespace}/${name} | grep ${new_storage_version} </ins> done killApiServer


dockertypes "github.com/docker/engine-api/types" ) <ins> // These two functions are OS specific (for now at least) func updateHostConfig(config *dockercontainer.HostConfig) { } func DefaultMemorySwap() int64 { return -1 } </ins> func getContainerIP(container *dockertypes.ContainerJSON) string { return "" }


} base := host hostURL, err := url.Parse(base) <del> if err != nil { return nil, "", err } if hostURL.Scheme == "" || hostURL.Host == "" { </del> <ins> if err != nil || hostURL.Scheme == "" || hostURL.Host == "" { </ins> scheme := "http://" if defaultTLS { scheme = "https://"


package main import ( <ins> goflag "flag" </ins> "fmt" "math/rand" "os" "time" <ins> "github.com/spf13/pflag" </ins> utilflag "k8s.io/apiserver/pkg/util/flag" "k8s.io/apiserver/pkg/util/logs" "k8s.io/kubernetes/cmd/kube-proxy/app"


"context" "errors" "fmt" <ins> "net" "sync" </ins> "time" <del> v1 "k8s.io/api/core/v1" resourceapi "k8s.io/api/resource/v1alpha3" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" </del> <ins> "google.golang.org/grpc" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials/insecure" </ins> utilversion "k8s.io/apimachinery/pkg/util/version" <del> "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" </del> "k8s.io/klog/v2" <del> "k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache" </del> <ins> drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha4" </ins> ) <del> // defaultClientCallTimeout is the default amount of time that a DRA driver has // to respond to any of the gRPC calls. kubelet uses this value by passing nil // to RegisterPlugin. Some tests use a different, usually shorter timeout to // speed up testing. // // This is half of the kubelet retry period (according to // https://github.com/kubernetes/kubernetes/commit/0449cef8fd5217d394c5cd331d852bd50983e6b3). const defaultClientCallTimeout = 45 * time.Second // RegistrationHandler is the handler which is fed to the pluginwatcher API. type RegistrationHandler struct { // backgroundCtx is used for all future activities of the handler. // This is necessary because it implements APIs which don't // provide a context. backgroundCtx context.Context kubeClient    kubernetes.Interface getNode       func() (*v1.Node, error) } </del> <ins> // NewDRAPluginClient returns a wrapper around those gRPC methods of a DRA // driver kubelet plugin which need to be called by kubelet. The wrapper // handles gRPC connection management and logging. Connections are reused // across different NewDRAPluginClient calls. func NewDRAPluginClient(pluginName string) (*Plugin, error) { if pluginName == "" { return nil, fmt.Errorf("plugin name is empty") } </ins> <del> var _ cache.PluginHandler = &RegistrationHandler{} // NewPluginHandler returns new registration handler. // // Must only be called once per process because it manages global state. // If a kubeClient is provided, then it synchronizes ResourceSlices // with the resource information provided by plugins. func NewRegistrationHandler(kubeClient kubernetes.Interface, getNode func() (*v1.Node, error)) *RegistrationHandler { handler := &RegistrationHandler{ // The context and thus logger should come from the caller. backgroundCtx: klog.NewContext(context.TODO(), klog.LoggerWithName(klog.TODO(), "DRA registration handler")), kubeClient:    kubeClient, getNode:       getNode, </del> <ins> existingPlugin := draPlugins.get(pluginName) if existingPlugin == nil { return nil, fmt.Errorf("plugin name %s not found in the list of registered DRA plugins", pluginName) </ins> } <del> // When kubelet starts up, no DRA driver has registered yet. None of // the drivers are usable until they come back, which might not happen // at all. Therefore it is better to not advertise any local resources // because pods could get stuck on the node waiting for the driver // to start up. // // This has to run in the background. go handler.wipeResourceSlices("") </del> <ins> return existingPlugin, nil } type Plugin struct { backgroundCtx context.Context cancel        func(cause error) </ins> <del> return handler </del> <ins> mutex                   sync.Mutex conn                    *grpc.ClientConn endpoint                string highestSupportedVersion *utilversion.Version clientCallTimeout       time.Duration </ins> } <del> // wipeResourceSlices deletes ResourceSlices of the node, optionally just for a specific driver. func (h *RegistrationHandler) wipeResourceSlices(driver string) { if h.kubeClient == nil { return } ctx := h.backgroundCtx logger := klog.FromContext(ctx) </del> <ins> func (p *Plugin) getOrCreateGRPCConn() (*grpc.ClientConn, error) { p.mutex.Lock() defer p.mutex.Unlock() </ins> <del> backoff := wait.Backoff{ Duration: time.Second, Factor:   2, Jitter:   0.2, Cap:      5 * time.Minute, Steps:    100, </del> <ins> if p.conn != nil { return p.conn, nil </ins> } <del> // Error logging is done inside the loop. Context cancellation doesn't get logged. _ = wait.ExponentialBackoffWithContext(ctx, backoff, func(ctx context.Context) (bool, error) { node, err := h.getNode() if apierrors.IsNotFound(err) { return false, nil } if err != nil { logger.Error(err, "Unexpected error checking for node") return false, nil } fieldSelector := fields.Set{resourceapi.ResourceSliceSelectorNodeName: node.Name} if driver != "" { fieldSelector[resourceapi.ResourceSliceSelectorDriver] = driver } err = h.kubeClient.ResourceV1alpha3().ResourceSlices().DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{FieldSelector: fieldSelector.String()}) switch { case err == nil: logger.V(3).Info("Deleted ResourceSlices", "fieldSelector", fieldSelector) return true, nil case apierrors.IsUnauthorized(err): // This can happen while kubelet is still figuring out // its credentials. logger.V(5).Info("Deleting ResourceSlice failed, retrying", "fieldSelector", fieldSelector, "err", err) return false, nil default: // Log and retry for other errors. logger.V(3).Info("Deleting ResourceSlice failed, retrying", "fieldSelector", fieldSelector, "err", err) return false, nil } }) } // RegisterPlugin is called when a plugin can be registered. func (h *RegistrationHandler) RegisterPlugin(pluginName string, endpoint string, versions []string, pluginClientTimeout *time.Duration) error { // Prepare a context with its own logger for the plugin. // // The lifecycle of the plugin's background activities is tied to our // root context, so canceling that will also cancel the plugin. // // The logger injects the plugin name as additional value // into all log output related to the plugin. ctx := h.backgroundCtx </del> <ins> ctx := p.backgroundCtx </ins> logger := klog.FromContext(ctx) <del> logger = klog.LoggerWithValues(logger, "pluginName", pluginName) ctx = klog.NewContext(ctx, logger) logger.V(3).Info("Register new DRA plugin", "endpoint", endpoint) highestSupportedVersion, err := h.validateVersions(pluginName, versions) </del> <ins> network := "unix" logger.V(4).Info("Creating new gRPC connection", "protocol", network, "endpoint", p.endpoint) // grpc.Dial is deprecated. grpc.NewClient should be used instead. // For now this gets ignored because this function is meant to establish // the connection, with the one second timeout below. Perhaps that // approach should be reconsidered? //nolint:staticcheck conn, err := grpc.Dial( p.endpoint, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(func(ctx context.Context, target string) (net.Conn, error) { return (&net.Dialer{}).DialContext(ctx, network, target) }), ) </ins> if err != nil { <del> return fmt.Errorf("version check of plugin %s failed: %w", pluginName, err) } var timeout time.Duration if pluginClientTimeout == nil { timeout = defaultClientCallTimeout } else { timeout = *pluginClientTimeout </del> <ins> return nil, err </ins> } <del> ctx, cancel := context.WithCancelCause(ctx) </del> <ins> ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() </ins> <del> pluginInstance := &Plugin{ backgroundCtx:           ctx, cancel:                  cancel, conn:                    nil, endpoint:                endpoint, highestSupportedVersion: highestSupportedVersion, clientCallTimeout:       timeout, </del> <ins> if ok := conn.WaitForStateChange(ctx, connectivity.Connecting); !ok { return nil, errors.New("timed out waiting for gRPC connection to be ready") </ins> } <del> // Storing endpoint of newly registered DRA Plugin into the map, where plugin name will be the key // all other DRA components will be able to get the actual socket of DRA plugins by its name. if draPlugins.add(pluginName, pluginInstance) { logger.V(1).Info("Already registered, previous plugin was replaced") } return nil </del> <ins> p.conn = conn return p.conn, nil </ins> } <del> func (h *RegistrationHandler) validateVersions( pluginName string, versions []string, ) (*utilversion.Version, error) { if len(versions) == 0 { return nil, errors.New("empty list for supported versions") } </del> <ins> func (p *Plugin) NodePrepareResources( ctx context.Context, req *drapb.NodePrepareResourcesRequest, opts ...grpc.CallOption, ) (*drapb.NodePrepareResourcesResponse, error) { logger := klog.FromContext(ctx) logger.V(4).Info("Calling NodePrepareResources rpc", "request", req) </ins> <del> // Validate version newPluginHighestVersion, err := utilversion.HighestSupportedVersion(versions) </del> <ins> conn, err := p.getOrCreateGRPCConn() </ins> if err != nil { <del> // HighestSupportedVersion includes the list of versions in its error // if relevant, no need to repeat it here. return nil, fmt.Errorf("none of the versions are supported: %w", err) } existingPlugin := draPlugins.get(pluginName) if existingPlugin == nil { return newPluginHighestVersion, nil </del> <ins> return nil, err </ins> } <del> if existingPlugin.highestSupportedVersion.LessThan(newPluginHighestVersion) { return newPluginHighestVersion, nil } return nil, fmt.Errorf("another plugin instance is already registered with a higher supported version: %q < %q", newPluginHighestVersion, existingPlugin.highestSupportedVersion) } // DeRegisterPlugin is called when a plugin has removed its socket, // signaling it is no longer available. func (h *RegistrationHandler) DeRegisterPlugin(pluginName string) { if p := draPlugins.delete(pluginName); p != nil { logger := klog.FromContext(p.backgroundCtx) logger.V(3).Info("Deregister DRA plugin", "endpoint", p.endpoint) // Clean up the ResourceSlices for the deleted Plugin since it // may have died without doing so itself and might never come // back. go h.wipeResourceSlices(pluginName) return } </del> <ins> ctx, cancel := context.WithTimeout(ctx, p.clientCallTimeout) defer cancel() </ins> <del> logger := klog.FromContext(h.backgroundCtx) logger.V(3).Info("Deregister DRA plugin not necessary, was already removed") </del> <ins> nodeClient := drapb.NewNodeClient(conn) response, err := nodeClient.NodePrepareResources(ctx, req) logger.V(4).Info("Done calling NodePrepareResources rpc", "response", response, "err", err) return response, err </ins> } <del> // ValidatePlugin is called by kubelet's plugin watcher upon detection // of a new registration socket opened by DRA plugin. func (h *RegistrationHandler) ValidatePlugin(pluginName string, endpoint string, versions []string) error { _, err := h.validateVersions(pluginName, versions) </del> <ins> func (p *Plugin) NodeUnprepareResources( ctx context.Context, req *drapb.NodeUnprepareResourcesRequest, opts ...grpc.CallOption, ) (*drapb.NodeUnprepareResourcesResponse, error) { logger := klog.FromContext(ctx) logger.V(4).Info("Calling NodeUnprepareResource rpc", "request", req) conn, err := p.getOrCreateGRPCConn() </ins> if err != nil { <del> return fmt.Errorf("invalid versions of plugin %s: %w", pluginName, err) </del> <ins> return nil, err </ins> } <del> return err </del> <ins> ctx, cancel := context.WithTimeout(ctx, p.clientCallTimeout) defer cancel() nodeClient := drapb.NewNodeClient(conn) response, err := nodeClient.NodeUnprepareResources(ctx, req) logger.V(4).Info("Done calling NodeUnprepareResources rpc", "response", response, "err", err) return response, err </ins> }


}) It("should write files of various sizes, verify size, validate content", func() { <del> fileSizes := []int64{1 * framework.MiB, 100 * framework.MiB, 1 * framework.GiB} </del> <ins> fileSizes := []int64{fileSizeSmall, fileSizeMedium, fileSizeLarge} </ins> err := testVolumeIO(f, cs, config, volSource, &podSec, testFile, fileSizes) Expect(err).NotTo(HaveOccurred()) })


import ( "fmt" <ins> "os" </ins> "strings" "syscall" "unsafe"


t.Fatal(err) } j = convertNullTypeToNullable(j) <ins> j = stripIntOrStringType(j) </ins> openAPIJSON, err = json.Marshal(j) if err != nil { t.Fatal(err)


foo := newDeployment("foo", 1, nil, nil, nil, map[string]string{"foo": "bar"}) foo.Spec.Strategy.Type = extensions.RecreateDeploymentStrategyType <del> rs := newReplicaSet(foo, "foo-1", 1) pod := generatePodFromRS(rs) </del> <ins> rs1 := newReplicaSet(foo, "foo-1", 1) rs2 := newReplicaSet(foo, "foo-1", 1) pod1 := generatePodFromRS(rs1) pod2 := generatePodFromRS(rs2) </ins> f.dLister = append(f.dLister, foo) <del> f.rsLister = append(f.rsLister, rs) </del> <ins> // Let's pretend this is a different pod. The gist is that the pod lister needs to // return a non-empty list. f.podLister = append(f.podLister, pod1, pod2) c, _ := f.newController() enqueued := false c.enqueueDeployment = func(d *extensions.Deployment) { if d.Name == "foo" { enqueued = true } } c.deletePod(pod1) if enqueued { t.Errorf("expected deployment %q not to be queued after pod deletion", foo.Name) } } // TestPodDeletionPartialReplicaSetOwnershipEnqueueRecreateDeployment ensures that // the deletion of a pod will requeue a Recreate deployment iff there is no other // pod returned from the client in the case where a deployment has multiple replica // sets, some of which have empty owner references. func TestPodDeletionPartialReplicaSetOwnershipEnqueueRecreateDeployment(t *testing.T) { f := newFixture(t) foo := newDeployment("foo", 1, nil, nil, nil, map[string]string{"foo": "bar"}) foo.Spec.Strategy.Type = extensions.RecreateDeploymentStrategyType rs1 := newReplicaSet(foo, "foo-1", 1) rs2 := newReplicaSet(foo, "foo-2", 2) rs2.OwnerReferences = nil pod := generatePodFromRS(rs1) f.dLister = append(f.dLister, foo) f.rsLister = append(f.rsLister, rs1, rs2) f.objects = append(f.objects, foo, rs1, rs2) c, _ := f.newController() enqueued := false c.enqueueDeployment = func(d *extensions.Deployment) { if d.Name == "foo" { enqueued = true } } c.deletePod(pod) if !enqueued { t.Errorf("expected deployment %q to be queued after pod deletion", foo.Name) } } // TestPodDeletionPartialReplicaSetOwnershipDoesntEnqueueRecreateDeployment that the // deletion of a pod will not requeue a Recreate deployment iff there are other pods // returned from the client in the case where a deployment has multiple replica sets, // some of which have empty owner references. func TestPodDeletionPartialReplicaSetOwnershipDoesntEnqueueRecreateDeployment(t *testing.T) { f := newFixture(t) foo := newDeployment("foo", 1, nil, nil, nil, map[string]string{"foo": "bar"}) foo.Spec.Strategy.Type = extensions.RecreateDeploymentStrategyType rs1 := newReplicaSet(foo, "foo-1", 1) rs2 := newReplicaSet(foo, "foo-2", 2) rs2.OwnerReferences = nil pod := generatePodFromRS(rs1) f.dLister = append(f.dLister, foo) f.rsLister = append(f.rsLister, rs1, rs2) f.objects = append(f.objects, foo, rs1, rs2) </ins> // Let's pretend this is a different pod. The gist is that the pod lister needs to // return a non-empty list. f.podLister = append(f.podLister, pod)


// GetZoneByNodeName gets cloudprovider.Zone by node name. func (ss *scaleSet) GetZoneByNodeName(name string) (cloudprovider.Zone, error) { <del> _, _, vm, err := ss.getVmssVM(name) </del> <ins> managedByAS, err := ss.isNodeManagedByAvailabilitySet(name) </ins> if err != nil { <del> if err == ErrorNotVmssInstance { glog.V(4).Infof("GetZoneByNodeName: node %q is managed by availability set", name) // Retry with standard type because nodes are not managed by vmss. return ss.availabilitySet.GetZoneByNodeName(name) } </del> <ins> glog.Errorf("Failed to check isNodeManagedByAvailabilitySet: %v", err) return cloudprovider.Zone{}, err } if managedByAS { // vm is managed by availability set. return ss.availabilitySet.GetZoneByNodeName(name) } _, _, vm, err := ss.getVmssVM(name) if err != nil { </ins> return cloudprovider.Zone{}, err }


# CNI storage path for Windows nodes export WINDOWS_CNI_STORAGE_PATH="https://storage.googleapis.com/k8s-artifacts-cni/release" # CNI version for Windows nodes <del> export WINDOWS_CNI_VERSION="v0.8.7" </del> <ins> export WINDOWS_CNI_VERSION="v0.9.1" </ins> # Pod manifests directory for Windows nodes on Windows nodes. export WINDOWS_MANIFESTS_DIR="${WINDOWS_K8S_DIR}manifests" # Directory where cert/key files will be stores on Windows nodes.


// The name of this port. All ports in an EndpointSlice must have a unique // name. If the EndpointSlice is dervied from a Kubernetes service, this // corresponds to the Service.ports[].name. <del> // Name must either be an empty string or pass IANA_SVC_NAME validation: // * must be no more than 15 characters long // * may contain only [-a-z0-9] // * must contain at least one letter [a-z] // * it must not start or end with a hyphen, nor contain adjacent hyphens </del> <ins> // Name must either be an empty string or pass DNS_LABEL validation: // * must be no more than 63 characters long. // * must consist of lower case alphanumeric characters or '-'. // * must start and end with an alphanumeric character. </ins> // Default is empty string. Name *string `json:"name,omitempty" protobuf:"bytes,1,name=name"` // The IP protocol for this port.


} glog.V(5).Infof("namespace controller - deleteAllContentForGroupVersionResource - items remaining - namespace: %s, gvr: %v, items: %v", namespace, gvr, len(unstructuredList.Items)) if len(unstructuredList.Items) != 0 && estimate == int64(0) { <ins> // if any item has a finalizer, we treat that as a normal condition, and use a default estimation to allow for GC to complete. for _, item := range unstructuredList.Items { if len(item.GetFinalizers()) > 0 { glog.V(5).Infof("namespace controller - deleteAllContentForGroupVersionResource - items remaining with finalizers - namespace: %s, gvr: %v, finalizers: %v", namespace, gvr, item.GetFinalizers()) return finalizerEstimateSeconds, nil } } // nothing reported a finalizer, so something was unexpected as it should have been deleted. </ins> return estimate, fmt.Errorf("unexpected items still remain in namespace: %s for gvr: %v", namespace, gvr) } return estimate, nil


// the test so we can ensure that we clean up after // ourselves defer podClient.Delete(pod.Name, api.NewDeleteOptions(0)) <del> _, err = podClient.Create(pod) </del> <ins> pod, err = podClient.Create(pod) </ins> if err != nil { Failf("Failed to create pod: %v", err) } By("verifying the pod is in kubernetes") <ins> selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value})) options = api.ListOptions{ LabelSelector:   selector, ResourceVersion: pod.ResourceVersion, } </ins> pods, err = podClient.List(options) if err != nil { Failf("Failed to query for pods: %v", err)


return true }) if err != nil { <ins> if apiErr, ok := err.(awserr.Error); ok && apiErr.Code() == "DelegationSetNotReusable" || apiErr.Code() == "NoSuchDelegationSet" || apiErr.Code() == "InvalidInput" { return []dnsprovider.Zone{}, nil } </ins> return []dnsprovider.Zone{}, err } return zoneList, nil


func exportCustomMetricFromPod(f *framework.Framework, consumerName string, metricValue int) *common.ResourceConsumer { podAnnotations := map[string]string{ "prometheus.io/scrape": "true", <del> "prometheus.io/path":   "/Metrics", </del> <ins> "prometheus.io/path":   "/metrics", </ins> "prometheus.io/port":   "8080", } return common.NewMetricExporter(consumerName, f.Namespace.Name, podAnnotations, nil, metricValue, f.ClientSet, f.InternalClientset, f.ScalesGetter)


package route53 import ( <ins> "github.com/aws/aws-sdk-go/aws/awserr" </ins> "github.com/aws/aws-sdk-go/service/route53" "k8s.io/apimachinery/pkg/util/uuid"


return info.HealthCheckNodePort } <ins> // GetNodePort is part of the ServicePort interface. func (info *BaseServiceInfo) GetNodePort() int { return info.NodePort } </ins> func (sct *ServiceChangeTracker) newBaseServiceInfo(port *v1.ServicePort, service *v1.Service) *BaseServiceInfo { onlyNodeLocalEndpoints := false if apiservice.RequestsOnlyLocalTraffic(service) {


kube::golang::setup_env <del> make -C "${KUBE_ROOT}" WHAT=cmd/genswaggertypedocs # Find binary genswaggertypedocs=$(kube::util::find-binary "genswaggertypedocs") if [[ ! -x "$genswaggertypedocs" ]]; then { echo "It looks as if you don't have a compiled genswaggertypedocs binary" echo echo "If you are running from a clone of the git repo, please run" echo "'make WHAT=cmd/genswaggertypedocs'." } >&2 exit 1 fi </del> _tmpdir="$(kube::realpath "$(mktemp -d -t swagger-docs.XXXXXX)")" function swagger_cleanup { rm -rf "${_tmpdir}"


if err != nil { framework.Failf("Error getting node hostnames: %v", err) } <ins> ginkgo.By(fmt.Sprintf("Found %d SSH'able hosts", len(hosts))) </ins> testCases := []struct { cmd            string


} } <ins> func TestCacherNoLeakWithMultipleWatchers(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.WatchBookmark, true)() backingStorage := &dummyStorage{} cacher, _, err := newTestCacher(backingStorage, 1000) if err != nil { t.Fatalf("Couldn't create cacher: %v", err) } defer cacher.Stop() // Wait until cacher is initialized. cacher.ready.wait() pred := storage.Everything pred.AllowWatchBookmarks = true // run the collision test for 3 seconds to let ~2 buckets expire stopCh := make(chan struct{}) time.AfterFunc(3*time.Second, func() { close(stopCh) }) wg := &sync.WaitGroup{} wg.Add(1) go func() { defer wg.Done() for { select { case <-stopCh: return default: ctx, _ := context.WithTimeout(context.Background(), 3*time.Second) w, err := cacher.Watch(ctx, "pods/ns", "0", pred) if err != nil { t.Fatalf("Failed to create watch: %v", err) } w.Stop() } } }() wg.Add(1) go func() { defer wg.Done() for { select { case <-stopCh: return default: cacher.bookmarkWatchers.popExpiredWatchers() } } }() // wait for adding/removing watchers to end wg.Wait() // wait out the expiration period and pop expired watchers time.Sleep(2 * time.Second) cacher.bookmarkWatchers.popExpiredWatchers() cacher.bookmarkWatchers.lock.Lock() defer cacher.bookmarkWatchers.lock.Unlock() if len(cacher.bookmarkWatchers.watchersBuckets) != 0 { t.Errorf("unexpected bookmark watchers %v", len(cacher.bookmarkWatchers.watchersBuckets)) } } </ins> func testCacherSendBookmarkEvents(t *testing.T, watchCacheEnabled, allowWatchBookmarks, expectedBookmarks bool) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.WatchBookmark, watchCacheEnabled)() backingStorage := &dummyStorage{}


}) 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>


} } <ins> // Check if the inspected image matches what we are looking for func matchImageTagOrSHA(inspected dockertypes.ImageInspect, image string) bool { // The image string follows the grammar specified here // https://github.com/docker/distribution/blob/master/reference/reference.go#L4 named, err := dockerref.ParseNamed(image) if err != nil { glog.V(4).Infof("couldn't parse image reference %q: %v", image, err) return false } _, isTagged := named.(dockerref.Tagged) digest, isDigested := named.(dockerref.Digested) if !isTagged && !isDigested { // No Tag or SHA specified, so just return what we have return true } if isTagged { // Check the RepoTags for an exact match for _, tag := range inspected.RepoTags { if tag == image { // We found a specific tag that we were looking for return true } } } if isDigested { algo := digest.Digest().Algorithm().String() sha := digest.Digest().Hex() // Look specifically for short and long sha(s) if strings.Contains(inspected.ID, algo+":"+sha) { // We found the short or long SHA requested return true } } glog.V(4).Infof("Inspected image (%q) does not match %s", inspected.ID, image) return false } </ins> // applyDefaultImageTag parses a docker image string, if it doesn't contain any tag or digest, // a default tag will be applied. func applyDefaultImageTag(image string) (string, error) {


resources []string namespace string <del> name      string </del> <ins> names     []string </ins> defaultNamespace bool requireNamespace bool


if err := deployClient.Delete(deployment.ObjectMeta.Name, deleteOptions); err != nil { framework.Failf("failed to delete the deployment: %v", err) } <del> ginkgo.By("wait for 30 seconds to see if the garbage collector mistakenly deletes the rs") time.Sleep(30 * time.Second) </del> <ins> ginkgo.By("wait for deployment deletion to see if the garbage collector mistakenly deletes the rs") err = wait.PollImmediate(500*time.Millisecond, 1*time.Minute, func() (bool, error) { dList, err := deployClient.List(metav1.ListOptions{}) if err != nil { return false, fmt.Errorf("failed to list deployments: %v", err) } return len(dList.Items) == 0, nil }) if err != nil { framework.Failf("Failed to wait for the Deployment to be deleted: %v", err) } // Once the deployment object is gone, we'll know the GC has finished performing any relevant actions. </ins> objects := map[string]int{"Deployments": 0, "ReplicaSets": 1, "Pods": 2} ok, err := verifyRemainingObjects(f, objects) if err != nil {


} mockCadvisor.On("VersionInfo").Return(versionInfo, nil) expectedNode := &api.Node{ <del> ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}, </del> <ins> ObjectMeta: api.ObjectMeta{Name: testKubeletHostname}, </ins> Spec:       api.NodeSpec{}, Status: api.NodeStatus{ Conditions: []api.NodeCondition{


. "github.com/onsi/gomega" ) <ins> func runLivenessTest(c *client.Client, podDescr *api.Pod) { defer GinkgoRecover() ns := "e2e-test-" + string(util.NewUUID()) By(fmt.Sprintf("Creating pod %s in namespace %s", podDescr.Name, ns)) _, err := c.Pods(ns).Create(podDescr) Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("creating pod %s", podDescr.Name)) // At the end of the test, clean up by removing the pod. defer func() { By("deleting the pod") c.Pods(ns).Delete(podDescr.Name) }() // Wait until the pod is not pending. (Here we need to check for something other than // 'Pending' other than checking for 'Running', since when failures occur, we go to // 'Terminated' which can cause indefinite blocking.) By("waiting for the pod to be something other than pending") err = waitForPodNotPending(c, ns, podDescr.Name, 60*time.Second) Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("starting pod %s in namespace %s", podDescr.Name, ns)) By(fmt.Sprintf("Started pod %s in namespace %s", podDescr.Name, ns)) // Check the pod's current state and verify that restartCount is present. By("checking the pod's current state and verifying that restartCount is present") pod, err := c.Pods(ns).Get(podDescr.Name) Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("getting pod %s in namespace %s", podDescr.Name, ns)) initialRestartCount := pod.Status.Info["liveness"].RestartCount By(fmt.Sprintf("Initial restart count of pod %s is %d", podDescr.Name, initialRestartCount)) // Wait for at most 48 * 5 = 240s = 4 minutes until restartCount is incremented pass := false for i := 0; i < 48; i++ { // Wait until restartCount is incremented. time.Sleep(5 * time.Second) pod, err = c.Pods(ns).Get(podDescr.Name) Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("getting pod %s", podDescr.Name)) restartCount := pod.Status.Info["liveness"].RestartCount By(fmt.Sprintf("Restart count of pod %s in namespace %s is now %d", podDescr.Name, ns, restartCount)) if restartCount > initialRestartCount { By(fmt.Sprintf("Restart count of pod %s in namespace %s increased from %d to %d during the test", podDescr.Name, ns, initialRestartCount, restartCount)) pass = true break } } if !pass { Fail(fmt.Sprintf("Did not see the restart count of pod %s in namespace %s increase from %d during the test", podDescr.Name, ns, initialRestartCount)) } } </ins> var _ = Describe("Pods", func() { <del> var ( c *client.Client ) </del> <ins> var c *client.Client </ins> BeforeEach(func() { var err error


}, expected: &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ <del> Name: "foo-94759gc65b", </del> <ins> Name: "foo-548cm7fgdh", </ins> }, Data: map[string][]byte{ <del> v1.DockerConfigKey: secretData, </del> <ins> v1.DockerConfigJsonKey: secretData, </ins> }, <del> Type: v1.SecretTypeDockercfg, </del> <ins> Type: v1.SecretTypeDockerConfigJson, </ins> }, expectErr: false, },


} } <del> azClientConfig := &azClientConfig{ subscriptionID:                 config.SubscriptionID, resourceManagerEndpoint:        env.ResourceManagerEndpoint, servicePrincipalToken:          servicePrincipalToken, rateLimiterReader:              operationPollRateLimiter, rateLimiterWriter:              operationPollRateLimiterWrite, CloudProviderBackoffRetries:    config.CloudProviderBackoffRetries, CloudProviderBackoffDuration:   config.CloudProviderBackoffDuration, ShouldOmitCloudProviderBackoff: config.shouldOmitCloudProviderBackoff(), } </del> az := Cloud{ Config:                 *config, Environment:            *env,


// InstanceShutdownByProviderID returns true if the instance is in safe state to detach volumes func (vs *VSphere) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error) { <del> return false, cloudprovider.NotImplemented </del> <ins> nodeName, err := vs.GetNodeNameFromProviderID(providerID) if err != nil { glog.Errorf("Error while getting nodename for providerID %s", providerID) return false, err } vsi, err := vs.getVSphereInstance(convertToK8sType(nodeName)) if err != nil { return false, err } // Ensure client is logged in and session is valid if err := vs.nodeManager.vcConnect(ctx, vsi); err != nil { return false, err } vm, err := vs.getVMFromNodeName(ctx, convertToK8sType(nodeName)) if err != nil { glog.Errorf("Failed to get VM object for node: %q. err: +%v", nodeName, err) return false, err } isActive, err := vm.IsActive(ctx) if err != nil { glog.Errorf("Failed to check whether node %q is active. err: %+v.", nodeName, err) return false, err } return !isActive, nil </ins> } // InstanceID returns the cloud provider ID of the node with the specified Name.


if s.ServiceClusterIPRange.IP == nil { glog.Fatal("No --service-cluster-ip-range specified") } <ins> var ones, bits = s.ServiceClusterIPRange.Mask.Size() if bits-ones > 20 { glog.Fatal("Specified --service-cluster-ip-range is too large") } </ins> } func newEtcd(etcdConfigFile string, etcdServerList []string, interfacesFunc meta.VersionInterfacesFunc, defaultVersion, storageVersion, pathPrefix string) (etcdStorage storage.Interface, err error) {


} <ins> func WaitForRootPaths(t *testing.T, ctx context.Context, client testClient, requirePaths, forbidPaths sets.Set[string]) error { return wait.PollUntilContextTimeout(ctx, 250*time.Millisecond, maxTimeout, true, func(ctx context.Context) (done bool, err error) { statusContent, err := client.Discovery().RESTClient().Get().AbsPath("/").SetHeader("Accept", "application/json").DoRaw(ctx) if err != nil { return false, err } rootPaths := metav1.RootPaths{} if err := json.Unmarshal(statusContent, &rootPaths); err != nil { return false, err } paths := sets.New(rootPaths.Paths...) if missing := requirePaths.Difference(paths); len(missing) > 0 { t.Logf("missing required root paths %v", sets.List(missing)) return false, nil } if present := forbidPaths.Intersection(paths); len(present) > 0 { t.Logf("present forbidden root paths %v", sets.List(present)) return false, nil } return true, nil }) } </ins> func WaitForGroups(ctx context.Context, client testClient, groups ...apidiscoveryv2beta1.APIGroupDiscovery) error { return WaitForResultWithCondition(ctx, client, func(groupList apidiscoveryv2beta1.APIGroupDiscoveryList) bool { for _, searchGroup := range groups {


fakeDocker.VersionInfo = []string{} kubeClient.ReactFn = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{ <del> {ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}}, </del> <ins> {ObjectMeta: api.ObjectMeta{Name: testKubeletHostname}}, </ins> }}).ReactFn mockCadvisor := testKubelet.fakeCadvisor machineInfo := &cadvisorApi.MachineInfo{


// a map[family]ip for the caller to release when everything else has // executed successfully func (rs *REST) handleClusterIPsForUpdatedService(oldService *api.Service, service *api.Service) (allocated map[api.IPFamily]string, toRelease map[api.IPFamily]string, err error) { <ins> // We don't want to upgrade (add an IP) or downgrade (remove an IP) // following a cluster downgrade/upgrade to/from dual-stackness // a PreferDualStack service following principle of least surprise // That means: PreferDualStack service will only be upgraded // if: // - changes type to RequireDualStack // - manually adding or removing ClusterIP (secondary) // - manually adding or removing IPFamily (secondary) if isMatchingPreferDualStackClusterIPFields(oldService, service) { return allocated, toRelease, nil // nothing more to do. } </ins> // use cases: // A: service changing types from ExternalName TO ClusterIP types ==> allocate all new // B: service changing types from ClusterIP types TO ExternalName ==> release all allocated


//	    - ... zero or more // // * every specified field or array in s is also specified outside of value validation. <ins> // * metadata at the root can only restrict the name and generateName, and not be specified at all in nested contexts. </ins> // * additionalProperties at the root is not allowed. func ValidateStructural(s *Structural, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{}


kr.CustomMustRegister(cs...) } <ins> // BuildVersion is a helper function that can be easily mocked. var BuildVersion = version.Get </ins> func newKubeRegistry(v apimachineryversion.Info) *kubeRegistry { r := &kubeRegistry{ PromRegistry:     prometheus.NewRegistry(),


// Store in cache c.lock.Lock() <ins> defer c.lock.Unlock() </ins> c.cache[key] = data <del> c.lock.Unlock() </del> // Remove in flight entry c.inFlightLock.Lock() <ins> defer c.inFlightLock.Unlock() </ins> delete(c.inFlight, key) <del> c.inFlightLock.Unlock() </del> }() return result }


clientset "k8s.io/client-go/kubernetes" kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants" <ins> "k8s.io/kubernetes/cmd/kubeadm/app/features" </ins> kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util" "k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient" "k8s.io/kubernetes/pkg/api/legacyscheme"


} func (flunderStrategy) NamespaceScoped() bool { <del> return false </del> <ins> return true </ins> } func (flunderStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {


return rs.releaseClusterIPs(toRelease) } <ins> // tests if two preferred dual-stack service have matching ClusterIPFields // assumption: old service is a valid, default service (e.g., loaded from store) func isMatchingPreferDualStackClusterIPFields(oldService, service *api.Service) bool { if oldService == nil { return false } if service.Spec.IPFamilyPolicy == nil { return false } // if type mutated then it is an update // that needs to run through the entire process. if oldService.Spec.Type != service.Spec.Type { return false } // both must be type that gets an IP assigned if service.Spec.Type != api.ServiceTypeClusterIP && service.Spec.Type != api.ServiceTypeNodePort && service.Spec.Type != api.ServiceTypeLoadBalancer { return false } if oldService.Spec.Type != api.ServiceTypeClusterIP && oldService.Spec.Type != api.ServiceTypeNodePort && oldService.Spec.Type != api.ServiceTypeLoadBalancer { return false } // both must be of IPFamilyPolicy==PreferDualStack if service.Spec.IPFamilyPolicy != nil && *(service.Spec.IPFamilyPolicy) != api.IPFamilyPolicyPreferDualStack { return false } if oldService.Spec.IPFamilyPolicy != nil && *(oldService.Spec.IPFamilyPolicy) != api.IPFamilyPolicyPreferDualStack { return false } // compare ClusterIPs lengths. // due to validation. if len(service.Spec.ClusterIPs) != len(oldService.Spec.ClusterIPs) { return false } for i, ip := range service.Spec.ClusterIPs { if oldService.Spec.ClusterIPs[i] != ip { return false } } // compare IPFamilies if len(service.Spec.IPFamilies) != len(oldService.Spec.IPFamilies) { return false } for i, family := range service.Spec.IPFamilies { if oldService.Spec.IPFamilies[i] != family { return false } } // they match on // Policy: preferDualStack // ClusterIPs // IPFamilies return true } </ins> // attempts to default service ip families according to cluster configuration // while ensuring that provided families are configured on cluster. <del> func (rs *REST) tryDefaultValidateServiceClusterIPFields(service *api.Service) error { </del> <ins> func (rs *REST) tryDefaultValidateServiceClusterIPFields(oldService, service *api.Service) error { </ins> // can not do anything here if service.Spec.Type == api.ServiceTypeExternalName { return nil


} } <del> func TestHistogramClear(t *testing.T) { samples := []float64{0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, 1.5, 3, 3, 3, 3, 6, 6, 6, 6} bounds := []float64{1, 2, 4, 8} h := samples2Histogram(samples, bounds) if *h.SampleCount == 0 { t.Errorf("Expected histogram .SampleCount to be non-zero") } if *h.SampleSum == 0 { t.Errorf("Expected histogram .SampleSum to be non-zero") } for _, b := range h.Bucket { if b.CumulativeCount != nil { if *b.CumulativeCount == 0 { t.Errorf("Expected histogram bucket to have non-zero comulative count") } } } h.Clear() if *h.SampleCount != 0 { t.Errorf("Expected histogram .SampleCount to be zero, have %v instead", *h.SampleCount) } if *h.SampleSum != 0 { t.Errorf("Expected histogram .SampleSum to be zero, have %v instead", *h.SampleSum) } for _, b := range h.Bucket { if b.CumulativeCount != nil { if *b.CumulativeCount != 0 { t.Errorf("Expected histogram bucket to have zero comulative count, have %v instead", *b.CumulativeCount) } } if b.UpperBound != nil { *b.UpperBound = 0 } } } </del> func TestHistogramValidate(t *testing.T) { tests := []struct { name string


"net/http" "path" "path/filepath" <ins> "runtime" </ins> "sync" "time"


# Cluster Role # ################ <ins> kubectl "${kube_flags[@]}" api-resources </ins> if kube::test::if_supports_resource "${clusterroles}" ; then record_command run_clusterroles_tests fi


{Type: v1.NodeMemoryPressure, Status: v1.ConditionFalse}, {Type: v1.NodeDiskPressure, Status: v1.ConditionFalse}, {Type: v1.NodeNetworkUnavailable, Status: v1.ConditionFalse}, <del> {Type: v1.NodeInodePressure, Status: v1.ConditionFalse}, </del> } return node }(),


return dswp, fakePodManager } <ins> func TestFindAndAddNewPods_WithRescontructedVolume(t *testing.T) { // create dswp dswp, fakePodManager := prepareDswpWithVolume(t) // create pod fakeOuterVolumeName := "dswp-test-volume-name" containers := []v1.Container{ { VolumeMounts: []v1.VolumeMount{ { Name:      fakeOuterVolumeName, MountPath: "/mnt", }, }, }, } pod := createPodWithVolume("dswp-test-pod", fakeOuterVolumeName, "file-bound", containers) fakePodManager.AddPod(pod) podName := util.GetUniquePodName(pod) mode := v1.PersistentVolumeFilesystem pv := &v1.PersistentVolume{ ObjectMeta: metav1.ObjectMeta{ Name: fakeOuterVolumeName, }, Spec: v1.PersistentVolumeSpec{ ClaimRef:   &v1.ObjectReference{Namespace: "ns", Name: "file-bound"}, VolumeMode: &mode, }, } generatedVolumeName := "fake-plugin/" + pod.Spec.Volumes[0].Name uniqueVolumeName := v1.UniqueVolumeName(generatedVolumeName) expectedOuterVolumeName := "dswp-test-volume-name" opts := operationexecutor.MarkVolumeOpts{ PodName:             podName, PodUID:              pod.UID, VolumeName:          uniqueVolumeName, OuterVolumeSpecName: generatedVolumeName, // fake reconstructed volume VolumeGidVolume:     "", VolumeSpec:          volume.NewSpecFromPersistentVolume(pv, false), VolumeMountState:    operationexecutor.VolumeMounted, } dswp.actualStateOfWorld.MarkVolumeAsAttached(opts.VolumeName, opts.VolumeSpec, "fake-node", "") dswp.actualStateOfWorld.MarkVolumeAsMounted(opts) dswp.findAndAddNewPods() mountedVolumes := dswp.actualStateOfWorld.GetMountedVolumesForPod(podName) found := false for _, volume := range mountedVolumes { if volume.OuterVolumeSpecName == expectedOuterVolumeName { found = true break } } if !found { t.Fatalf( "Could not found pod volume %v in the list of actual state of world volumes to mount.", expectedOuterVolumeName) } } </ins> func TestFindAndAddNewPods_WithReprocessPodAndVolumeRetrievalError(t *testing.T) { // create dswp dswp, fakePodManager := prepareDswpWithVolume(t)


// +k8s:deepcopy-gen=package <del> package testing </del> <ins> package testing // import "k8s.io/apiserver/pkg/storage/testing" </ins>


<del> kind: ReplicationController apiVersion: v1 </del> <ins> apiVersion: extensions/v1beta1 kind: Deployment </ins> metadata: name: etcd <del> creationTimestamp: </del> spec: strategy: type: Recreate <del> resources: {} triggers: - type: ConfigChange </del> replicas: 3 selector: <del> name: etcd </del> <ins> matchLabels: name: etcd </ins> template: metadata: <del> creationTimestamp: </del> labels: name: etcd spec:


// or the kubeadm preferred one for the desired Kubernetes version var desiredEtcdVersion *version.Version if cfg.Etcd.Local.ImageTag != "" { <del> desiredEtcdVersion, err = version.ParseSemantic(cfg.Etcd.Local.ImageTag) </del> <ins> desiredEtcdVersion, err = version.ParseSemantic( convertImageTagMetadataToSemver(cfg.Etcd.Local.ImageTag)) </ins> if err != nil { return true, errors.Wrapf(err, "failed to parse tag %q as a semantic version", cfg.Etcd.Local.ImageTag) }


// Cannot be updated. // +optional WorkingDir string `json:"workingDir,omitempty" protobuf:"bytes,5,opt,name=workingDir"` <del> // List of ports to expose from the container. Exposing a port here gives // the system additional information about the network connections a // container uses, but is primarily informational. Not specifying a port here </del> <ins> // List of ports to expose from the container. Not specifying a port here </ins> // DOES NOT prevent that port from being exposed. Any port which is // listening on the default "0.0.0.0" address inside a container will be // accessible from the network. <ins> // Modifying this array with strategic merge patch may corrupt the data. // For more information See https://github.com/kubernetes/kubernetes/issues/108255. </ins> // Cannot be updated. // +optional // +patchMergeKey=containerPort


const ( // StatusSuccess represents the successful completion of command. StatusSuccess = "Success" <del> // StatusFailed represents that the command failed. StatusFailure = "Failed" </del> // StatusNotSupported represents that the command is not supported. StatusNotSupported = "Not supported" )


FlagTimeout      = "request-timeout" ) <ins> // RecommendedConfigOverrideFlags is a convenience method to return recommended flag names prefixed with a string of your choosing func RecommendedConfigOverrideFlags(prefix string) ConfigOverrideFlags { return ConfigOverrideFlags{ AuthOverrideFlags:    RecommendedAuthOverrideFlags(prefix), ClusterOverrideFlags: RecommendedClusterOverrideFlags(prefix), ContextOverrideFlags: RecommendedContextOverrideFlags(prefix), CurrentContext: FlagInfo{prefix + FlagContext, "", "", "The name of the kubeconfig context to use"}, Timeout:        FlagInfo{prefix + FlagTimeout, "", "0", "The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests."}, } } </ins> // RecommendedAuthOverrideFlags is a convenience method to return recommended flag names prefixed with a string of your choosing func RecommendedAuthOverrideFlags(prefix string) AuthOverrideFlags { return AuthOverrideFlags{


t.Errorf("Timed out waiting for response.") } } <ins> func TestWarningWithRequestTimeout(t *testing.T) { type result struct { err        interface{} stackTrace string } clientDoneCh, resultCh := make(chan struct{}), make(chan result, 1) testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // this will catch recoverable panic like 'Header called after Handler finished'. // go runtime crashes the program if it detects a program-ending // panic like 'concurrent map iteration and map write', so this // panic can not be caught. defer func() { result := result{} result.err = recover() if result.err != nil { // Same as stdlib http server code. Manually allocate stack // trace buffer size to prevent excessively large logs const size = 64 << 10 buf := make([]byte, size) buf = buf[:goruntime.Stack(buf, false)] result.stackTrace = string(buf) } resultCh <- result }() // add warnings while we're waiting for the request to timeout to catch read/write races loop: for { select { case <-r.Context().Done(): break loop default: warning.AddWarning(r.Context(), "a", "1") } } // the request has just timed out, write to catch read/write races warning.AddWarning(r.Context(), "agent", "text") // give time for the timeout response to be written, then try to // write a response header to catch the "Header after Handler finished" panic <-clientDoneCh warning.AddWarning(r.Context(), "agent", "text") }) handler := newGenericAPIServerHandlerChain(t, "/test", testHandler) server := httptest.NewUnstartedServer(handler) server.EnableHTTP2 = true server.StartTLS() defer server.Close() request, err := http.NewRequest("GET", server.URL+"/test?timeout=100ms", nil) if err != nil { t.Fatalf("unexpected error: %v", err) } client := server.Client() response, err := client.Do(request) close(clientDoneCh) if err != nil { t.Errorf("expected server to return an HTTP response: %v", err) } if want := http.StatusGatewayTimeout; response == nil || response.StatusCode != want { t.Errorf("expected server to return %d, but got: %v", want, response) } var resultGot result select { case resultGot = <-resultCh: case <-time.After(wait.ForeverTestTimeout): t.Errorf("the handler never returned a result") } if resultGot.err != nil { t.Errorf("Expected no panic, but got: %v", resultGot.err) t.Errorf("Stack Trace: %s", resultGot.stackTrace) } } // builds a handler chain with the given user handler as used by GenericAPIServer. func newGenericAPIServerHandlerChain(t *testing.T, path string, handler http.Handler) http.Handler { config, _ := setUp(t) s, err := config.Complete(nil).New("test", NewEmptyDelegate()) if err != nil { t.Fatalf("Error in bringing up the server: %v", err) } s.Handler.NonGoRestfulMux.Handle(path, handler) return s.Handler } </ins>


metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/runtime" <ins> "k8s.io/apimachinery/pkg/util/sets" </ins> "k8s.io/apimachinery/pkg/util/wait" corev1client "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/tools/record"


mkdir -p "${dst_dir}" local salt_dir="${KUBE_ROOT}/cluster/saltbase/salt" <ins> cp "${salt_dir}/cluster-autoscaler/cluster-autoscaler.manifest" "${dst_dir}/" </ins> cp "${salt_dir}/fluentd-es/fluentd-es.yaml" "${release_stage}/" cp "${salt_dir}/fluentd-gcp/fluentd-gcp.yaml" "${release_stage}/" cp "${salt_dir}/kube-registry-proxy/kube-registry-proxy.yaml" "${release_stage}/"


if pod == nil { return framework.NewStatus(framework.Error, "pod cannot be nil") } <del> state.RLock() defer state.RUnlock() </del> if v, e := state.Read(framework.StateKey(pod.Name)); e == nil { if value, ok := v.(*stateData); ok && value.data == "never bind" { return framework.NewStatus(framework.Unschedulable, "pod is not permitted")


} } <ins> func TestValidateFinalizersUpdate(t *testing.T) { testcases := map[string]struct { Old         api.ObjectMeta New         api.ObjectMeta ExpectedErr string }{ "invalid adding finalizers": { Old:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &unversioned.Time{}, Finalizers: []string{"x/a"}}, New:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &unversioned.Time{}, Finalizers: []string{"x/a", "y/b"}}, ExpectedErr: "y/b", }, "invalid changing finalizers": { Old:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &unversioned.Time{}, Finalizers: []string{"x/a"}}, New:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &unversioned.Time{}, Finalizers: []string{"x/b"}}, ExpectedErr: "x/b", }, "valid removing finalizers": { Old:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &unversioned.Time{}, Finalizers: []string{"x/a", "y/b"}}, New:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &unversioned.Time{}, Finalizers: []string{"x/a"}}, ExpectedErr: "", }, "valid adding finalizers for objects not being deleted": { Old:         api.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a"}}, New:         api.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a", "y/b"}}, ExpectedErr: "", }, } for name, tc := range testcases { errs := ValidateObjectMetaUpdate(&tc.New, &tc.Old, field.NewPath("field")) if len(errs) == 0 { if len(tc.ExpectedErr) != 0 { t.Errorf("case: %q, expected error to contain %q", name, tc.ExpectedErr) } } else if e, a := tc.ExpectedErr, errs.ToAggregate().Error(); !strings.Contains(a, e) { t.Errorf("case: %q, expected error to contain %q, got error %q", name, e, a) } } } </ins> func TestValidateObjectMetaUpdatePreventsDeletionFieldMutation(t *testing.T) { now := unversioned.NewTime(time.Unix(1000, 0).UTC()) later := unversioned.NewTime(time.Unix(2000, 0).UTC())


package clouddns import ( <ins> "google.golang.org/api/googleapi" </ins> "k8s.io/kubernetes/federation/pkg/dnsprovider" "k8s.io/kubernetes/federation/pkg/dnsprovider/providers/google/clouddns/internal/interfaces" )


// Package discovery provides ways to discover server-supported // API groups, versions and resources. <del> package discovery </del> <ins> package discovery // import "k8s.io/client-go/discovery" </ins>


serviceHasSynced = func() bool { return true } } <del> nodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{}) </del> <ins> var nodeHasSynced cache.InformerSynced var nodeLister corelisters.NodeLister </ins> if kubeDeps.KubeClient != nil { <del> fieldSelector := fields.Set{api.ObjectNameField: string(nodeName)}.AsSelector() nodeLW := cache.NewListWatchFromClient(kubeDeps.KubeClient.CoreV1().RESTClient(), "nodes", metav1.NamespaceAll, fieldSelector) r := cache.NewReflector(nodeLW, &v1.Node{}, nodeIndexer, 0) go r.Run(wait.NeverStop) </del> <ins> kubeInformers := informers.NewSharedInformerFactoryWithOptions(kubeDeps.KubeClient, 0, informers.WithTweakListOptions(func(options *metav1.ListOptions) { options.FieldSelector = fields.Set{api.ObjectNameField: string(nodeName)}.String() })) nodeLister = kubeInformers.Core().V1().Nodes().Lister() nodeHasSynced = func() bool { if kubeInformers.Core().V1().Nodes().Informer().HasSynced() { klog.Infof("kubelet nodes sync") return true } klog.Infof("kubelet nodes not sync") return false } kubeInformers.Start(wait.NeverStop) klog.Info("Kubelet client is not nil") } else { // we dont have a client to sync! nodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{}) nodeLister = corelisters.NewNodeLister(nodeIndexer) nodeHasSynced = func() bool { return true } klog.Info("Kubelet client is nil") </ins> } <del> nodeLister := corelisters.NewNodeLister(nodeIndexer) </del> // TODO: get the real node object of ourself, // and use the real node name and UID.


b.Do().Visit(func(r *resource.Info) error { services := r.Object.(*api.ServiceList).Items for _, service := range services { <del> link := client.Host + "/api/v1beta3/proxy/namespaces/" + service.ObjectMeta.Namespace + "/services/" + service.ObjectMeta.Name </del> <ins> var link string if len(service.Spec.PublicIPs) > 0 { for _, port := range service.Spec.Ports { link += "http://" + service.Spec.PublicIPs[0] + ":" + strconv.Itoa(port.Port) + " " } } else { link = client.Host + "/api/v1beta3/proxy/namespaces/" + service.ObjectMeta.Namespace + "/services/" + service.ObjectMeta.Name } </ins> printService(out, service.ObjectMeta.Labels["name"], link) } return nil


framework.ExpectNoError(err, "failed to delete Service %v in namespace %v", testService.ObjectMeta.Name, ns) framework.Logf("Service %s deleted", testSvcName) }) <ins> ginkgo.It("should delete a collection of services", func() { ns := f.Namespace.Name svcClient := f.ClientSet.CoreV1().Services(ns) svcResource := schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"} svcDynamicClient := f.DynamicClient.Resource(svcResource).Namespace(ns) svcLabel := map[string]string{"e2e-test-service": "delete"} deleteLabel := labels.SelectorFromSet(svcLabel).String() ginkgo.By("creating a collection of services") testServices := []struct { name  string label map[string]string port  int }{ { name:  "e2e-svc-a-" + utilrand.String(5), label: map[string]string{"e2e-test-service": "delete"}, port:  8001, }, { name:  "e2e-svc-b-" + utilrand.String(5), label: map[string]string{"e2e-test-service": "delete"}, port:  8002, }, { name:  "e2e-svc-c-" + utilrand.String(5), label: map[string]string{"e2e-test-service": "keep"}, port:  8003, }, } for _, testService := range testServices { func() { framework.Logf("Creating %s", testService.name) svc := v1.Service{ ObjectMeta: metav1.ObjectMeta{ Name:   testService.name, Labels: testService.label, }, Spec: v1.ServiceSpec{ Type: "ClusterIP", Ports: []v1.ServicePort{{ Name:       "http", Protocol:   v1.ProtocolTCP, Port:       int32(testService.port), TargetPort: intstr.FromInt(testService.port), }}, }, } _, err := svcClient.Create(context.TODO(), &svc, metav1.CreateOptions{}) framework.ExpectNoError(err, "failed to create Service") }() } svcList, err := cs.CoreV1().Services(ns).List(context.TODO(), metav1.ListOptions{}) framework.ExpectNoError(err, "failed to list Services") framework.ExpectEqual(len(svcList.Items), 3, "Required count of services out of sync") ginkgo.By("deleting service collection") err = svcDynamicClient.DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{LabelSelector: deleteLabel}) framework.ExpectNoError(err, "failed to delete service collection. %v", err) svcList, err = cs.CoreV1().Services(ns).List(context.TODO(), metav1.ListOptions{}) framework.ExpectNoError(err, "failed to list Services") framework.ExpectEqual(len(svcList.Items), 1, "Required count of services out of sync") framework.Logf("Collection of services has been deleted") }) </ins> }) // execAffinityTestForSessionAffinityTimeout is a helper function that wrap the logic of


if pod.Name != mirrorPod.Name || pod.Namespace != mirrorPod.Namespace { return false } <del> return api.Semantic.DeepEqual(&pod.Spec, &mirrorPod.Spec) </del> <ins> hash, ok := getHashFromMirrorPod(mirrorPod) if !ok { return false } return hash == getPodHash(pod) </ins> } func podsMapToPods(UIDMap map[types.UID]*api.Pod) []*api.Pod {


return p, err } <del> // waitForRCPodToDisappear returns nil if the pod from the given replication controller (described by rcName) no longer exists. // In case of failure or too long waiting time, an error is returned. func waitForRCPodToDisappear(c *client.Client, ns, rcName, podName string) error { label := labels.SelectorFromSet(labels.Set(map[string]string{"name": rcName})) return wait.Poll(20*time.Second, 5*time.Minute, func() (bool, error) { </del> <ins> func waitForPodToDisappear(c *client.Client, ns, podName string, label labels.Selector, interval, timeout time.Duration) error { return wait.Poll(interval, timeout, func() (bool, error) { </ins> Logf("Waiting for pod %s to disappear", podName) pods, err := c.Pods(ns).List(label, fields.Everything()) if err != nil {


}, }, }, <del> map[string]interface{}{"field": map[string]interface{}{}}, }, false}, {"!nullable against null", args{ apiextensions.JSONSchemaProps{ Properties: map[string]apiextensions.JSONSchemaProps{ "field": { Type:     "object", Nullable: false, }, }, </del> <ins> objects: []interface{}{ map[string]interface{}{}, map[string]interface{}{"field": map[string]interface{}{}}, </ins> }, <del> map[string]interface{}{"field": nil}, }, true}, {"!nullable against undefined", args{ apiextensions.JSONSchemaProps{ </del> <ins> failingObjects: []interface{}{ map[string]interface{}{"field": "foo"}, map[string]interface{}{"field": 42}, map[string]interface{}{"field": true}, map[string]interface{}{"field": 1.2}, map[string]interface{}{"field": []interface{}{}}, }, }, {name: "nullable", schema: apiextensions.JSONSchemaProps{ </ins> Properties: map[string]apiextensions.JSONSchemaProps{ "field": { Type:     "object", <del> Nullable: false, </del> <ins> Nullable: true, </ins> }, }, }, <del> map[string]interface{}{}, }, false}, {"nullable against non-null", args{ apiextensions.JSONSchemaProps{ </del> <ins> objects: []interface{}{ map[string]interface{}{}, map[string]interface{}{"field": map[string]interface{}{}}, map[string]interface{}{"field": nil}, }, failingObjects: []interface{}{ map[string]interface{}{"field": "foo"}, map[string]interface{}{"field": 42}, map[string]interface{}{"field": true}, map[string]interface{}{"field": 1.2}, map[string]interface{}{"field": []interface{}{}}, }, }, {name: "nullable and no type", schema: apiextensions.JSONSchemaProps{ </ins> Properties: map[string]apiextensions.JSONSchemaProps{ "field": { <del> Type:     "object", </del> Nullable: true, }, }, }, <del> map[string]interface{}{"field": map[string]interface{}{}}, }, false}, {"nullable against null", args{ apiextensions.JSONSchemaProps{ </del> <ins> objects: []interface{}{ map[string]interface{}{}, map[string]interface{}{"field": map[string]interface{}{}}, map[string]interface{}{"field": nil}, map[string]interface{}{"field": "foo"}, map[string]interface{}{"field": 42}, map[string]interface{}{"field": true}, map[string]interface{}{"field": 1.2}, map[string]interface{}{"field": []interface{}{}}, }, }, {name: "x-kubernetes-int-or-string", schema: apiextensions.JSONSchemaProps{ </ins> Properties: map[string]apiextensions.JSONSchemaProps{ "field": { <del> Type:     "object", Nullable: true, </del> <ins> XIntOrString: true, </ins> }, }, }, <del> map[string]interface{}{"field": nil}, }, false}, {"!nullable against undefined", args{ apiextensions.JSONSchemaProps{ </del> <ins> objects: []interface{}{ map[string]interface{}{}, map[string]interface{}{"field": 42}, map[string]interface{}{"field": "foo"}, }, failingObjects: []interface{}{ map[string]interface{}{"field": nil}, map[string]interface{}{"field": true}, map[string]interface{}{"field": 1.2}, map[string]interface{}{"field": map[string]interface{}{}}, map[string]interface{}{"field": []interface{}{}}, }, }, {name: "nullable and x-kubernetes-int-or-string", schema: apiextensions.JSONSchemaProps{ </ins> Properties: map[string]apiextensions.JSONSchemaProps{ "field": { <del> Type:     "object", Nullable: true, </del> <ins> Nullable:     true, XIntOrString: true, </ins> }, }, }, <del> map[string]interface{}{}, }, false}, {"nullable and no type against non-nil", args{ apiextensions.JSONSchemaProps{ </del> <ins> objects: []interface{}{ map[string]interface{}{}, map[string]interface{}{"field": 42}, map[string]interface{}{"field": "foo"}, map[string]interface{}{"field": nil}, }, failingObjects: []interface{}{ map[string]interface{}{"field": true}, map[string]interface{}{"field": 1.2}, map[string]interface{}{"field": map[string]interface{}{}}, map[string]interface{}{"field": []interface{}{}}, }, }, {name: "nullable, x-kubernetes-int-or-string and user-provided anyOf", schema: apiextensions.JSONSchemaProps{ </ins> Properties: map[string]apiextensions.JSONSchemaProps{ "field": { <del> Nullable: true, </del> <ins> Nullable:     true, XIntOrString: true, AnyOf: []apiextensions.JSONSchemaProps{ {Type: "integer"}, {Type: "string"}, }, </ins> }, }, }, <del> map[string]interface{}{"field": 42}, }, false}, {"nullable and no type against nil", args{ apiextensions.JSONSchemaProps{ </del> <ins> objects: []interface{}{ map[string]interface{}{}, map[string]interface{}{"field": nil}, map[string]interface{}{"field": 42}, map[string]interface{}{"field": "foo"}, }, failingObjects: []interface{}{ map[string]interface{}{"field": true}, map[string]interface{}{"field": 1.2}, map[string]interface{}{"field": map[string]interface{}{}}, map[string]interface{}{"field": []interface{}{}}, }, }, {name: "nullable, x-kubernetes-int-or-string and user-provider allOf", schema: apiextensions.JSONSchemaProps{ </ins> Properties: map[string]apiextensions.JSONSchemaProps{ "field": { <del> Nullable: true, </del> <ins> Nullable:     true, XIntOrString: true, AllOf: []apiextensions.JSONSchemaProps{ { AnyOf: []apiextensions.JSONSchemaProps{ {Type: "integer"}, {Type: "string"}, }, }, }, </ins> }, }, }, <del> map[string]interface{}{"field": nil}, }, false}, {"invalid regex", args{ apiextensions.JSONSchemaProps{ </del> <ins> objects: []interface{}{ map[string]interface{}{}, map[string]interface{}{"field": nil}, map[string]interface{}{"field": 42}, map[string]interface{}{"field": "foo"}, }, failingObjects: []interface{}{ map[string]interface{}{"field": true}, map[string]interface{}{"field": 1.2}, map[string]interface{}{"field": map[string]interface{}{}}, map[string]interface{}{"field": []interface{}{}}, }, }, {name: "invalid regex", schema: apiextensions.JSONSchemaProps{ </ins> Properties: map[string]apiextensions.JSONSchemaProps{ "field": { Type:    "string",


}, { message: "{", <del> err:     "error stream protocol error: unexpected end of JSON input in "{"", </del> <ins> err:     "unexpected end of JSON input in "{"", </ins> }, { message: `{"status": "Success" }`,


package mount import ( <ins> "reflect" </ins> "strings" "testing" )


// Leave something on the stack, so that calls to struct tag getters never fail. s.srcStack.push(scopeStackElem{}) s.destStack.push(scopeStackElem{}) <del> return c.convert(sv, dv, s) </del> <ins> return f(sv, dv, s) </ins> } // callCustom calls 'custom' with sv & dv. custom must be a conversion function.


existingFilterChains := proxier.getExistingChains(proxier.filterChainsData, utiliptables.TableFilter) existingNATChains := proxier.getExistingChains(proxier.iptablesData, utiliptables.TableNAT) <ins> // ensure KUBE-MARK-DROP chain exist but do not change any rules for _, ch := range iptablesEnsureChains { if _, err := proxier.iptables.EnsureChain(ch.table, ch.chain); err != nil { klog.Errorf("Failed to ensure that %s chain %s exists: %v", ch.table, ch.chain, err) return } } </ins> // Make sure we keep stats for the top-level chains for _, ch := range iptablesChains { if _, err := proxier.iptables.EnsureChain(ch.table, ch.chain); err != nil {


fi fi <ins> # generate the controller manager token here since its only used on the master. KUBE_CONTROLLER_MANAGER_TOKEN=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null) </ins> # KUBERNETES_CONTAINER_RUNTIME is set by the `kube-env` file, but it's a bit of a mouthful if [[ "${CONTAINER_RUNTIME:-}" == "" ]]; then CONTAINER_RUNTIME="${KUBERNETES_CONTAINER_RUNTIME:-docker}"


apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" <ins> "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" </ins> "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" clientset "k8s.io/client-go/kubernetes" <ins> "k8s.io/client-go/util/retry" </ins> batchinternal "k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/test/e2e/framework" e2ejob "k8s.io/kubernetes/test/e2e/framework/job"


import ( "fmt" "sync" <ins> "time" </ins> "github.com/golang/glog"


metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/wait" <ins> "k8s.io/apiserver/pkg/admission" </ins> "k8s.io/client-go/informers" clientset "k8s.io/client-go/kubernetes" typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" typedv1 "k8s.io/client-go/kubernetes/typed/core/v1" restclient "k8s.io/client-go/rest" "k8s.io/client-go/util/retry" <ins> api "k8s.io/kubernetes/pkg/apis/core" </ins> //svc "k8s.io/kubernetes/pkg/api/v1/service" "k8s.io/kubernetes/pkg/controller/statefulset"


framework.Logf("Service %s deleted", testSvcName) }) <del> ginkgo.It("should delete a collection of services", func() { </del> <ins> /* Release: v1.23 Testname: Service, deletes a collection of services Description: Create three services with the required labels and ports. It MUST locate three services in the test namespace. It MUST succeed at deleting a collection of services via a label selector. It MUST locate only one service after deleting the service collection. */ framework.ConformanceIt("should delete a collection of services", func() { </ins> ns := f.Namespace.Name svcClient := f.ClientSet.CoreV1().Services(ns)


nodePortAddresses []string, ) (proxy.Provider, error) { // Create an ipv4 instance of the single-stack proxier <ins> nodePortAddresses4, nodePortAddresses6 := utilproxy.FilterIncorrectCIDRVersion(nodePortAddresses, false) </ins> ipv4Proxier, err := NewProxier(ipt[0], sysctl, exec, syncPeriod, minSyncPeriod, masqueradeAll, masqueradeBit, localDetectors[0], hostname, <del> nodeIP[0], recorder, healthzServer, nodePortAddresses) </del> <ins> nodeIP[0], recorder, healthzServer, nodePortAddresses4) </ins> if err != nil { return nil, fmt.Errorf("unable to create ipv4 proxier: %v", err) } ipv6Proxier, err := NewProxier(ipt[1], sysctl, exec, syncPeriod, minSyncPeriod, masqueradeAll, masqueradeBit, localDetectors[1], hostname, <del> nodeIP[1], recorder, healthzServer, nodePortAddresses) </del> <ins> nodeIP[1], recorder, healthzServer, nodePortAddresses6) </ins> if err != nil { return nil, fmt.Errorf("unable to create ipv6 proxier: %v", err) }


"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apiserver/pkg/authentication/serviceaccount" clientset "k8s.io/client-go/kubernetes" <ins> imageutils "k8s.io/kubernetes/test/utils/image" </ins> "github.com/onsi/ginkgo"


<ins> /* Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package main import ( "encoding/json" "flag" "fmt" "os" "path" "strconv" "strings" "time" "github.com/coreos/etcd/etcdserver" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/etcdserver/membership" "github.com/coreos/etcd/mvcc/backend" "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/pbutil" "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/raft/raftpb" "github.com/coreos/etcd/snap" "github.com/coreos/etcd/store" "github.com/coreos/etcd/wal" "github.com/coreos/etcd/wal/walpb" "github.com/golang/glog" ) const rollbackVersion = "2.3.7" var ( migrateDatadir = flag.String("data-dir", "", "Path to the data directory") ttl            = flag.Duration("ttl", time.Hour, "TTL of event keys (default 1 hour)") ) func main() { flag.Parse() if len(*migrateDatadir) == 0 { glog.Fatal("need to set '--data-dir'") } dbpath := path.Join(*migrateDatadir, "member", "snap", "db") // etcd3 store backend. We will use it to parse v3 data files and extract information. be := backend.NewDefaultBackend(dbpath) tx := be.BatchTx() // etcd2 store backend. We will use v3 data to update this and then save snapshot to disk. st := store.New(etcdserver.StoreClusterPrefix, etcdserver.StoreKeysPrefix) expireTime := time.Now().Add(*ttl) tx.Lock() err := tx.UnsafeForEach([]byte("key"), func(k, v []byte) error { kv := &mvccpb.KeyValue{} kv.Unmarshal(v) // This is compact key. if !strings.HasPrefix(string(kv.Key), "/") { return nil } ttlOpt := store.TTLOptionSet{} if kv.Lease != 0 { ttlOpt = store.TTLOptionSet{ExpireTime: expireTime} } if !isTombstone(k) { sk := path.Join(strings.Trim(etcdserver.StoreKeysPrefix, "/"), string(kv.Key)) _, err := st.Set(sk, false, string(kv.Value), ttlOpt) if err != nil { return err } } else { st.Delete(string(kv.Key), false, false) } return nil }) if err != nil { glog.Fatal(err) } tx.Unlock() if err := traverseAndDeleteEmptyDir(st, "/"); err != nil { glog.Fatal(err) } // rebuild cluster state. metadata, hardstate, oldSt, err := rebuild(*migrateDatadir) if err != nil { glog.Fatal(err) } // In the following, it's low level logic that saves metadata and data into v2 snapshot. backupPath := *migrateDatadir + ".rollback.backup" if err := os.Rename(*migrateDatadir, backupPath); err != nil { glog.Fatal(err) } if err := os.MkdirAll(path.Join(*migrateDatadir, "member", "snap"), 0700); err != nil { glog.Fatal(err) } walDir := path.Join(*migrateDatadir, "member", "wal") w, err := wal.Create(walDir, metadata) if err != nil { glog.Fatal(err) } err = w.SaveSnapshot(walpb.Snapshot{Index: hardstate.Commit, Term: hardstate.Term}) if err != nil { glog.Fatal(err) } w.Close() event, err := oldSt.Get(etcdserver.StoreClusterPrefix, true, false) if err != nil { glog.Fatal(err) } // nodes (members info) for ConfState nodes := []uint64{} traverseMetadata(event.Node, func(n *store.NodeExtern) { if n.Key != etcdserver.StoreClusterPrefix { // update store metadata v := "" if !n.Dir { v = *n.Value } if n.Key == path.Join(etcdserver.StoreClusterPrefix, "version") { v = rollbackVersion } if _, err := st.Set(n.Key, n.Dir, v, store.TTLOptionSet{}); err != nil { glog.Fatal(err) } // update nodes fields := strings.Split(n.Key, "/") if len(fields) == 4 && fields[2] == "members" { nodeID, err := strconv.ParseUint(fields[3], 16, 64) if err != nil { glog.Fatalf("failed to parse member ID (%s): %v", fields[3], err) } nodes = append(nodes, nodeID) } } }) data, err := st.Save() if err != nil { glog.Fatal(err) } raftSnap := raftpb.Snapshot{ Data: data, Metadata: raftpb.SnapshotMetadata{ Index: hardstate.Commit, Term:  hardstate.Term, ConfState: raftpb.ConfState{ Nodes: nodes, }, }, } snapshotter := snap.New(path.Join(*migrateDatadir, "member", "snap")) if err := snapshotter.SaveSnap(raftSnap); err != nil { glog.Fatal(err) } fmt.Println("Finished successfully") } func traverseMetadata(head *store.NodeExtern, handleFunc func(*store.NodeExtern)) { q := []*store.NodeExtern{head} for len(q) > 0 { n := q[0] q = q[1:] handleFunc(n) for _, next := range n.Nodes { q = append(q, next) } } } const ( revBytesLen       = 8 + 1 + 8 markedRevBytesLen = revBytesLen + 1 markBytePosition  = markedRevBytesLen - 1 markTombstone byte = 't' ) func isTombstone(b []byte) bool { return len(b) == markedRevBytesLen && b[markBytePosition] == markTombstone } func traverseAndDeleteEmptyDir(st store.Store, dir string) error { e, err := st.Get(dir, true, false) if err != nil { return err } if len(e.Node.Nodes) == 0 { st.Delete(dir, true, true) return nil } for _, node := range e.Node.Nodes { if !node.Dir { glog.V(2).Infof("key: %s", node.Key[len(etcdserver.StoreKeysPrefix):]) } else { err := traverseAndDeleteEmptyDir(st, node.Key) if err != nil { return err } } } return nil } func rebuild(datadir string) ([]byte, *raftpb.HardState, store.Store, error) { waldir := path.Join(datadir, "member", "wal") snapdir := path.Join(datadir, "member", "snap") ss := snap.New(snapdir) snapshot, err := ss.Load() if err != nil && err != snap.ErrNoSnapshot { return nil, nil, nil, err } var walsnap walpb.Snapshot if snapshot != nil { walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term } w, err := wal.OpenForRead(waldir, walsnap) if err != nil { return nil, nil, nil, err } defer w.Close() meta, hardstate, ents, err := w.ReadAll() if err != nil { return nil, nil, nil, err } st := store.New(etcdserver.StoreClusterPrefix, etcdserver.StoreKeysPrefix) if snapshot != nil { err := st.Recovery(snapshot.Data) if err != nil { return nil, nil, nil, err } } cluster := membership.NewCluster("") cluster.SetStore(st) applier := etcdserver.NewApplierV2(st, cluster) for _, ent := range ents { if ent.Type == raftpb.EntryConfChange { var cc raftpb.ConfChange pbutil.MustUnmarshal(&cc, ent.Data) switch cc.Type { case raftpb.ConfChangeAddNode: m := new(membership.Member) if err := json.Unmarshal(cc.Context, m); err != nil { return nil, nil, nil, err } cluster.AddMember(m) case raftpb.ConfChangeRemoveNode: id := types.ID(cc.NodeID) cluster.RemoveMember(id) case raftpb.ConfChangeUpdateNode: m := new(membership.Member) if err := json.Unmarshal(cc.Context, m); err != nil { return nil, nil, nil, err } cluster.UpdateRaftAttributes(m.ID, m.RaftAttributes) } continue } var raftReq pb.InternalRaftRequest if !pbutil.MaybeUnmarshal(&raftReq, ent.Data) { // backward compatible var r pb.Request pbutil.MustUnmarshal(&r, ent.Data) applyRequest(&r, applier) } else { if raftReq.V2 != nil { req := raftReq.V2 applyRequest(req, applier) } } } return meta, &hardstate, st, nil } func toTTLOptions(r *pb.Request) store.TTLOptionSet { refresh, _ := pbutil.GetBool(r.Refresh) ttlOptions := store.TTLOptionSet{Refresh: refresh} if r.Expiration != 0 { ttlOptions.ExpireTime = time.Unix(0, r.Expiration) } return ttlOptions } func applyRequest(r *pb.Request, applyV2 etcdserver.ApplierV2) { toTTLOptions(r) switch r.Method { case "PUT": applyV2.Put(r) case "DELETE": applyV2.Delete(r) case "POST", "QGET", "SYNC": return default: glog.Fatal("unknown command") } } </ins>


import ( "fmt" <ins> "reflect" </ins> "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime/schema" <del> serializer "k8s.io/apimachinery/pkg/runtime/serializer" </del> <ins> "k8s.io/apimachinery/pkg/runtime/serializer" </ins> "k8s.io/client-go/rest" "k8s.io/client-go/util/flowcontrol"


return err } if !mountPoint { <del> return fmt.Errorf("azureDisk - Not a mounting point for disk %s on %s", diskName, dir) </del> <ins> glog.V(4).Infof("azureDisk - already mounted to target %s", dir) return nil </ins> } if err := os.MkdirAll(dir, 0750); err != nil {


if len(q.nominatedPods.nominatedPods["node1"]) != 2 { t.Errorf("Expected medPriorityPod and unschedulablePod to be still present in nomindatePods: %v", q.nominatedPods.nominatedPods["node1"]) } <del> if q.unschedulableQ.get(&highPriNominatedPod) != &highPriNominatedPod { </del> <ins> if getUnschedulablePod(q, &highPriNominatedPod) != &highPriNominatedPod { </ins> t.Errorf("Pod %v was not found in the unschedulableQ.", highPriNominatedPod.Name) } }


return "", err } <del> return image.TagFromImage(pod.Spec.Containers[0].Image), nil </del> <ins> return convertImageTagMetadataToSemver(image.TagFromImage(pod.Spec.Containers[0].Image)), nil } // convertImageTagMetadataToSemver converts imagetag in the format of semver_metadata to semver+metadata func convertImageTagMetadataToSemver(tag string) string { // Container registries do not support `+` characters in tag names. This prevents imagetags from // correctly representing semantic versions which use the plus symbol to delimit build metadata. // Kubernetes uses the convention of using an underscore in image registries to preserve // build metadata information in imagetags. return strings.Replace(tag, "_", "+", 1) </ins> }


// In case of failure or too long waiting time, an error is returned. func waitForRCPodToDisappear(c *client.Client, ns, rcName, podName string) error { label := labels.SelectorFromSet(labels.Set(map[string]string{"name": rcName})) <del> return waitForPodToDisappear(c, ns, podName, label, 20*time.Second, 5*time.Minute) </del> <ins> // NodeController evicts pod after 5 minutes, so we need timeout greater than that. // Additionally, there can be non-zero grace period, so we are setting 10 minutes // to be on the safe size. return waitForPodToDisappear(c, ns, podName, label, 20*time.Second, 10*time.Minute) </ins> } // waitForService waits until the service appears (exist == true), or disappears (exist == false)


if utilfeature.DefaultFeatureGate.Enabled(features.CSIDriverRegistry) { csiClient := host.GetKubeClient() if csiClient == nil { <del> return errors.New("unable to get Kubernetes client") </del> <ins> klog.Warning(log("kubeclient not set, assuming standalone kubelet")) } else { // Start informer for CSIDrivers. factory := csiapiinformer.NewSharedInformerFactory(csiClient, csiResyncPeriod) p.csiDriverInformer = factory.Storage().V1beta1().CSIDrivers() p.csiDriverLister = p.csiDriverInformer.Lister() go factory.Start(wait.NeverStop) </ins> } <del> // Start informer for CSIDrivers. factory := csiapiinformer.NewSharedInformerFactory(csiClient, csiResyncPeriod) p.csiDriverInformer = factory.Storage().V1beta1().CSIDrivers() p.csiDriverLister = p.csiDriverInformer.Lister() go factory.Start(wait.NeverStop) </del> } // Initializing the label management channels


// EnsureDesiredReplicasInRange ensure the replicas is in a desired range func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) { interval := 10 * time.Second <del> err := wait.PollUntilContextTimeout(ctx, interval, duration, true, func(ctx context.Context) (bool, error) { replicas := rc.GetReplicas(ctx) framework.Logf("expecting there to be in [%d, %d] replicas (are: %d)", minDesiredReplicas, maxDesiredReplicas, replicas) as, err := rc.GetHpa(ctx, hpaName) if err != nil { framework.Logf("Error getting HPA: %s", err) } else { framework.Logf("HPA status: %+v", as.Status) } if replicas < minDesiredReplicas { return false, fmt.Errorf("number of replicas below target") } else if replicas > maxDesiredReplicas { return false, fmt.Errorf("number of replicas above target") } else { return false, nil // Expected number of replicas found. Continue polling until timeout. } }) // The call above always returns an error, but if it is timeout, it's OK (condition satisfied all the time). if wait.Interrupted(err) { framework.Logf("Number of replicas was stable over %v", duration) return </del> <ins> desiredReplicasErr := framework.Gomega().Consistently(ctx, func(ctx context.Context) int { return rc.GetReplicas(ctx) }).WithTimeout(duration).WithPolling(interval).Should(gomega.And(gomega.BeNumerically(">=", minDesiredReplicas), gomega.BeNumerically("<=", maxDesiredReplicas))) // dump HPA for debugging as, err := rc.GetHpa(ctx, hpaName) if err != nil { framework.Logf("Error getting HPA: %s", err) } else { framework.Logf("HPA status: %+v", as.Status) </ins> } <del> framework.ExpectNoErrorWithOffset(1, err) </del> <ins> framework.ExpectNoError(desiredReplicasErr) </ins> } // Pause stops background goroutines responsible for consuming resources.


ginkgo.It("should always delete fast (ALL of 100 namespaces in 150 seconds) [Feature:ComprehensiveNamespaceDraining]", func() { extinguish(f, 100, 0, 150) }) <ins> ginkgo.It("should patch a Namespace", func() { ginkgo.By("creating a Namespace") namespaceName := "nspatchtest-" + string(uuid.NewUUID()) ns, err := f.CreateNamespace(namespaceName, nil) framework.ExpectNoError(err, "failed creating Namespace") namespaceName = ns.ObjectMeta.Name ginkgo.By("patching the Namespace") nspatch, err := json.Marshal(map[string]interface{}{ "metadata": map[string]interface{}{ "labels": map[string]string{"testLabel": "testValue"}, }, }) framework.ExpectNoError(err, "failed to marshal JSON patch data") _, err = f.ClientSet.CoreV1().Namespaces().Patch(namespaceName, types.StrategicMergePatchType, []byte(nspatch)) framework.ExpectNoError(err, "failed to patch Namespace") ginkgo.By("get the Namespace and ensuring it has the label") namespace, err := f.ClientSet.CoreV1().Namespaces().Get(namespaceName, metav1.GetOptions{}) framework.ExpectNoError(err, "failed to get Namespace") framework.ExpectEqual(namespace.ObjectMeta.Labels["testLabel"], "testValue", "namespace not patched") }) </ins> })


var map_EnvVarSource = map[string]string{ "":                 "EnvVarSource represents a source for the value of an EnvVar.", <del> "fieldRef":         "Selects a field of the pod: supports metadata.name, metadata.namespace, metadata.labels, metadata.annotations, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.", </del> <ins> "fieldRef":         "Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.", </ins> "resourceFieldRef": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.", "configMapKeyRef":  "Selects a key of a ConfigMap.", "secretKeyRef":     "Selects a key of a secret in the pod's namespace",


safeIpset := newSafeIpset(ipset) <ins> nodePortAddresses4, nodePortAddresses6 := utilproxy.FilterIncorrectCIDRVersion(nodePortAddresses, false) </ins> // Create an ipv4 instance of the single-stack proxier ipv4Proxier, err := NewProxier(ipt[0], ipvs, safeIpset, sysctl, exec, syncPeriod, minSyncPeriod, filterCIDRs(false, excludeCIDRs), strictARP, tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit, localDetectors[0], hostname, nodeIP[0], <del> recorder, healthzServer, scheduler, nodePortAddresses, kernelHandler) </del> <ins> recorder, healthzServer, scheduler, nodePortAddresses4, kernelHandler) </ins> if err != nil { return nil, fmt.Errorf("unable to create ipv4 proxier: %v", err) }


// Not local instance, get instanceID from Azure ARM API. if !isLocalInstance { <del> return az.vmSet.GetInstanceIDByNodeName(nodeName) </del> <ins> if az.vmSet != nil { return az.vmSet.GetInstanceIDByNodeName(nodeName) } // vmSet == nil indicates credentials are not provided. return "", fmt.Errorf("no credentials provided for Azure cloud provider") </ins> } // Get resource group name.


--bind-address="${API_HOST}"  --insecure-port="${API_PORT}"  --etcd-servers="http://${ETCD_HOST}:${ETCD_PORT}"  <ins> --etcd-prefix="${ETCD_PREFIX}"  </ins> --runtime-config="${RUNTIME_CONFIG}"  --cert-dir="${TMPDIR:-/tmp/}"  --service-cluster-ip-range="10.0.0.0/24"


}, "securityContext": { "$ref": "#/definitions/io.k8s.api.core.v1.SecurityContext", <del> "description": "Security options the pod should run with. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" </del> <ins> "description": "SecurityContext defines the security options the container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" </ins> }, "startupProbe": { "$ref": "#/definitions/io.k8s.api.core.v1.Probe",


) const ( <del> validTmpl    = "image: {{ .ImageRepository }}/pause-{{ .Arch }}:3.0" validTmplOut = "image: gcr.io/google_containers/pause-amd64:3.0" doNothing    = "image: gcr.io/google_containers/pause-amd64:3.0" </del> <ins> validTmpl    = "image: {{ .ImageRepository }}/pause-{{ .Arch }}:3.1" validTmplOut = "image: gcr.io/google_containers/pause-amd64:3.1" doNothing    = "image: gcr.io/google_containers/pause-amd64:3.1" </ins> invalidTmpl1 = "{{ .baz }/d}" invalidTmpl2 = "{{ !foobar }}" )


<del> apiVersion: v1 kind: ServiceAccount metadata: name: elasticsearch </del>


return } <del> RemoveCleanupAction(f.cleanupHandle) </del> // This should not happen. Given ClientSet is a public field a test must have updated it! // Error out early before any API calls during cleanup. if f.ClientSet == nil {


} } <del> func newDeployment(deploymentName string, replicas int, podLabels map[string]string, imageName string, image string) *extensions.Deployment { </del> <ins> func newDeployment(deploymentName string, replicas int, podLabels map[string]string, imageName string, image string, strategyType extensions.DeploymentStrategyType) *extensions.Deployment { </ins> return &extensions.Deployment{ ObjectMeta: api.ObjectMeta{ Name: deploymentName, }, Spec: extensions.DeploymentSpec{ <del> Replicas:       replicas, Selector:       podLabels, </del> <ins> Replicas: replicas, Selector: podLabels, Strategy: extensions.DeploymentStrategy{ Type: strategyType, }, </ins> UniqueLabelKey: extensions.DefaultDeploymentUniqueLabelKey, Template: api.PodTemplateSpec{ ObjectMeta: api.ObjectMeta{


package logs import ( <ins> "bufio" </ins> "bytes" "context" <ins> "fmt" "io" "io/ioutil" </ins> "os" "testing" "time"


proberDurationLabels := metrics.Labels{ "probe_type": w.probeType.String(), "container":  w.container.Name, <del> "pod":        podName, </del> <ins> "pod":        w.pod.Name, </ins> "namespace":  w.pod.Namespace, }


service Node { // NodePrepareResources prepares several ResourceClaims // for use on the node. If an error is returned, the <del> // response is ignored. Failures for individidual claims </del> <ins> // response is ignored. Failures for individual claims </ins> // can be reported inside NodePrepareResourcesResponse. rpc NodePrepareResources (NodePrepareResourcesRequest) returns (NodePrepareResourcesResponse) {}


var _ = Describe("Shell", func() { defer GinkgoRecover() <del> // A number of scripts only work on gce if testContext.Provider != "gce" && testContext.Provider != "gke" { By(fmt.Sprintf("Skipping Shell test, which is only supported for provider gce and gke (not %s)", testContext.Provider)) return } </del> // Slurp up all the tests in hack/e2e-suite bashE2ERoot := filepath.Join(root, "hack/e2e-suite") files, err := ioutil.ReadDir(bashE2ERoot)


klog.ErrorS(err, "Unable to connect to device plugin client with socket path", "path", c.socket) return err } <ins> c.mutex.Lock() </ins> c.grpc = conn c.client = client <ins> c.mutex.Unlock() </ins> return c.handler.PluginConnected(c.resource, c) }


"Required Drop Capabilities:s*<none>", "Allowed Capabilities:s*<none>", "Allowed Volume Types:s*<none>", <ins> "Allowed Unsafe Sysctls:s*kernel.*,net.ipv4.ip_local_port_range", "Forbidden Sysctls:s*net.ipv4.ip_default_ttl", </ins> "Allow Host Network:s*false", "Allow Host Ports:s*<none>", "Allow Host PID:s*false",


assert.Equal(t, test.expectStderr, stderrBuf.String()) } } <ins> func TestReadLogsLimitsWithTimestamps(t *testing.T) { logLineFmt := "2022-10-29T16:10:22.592603036-05:00 stdout P %vn" logLineNewLine := "2022-10-29T16:10:22.592603036-05:00 stdout F n" tmpfile, err := ioutil.TempFile("", "log.*.txt") assert.NoError(t, err) count := 10000 for i := 0; i < count; i++ { tmpfile.WriteString(fmt.Sprintf(logLineFmt, i)) } tmpfile.WriteString(logLineNewLine) for i := 0; i < count; i++ { tmpfile.WriteString(fmt.Sprintf(logLineFmt, i)) } tmpfile.WriteString(logLineNewLine) // two lines are in the buffer defer os.Remove(tmpfile.Name()) // clean up assert.NoError(t, err) tmpfile.Close() var buf bytes.Buffer w := io.MultiWriter(&buf) err = ReadLogs(context.Background(), tmpfile.Name(), "", &LogOptions{tail: -1, bytes: -1, timestamp: true}, nil, w, w) assert.NoError(t, err) lineCount := 0 scanner := bufio.NewScanner(bytes.NewReader(buf.Bytes())) for scanner.Scan() { lineCount++ // Split the line ts, logline, _ := bytes.Cut(scanner.Bytes(), []byte(" ")) // Verification //   1. The timestamp should exist //   2. The last item in the log should be 9999 _, err = time.Parse(time.RFC3339, string(ts)) assert.NoError(t, err, "timestamp not found") assert.Equal(t, true, bytes.HasSuffix(logline, []byte("9999")), "is the complete log found") } assert.Equal(t, 2, lineCount, "should have two lines") } </ins>


cp "${src_file}" /etc/kubernetes/manifests } <ins> # Starts cluster autoscaler. function start-cluster-autoscaler { if [ "${ENABLE_NODE_AUTOSCALER:-}" = "true" ]; then touch /etc/kubernetes/start-cluster-autoscaler-enabled # Remove salt comments and replace variables with values src_file="${KUBE_HOME}/kube-manifests/kubernetes/gci-trusty/cluster-autoscaler.manifest" remove-salt-config-comments "${src_file}" local params=`sed 's/^/"/;s/ /","/g;s/$/",/' <<< "${AUTOSCALER_MIG_CONFIG}"` sed -i -e "s@"{{param}}",@${params}@g" "${src_file}" sed -i -e "s@{%.*%}@@g" "${src_file}" cp "${src_file}" /etc/kubernetes/manifests fi } </ins> # A helper function for copying addon manifests and set dir/files # permissions. #


if StatusStrategy.AllowCreateOnUpdate() { t.Errorf("Namespaces should not allow create on update") } <ins> now := util.Now() </ins> oldNamespace := &api.Namespace{ ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "10"}, Spec:       api.NamespaceSpec{Finalizers: []api.FinalizerName{"kubernetes"}}, Status:     api.NamespaceStatus{Phase: api.NamespaceActive}, } namespace := &api.Namespace{ <del> ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "9"}, </del> <ins> ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "9", DeletionTimestamp: &now}, </ins> Status:     api.NamespaceStatus{Phase: api.NamespaceTerminating}, } StatusStrategy.PrepareForUpdate(namespace, oldNamespace)