<ins> /* Copyright 2018 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 cmd import ( "fmt" "io" "sort" "strings" "github.com/spf13/cobra" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/kubernetes/pkg/kubectl/cmd/templates" cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/printers" ) var ( apiresources_example = templates.Examples(` # Print the supported API Resources kubectl api-resources # Print the supported API Resources with more information kubectl api-resources -o wide # Print the supported namespaced resources kubectl api-resources --namespaced=true # Print the supported non-namespaced resources kubectl api-resources --namespaced=false # Print the supported API Resources with specific APIGroup kubectl api-resources --api-group=extensions`) ) // ApiResourcesOptions is the start of the data required to perform the operation.  As new fields are added, add them here instead of // referencing the cmd.Flags() type ApiResourcesOptions struct { out io.Writer Output     string APIGroup   string Namespaced bool NoHeaders  bool } // groupResource contains the APIGroup and APIResource type groupResource struct { APIGroup    string APIResource metav1.APIResource } func NewCmdApiResources(f cmdutil.Factory, out io.Writer) *cobra.Command { options := &ApiResourcesOptions{ out: out, } cmd := &cobra.Command{ Use:     "api-resources", Short:   "Print the supported API resources on the server", Long:    "Print the supported API resources on the server", Example: apiresources_example, Run: func(cmd *cobra.Command, args []string) { cmdutil.CheckErr(options.Complete(cmd)) cmdutil.CheckErr(options.Validate(cmd)) cmdutil.CheckErr(options.RunApiResources(cmd, f)) }, } cmdutil.AddOutputFlags(cmd) cmdutil.AddNoHeadersFlags(cmd) cmd.Flags().StringVar(&options.APIGroup, "api-group", "", "The API group to use when talking to the server.") cmd.Flags().BoolVar(&options.Namespaced, "namespaced", true, "Namespaced indicates if a resource is namespaced or not.") return cmd } func (o *ApiResourcesOptions) Complete(cmd *cobra.Command) error { o.Output = cmdutil.GetFlagString(cmd, "output") o.NoHeaders = cmdutil.GetFlagBool(cmd, "no-headers") return nil } func (o *ApiResourcesOptions) Validate(cmd *cobra.Command) error { validOutputTypes := sets.NewString("", "json", "yaml", "wide", "name", "custom-columns", "custom-columns-file", "go-template", "go-template-file", "jsonpath", "jsonpath-file") supportedOutputTypes := sets.NewString("", "wide") outputFormat := cmdutil.GetFlagString(cmd, "output") if !validOutputTypes.Has(outputFormat) { return fmt.Errorf("output must be one of '' or 'wide': %v", outputFormat) } if !supportedOutputTypes.Has(outputFormat) { return fmt.Errorf("--output %v is not available in kubectl api-resources", outputFormat) } return nil } func (o *ApiResourcesOptions) RunApiResources(cmd *cobra.Command, f cmdutil.Factory) error { w := printers.GetNewTabWriter(o.out) defer w.Flush() discoveryclient, err := f.DiscoveryClient() if err != nil { return err } // Always request fresh data from the server discoveryclient.Invalidate() lists, err := discoveryclient.ServerPreferredResources() if err != nil { return err } resources := []groupResource{} groupChanged := cmd.Flags().Changed("api-group") nsChanged := cmd.Flags().Changed("namespaced") for _, list := range lists { if len(list.APIResources) == 0 { continue } gv, err := schema.ParseGroupVersion(list.GroupVersion) if err != nil { continue } for _, resource := range list.APIResources { if len(resource.Verbs) == 0 { continue } // filter apiGroup if groupChanged && o.APIGroup != gv.Group { continue } // filter namespaced if nsChanged && o.Namespaced != resource.Namespaced { continue } resources = append(resources, groupResource{ APIGroup:    gv.Group, APIResource: resource, }) } } if o.NoHeaders == false { if err = printContextHeaders(w, o.Output); err != nil { return err } } sort.Stable(sortableGroupResource(resources)) for _, r := range resources { if o.Output == "wide" { if _, err := fmt.Fprintf(w, "%st%st%st%vt%st%vn", r.APIResource.Name, strings.Join(r.APIResource.ShortNames, ","), r.APIGroup, r.APIResource.Namespaced, r.APIResource.Kind, r.APIResource.Verbs); err != nil { return err } } else { if _, err := fmt.Fprintf(w, "%st%st%st%vt%sn", r.APIResource.Name, strings.Join(r.APIResource.ShortNames, ","), r.APIGroup, r.APIResource.Namespaced, r.APIResource.Kind); err != nil { return err } } } return nil } func printContextHeaders(out io.Writer, output string) error { columnNames := []string{"NAME", "SHORTNAMES", "APIGROUP", "NAMESPACED", "KIND"} if output == "wide" { columnNames = append(columnNames, "VERBS") } _, err := fmt.Fprintf(out, "%sn", strings.Join(columnNames, "t")) return err } type sortableGroupResource []groupResource func (s sortableGroupResource) Len() int      { return len(s) } func (s sortableGroupResource) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s sortableGroupResource) Less(i, j int) bool { ret := strings.Compare(s[i].APIGroup, s[j].APIGroup) if ret > 0 { return false } else if ret == 0 { return strings.Compare(s[i].APIResource.Name, s[j].APIResource.Name) < 0 } return true } </ins>


// have a place they can schedule. testRootDir = makeTempDirOrDie("kubelet_integ_2.", "") glog.Infof("Using %s as root dir for kubelet #2", testRootDir) <del> kcfg = kubeletapp.SimpleKubelet(cl, &fakeDocker2, machineList[1], testRootDir, "", "127.0.0.1", 10251, api.NamespaceDefault, empty_dir.ProbeVolumePlugins(), nil, cadvisorInterface, "") </del> <ins> kcfg = kubeletapp.SimpleKubelet(cl, &fakeDocker2, machineList[1], testRootDir, secondManifestURL, "127.0.0.1", 10251, api.NamespaceDefault, empty_dir.ProbeVolumePlugins(), nil, cadvisorInterface, "") </ins> kcfg.PodStatusUpdateFrequency = 1 * time.Second kubeletapp.RunKubelet(kcfg) return apiServer.URL, configFilePath


kind: Pod metadata: name: b <ins> namespace: nsb </ins> labels: prune-group: "true" spec:


return nil, cleanupAction, fmt.Errorf("volume subpaths are disabled") } <del> if !utilfeature.DefaultFeatureGate.Enabled(features.VolumeSubpathEnvExpansion) { return nil, cleanupAction, fmt.Errorf("volume subpath expansion is disabled") } </del> subPath, err = kubecontainer.ExpandContainerVolumeMounts(mount, expandEnvs) if err != nil {


func CheckAffinity(execPod *v1.Pod, serviceIP string, servicePort int, shouldHold bool) bool { serviceIPPort := net.JoinHostPort(serviceIP, strconv.Itoa(servicePort)) cmd := fmt.Sprintf(`curl -q -s --connect-timeout 2 http://%s/`, serviceIPPort) <del> timeout := TestTimeout </del> <ins> timeout := AffinityTimeout </ins> if execPod == nil { timeout = LoadBalancerPollTimeout }


return json.Marshal(doc) } <del> // CreateMergePatch creates a merge patch as specified in http://tools.ietf.org/html/draft-ietf-appsawg-json-merge-patch-07 // // 'a' is original, 'b' is the modified document. Both are to be given as json encoded content. // The function will return a mergeable json document with differences from a to b. // // An error will be returned if any of the two documents are invalid. func CreateMergePatch(a, b []byte) ([]byte, error) { aI := map[string]interface{}{} bI := map[string]interface{}{} err := json.Unmarshal(a, &aI) </del> <ins> // resemblesJSONArray indicates whether the byte-slice "appears" to be // a JSON array or not. // False-positives are possible, as this function does not check the internal // structure of the array. It only checks that the outer syntax is present and // correct. func resemblesJSONArray(input []byte) bool { input = bytes.TrimSpace(input) hasPrefix := bytes.HasPrefix(input, []byte("[")) hasSuffix := bytes.HasSuffix(input, []byte("]")) return hasPrefix && hasSuffix } // CreateMergePatch will return a merge patch document capable of converting // the original document(s) to the modified document(s). // The parameters can be bytes of either two JSON Documents, or two arrays of // JSON documents. // The merge patch returned follows the specification defined at http://tools.ietf.org/html/draft-ietf-appsawg-json-merge-patch-07 func CreateMergePatch(originalJSON, modifiedJSON []byte) ([]byte, error) { originalResemblesArray := resemblesJSONArray(originalJSON) modifiedResemblesArray := resemblesJSONArray(modifiedJSON) // Do both byte-slices seem like JSON arrays? if originalResemblesArray && modifiedResemblesArray { return createArrayMergePatch(originalJSON, modifiedJSON) } // Are both byte-slices are not arrays? Then they are likely JSON objects... if !originalResemblesArray && !modifiedResemblesArray { return createObjectMergePatch(originalJSON, modifiedJSON) } // None of the above? Then return an error because of mismatched types. return nil, errBadMergeTypes } // createObjectMergePatch will return a merge-patch document capable of // converting the original document to the modified document. func createObjectMergePatch(originalJSON, modifiedJSON []byte) ([]byte, error) { originalDoc := map[string]interface{}{} modifiedDoc := map[string]interface{}{} err := json.Unmarshal(originalJSON, &originalDoc) </ins> if err != nil { return nil, errBadJSONDoc } <del> err = json.Unmarshal(b, &bI) </del> <ins> err = json.Unmarshal(modifiedJSON, &modifiedDoc) </ins> if err != nil { return nil, errBadJSONDoc } <del> dest, err := getDiff(aI, bI) </del> <ins> dest, err := getDiff(originalDoc, modifiedDoc) </ins> if err != nil { return nil, err } return json.Marshal(dest) } <ins> // createArrayMergePatch will return an array of merge-patch documents capable // of converting the original document to the modified document for each // pair of JSON documents provided in the arrays. // Arrays of mismatched sizes will result in an error. func createArrayMergePatch(originalJSON, modifiedJSON []byte) ([]byte, error) { originalDocs := []json.RawMessage{} modifiedDocs := []json.RawMessage{} err := json.Unmarshal(originalJSON, &originalDocs) if err != nil { return nil, errBadJSONDoc } err = json.Unmarshal(modifiedJSON, &modifiedDocs) if err != nil { return nil, errBadJSONDoc } total := len(originalDocs) if len(modifiedDocs) != total { return nil, errBadJSONDoc } result := []json.RawMessage{} for i := 0; i < len(originalDocs); i++ { original := originalDocs[i] modified := modifiedDocs[i] patch, err := createObjectMergePatch(original, modified) if err != nil { return nil, err } result = append(result, json.RawMessage(patch)) } return json.Marshal(result) } </ins> // Returns true if the array matches (must be json types). // As is idiomatic for go, an empty array is not the same as a nil array. func matchesArray(a, b []interface{}) bool {


} type Zones interface { <del> // List returns the managed Zones, or an error if the list operation failed. </del> <ins> // List returns the (possibly empty) list of managed Zones, or an error if the list operation failed. </ins> List() ([]Zone, error) // Add creates and returns a new managed zone, or an error if the operation failed Add(Zone) (Zone, error)


"net/http/httptest" "os" "reflect" <ins> "strconv" </ins> "strings" "sync" "testing"


<del> // +build cgo,linux </del> <ins> // +build linux </ins> /* Copyright 2015 The Kubernetes Authors.


}, { "ImportPath": "github.com/evanphx/json-patch", <del> "Rev": "ed7cfbae1fffc071f71e068df27bf4f0521402d8" </del> <ins> "Rev": "94e38aa1586e8a6c8a75770bddf5ff84c48a106b" </ins> }, { "ImportPath": "github.com/ghodss/yaml",


if cleanupInfo != nil { // we don't perform the clean up just yet at that could destroy information // needed for the container to start (e.g. Windows credentials stored in <del> // registry keys); instead, we'll clean up after the container successfully // starts or gets removed </del> <ins> // registry keys); instead, we'll clean up when the container gets removed </ins> ds.containerCleanupInfos[containerID] = cleanupInfo } return &runtimeapi.CreateContainerResponse{ContainerId: containerID}, nil } <del> // the creation failed, let's clean up right away </del> <ins> // the creation failed, let's clean up right away - we ignore any errors though, // this is best effort </ins> ds.performPlatformSpecificContainerCleanupAndLogErrors(containerName, cleanupInfo) return nil, createErr


// 1. Add a volume to DSW and wait until it's mounted volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]} <ins> // copy before reconciler runs to avoid data race. volumeSpecCopy := &volume.Spec{Volume: &pod.Spec.Volumes[0]} </ins> podName := util.GetUniquePodName(pod) generatedVolumeName, err := dsw.AddPodToVolume( podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */)


func (f *Framework) BeforeEach() { f.beforeEachStarted = true <del> // The fact that we need this feels like a bug in ginkgo. // https://github.com/onsi/ginkgo/v2/issues/222 f.cleanupHandle = AddCleanupAction(f.AfterEach) </del> if f.ClientSet == nil { ginkgo.By("Creating a kubernetes client") config, err := LoadConfig()


for n, pods := range nodeToDaemonPods { if !isNodeRunning[n] { for _, pod := range pods { <del> results = append(results, pod.Name) </del> <ins> if len(pod.Spec.NodeName) == 0 { results = append(results, pod.Name) } </ins> } } }


<ins> // +build linux /* Copyright 2021 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 e2enode import ( "time" "golang.org/x/sys/unix" "github.com/onsi/ginkgo" "github.com/onsi/gomega" "k8s.io/kubernetes/test/e2e/framework" ) const contentionLockFile = "/var/run/kubelet.lock" var _ = SIGDescribe("Lock contention [Slow] [Disruptive] [NodeFeature:LockContention]", func() { ginkgo.It("Kubelet should stop when the test acquires the lock on lock file and restart once the lock is released", func() { ginkgo.By("perform kubelet health check to check if kubelet is healthy and running.") // Precautionary check that kubelet is healthy before running the test. gomega.Expect(kubeletHealthCheck(kubeletHealthCheckURL)).To(gomega.BeTrue()) ginkgo.By("acquiring the lock on lock file i.e /var/run/kubelet.lock") // Open the file with the intention to acquire the lock, this would imitate the behaviour // of the another kubelet(self-hosted) trying to start. When this lock contention happens // it is expected that the running kubelet must terminate and wait until the lock on the // lock file is released. // Kubelet uses the same approach to acquire the lock on lock file as shown here: // https://github.com/kubernetes/kubernetes/blob/master/cmd/kubelet/app/server.go#L530-#L546 // and the function definition of Acquire is here: // https://github.com/kubernetes/kubernetes/blob/master/pkg/util/flock/flock_unix.go#L25 fd, err := unix.Open(contentionLockFile, unix.O_CREAT|unix.O_RDWR|unix.O_CLOEXEC, 0600) framework.ExpectNoError(err) // Defer the lock release in case test fails and we don't reach the step of the release // lock. This ensures that we release the lock for sure. defer func() { err = unix.Flock(fd, unix.LOCK_UN) framework.ExpectNoError(err) }() // Acquire lock. err = unix.Flock(fd, unix.LOCK_EX) framework.ExpectNoError(err) ginkgo.By("verifying the kubelet is not healthy as there was a lock contention.") // Once the lock is acquired, check if the kubelet is in healthy state or not. // It should not be. gomega.Eventually(func() bool { return kubeletHealthCheck(kubeletHealthCheckURL) }, 10*time.Second, time.Second).Should(gomega.BeFalse()) ginkgo.By("releasing the lock on lock file i.e /var/run/kubelet.lock") // Release the lock. err = unix.Flock(fd, unix.LOCK_UN) framework.ExpectNoError(err) ginkgo.By("verifying the kubelet is healthy again after the lock was released.") // Releasing the lock triggers kubelet to re-acquire the lock and restart. // Hence the kubelet should report healthy state. gomega.Eventually(func() bool { return kubeletHealthCheck(kubeletHealthCheckURL) }, 10*time.Second, time.Second).Should(gomega.BeTrue()) }) }) </ins>


"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", <ins> "//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library", </ins> "//staging/src/k8s.io/client-go/dynamic:go_default_library", "//test/integration/framework:go_default_library", "//vendor/github.com/coreos/etcd/clientv3:go_default_library",


if err != nil { t.Fatal(err) } ss1Rev1.Namespace = ss1.Namespace ss1Rev2, err := NewControllerRevision(ss1, parentKind, ss1.Spec.Template.Labels, rawTemplate(&ss1.Spec.Template), 2, ss1.Status.CollisionCount) if err != nil { t.Fatal(err) } ss1Rev2.Namespace = ss1.Namespace ss1Rev3, err := NewControllerRevision(ss1, parentKind, ss1.Spec.Template.Labels, rawTemplate(&ss1.Spec.Template), 3, ss1.Status.CollisionCount) if err != nil { t.Fatal(err) } <del> ss1Rev3.Namespace = ss1.Namespace </del> <ins> ss1Rev3Time2, err := NewControllerRevision(ss1, parentKind, ss1.Spec.Template.Labels, rawTemplate(&ss1.Spec.Template), 3, ss1.Status.CollisionCount) if err != nil { t.Fatal(err) } ss1Rev3Time2.Namespace = ss1.Namespace ss1Rev3Time2.CreationTimestamp = metav1.Time{Time: ss1Rev3.CreationTimestamp.Add(time.Second)} ss1Rev3Time2Name2, err := NewControllerRevision(ss1, parentKind, ss1.Spec.Template.Labels, rawTemplate(&ss1.Spec.Template), 3, ss1.Status.CollisionCount) if err != nil { t.Fatal(err) } ss1Rev3Time2Name2.Namespace = ss1.Namespace ss1Rev3Time2Name2.CreationTimestamp = metav1.Time{Time: ss1Rev3.CreationTimestamp.Add(time.Second)} </ins> tests := []testcase{ {


} framework.ExpectEqual(successes, largeCompletions, "expected %d successful job pods, but got  %d", largeCompletions, successes) }) <ins> ginkgo.It("should apply changes to a job status", func() { ns := f.Namespace.Name jClient := f.ClientSet.BatchV1().Jobs(ns) ginkgo.By("Creating a job") job := e2ejob.NewTestJob("notTerminate", "suspend-false-to-true", v1.RestartPolicyNever, parallelism, completions, nil, backoffLimit) job, err := e2ejob.CreateJob(f.ClientSet, f.Namespace.Name, job) framework.ExpectNoError(err, "failed to create job in namespace: %s", f.Namespace.Name) ginkgo.By("Ensure pods equal to paralellism count is attached to the job") err = e2ejob.WaitForAllJobPodsRunning(f.ClientSet, f.Namespace.Name, job.Name, parallelism) framework.ExpectNoError(err, "failed to ensure number of pods associated with job %s is equal to parallelism count in namespace: %s", job.Name, f.Namespace.Name) // /status subresource operations ginkgo.By("patching /status") // we need to use RFC3339 version since conversion over the wire cuts nanoseconds now1 := metav1.Now().Rfc3339Copy() jStatus := batchv1.JobStatus{ StartTime: &now1, } jStatusJSON, err := json.Marshal(jStatus) framework.ExpectNoError(err) patchedStatus, err := jClient.Patch(context.TODO(), job.Name, types.MergePatchType, []byte(`{"metadata":{"annotations":{"patchedstatus":"true"}},"status":`+string(jStatusJSON)+`}`), metav1.PatchOptions{}, "status") framework.ExpectNoError(err) framework.ExpectEqual(patchedStatus.Status.StartTime.Equal(&now1), true, "patched object should have the applied StartTime status") framework.ExpectEqual(patchedStatus.Annotations["patchedstatus"], "true", "patched object should have the applied annotation") ginkgo.By("updating /status") // we need to use RFC3339 version since conversion over the wire cuts nanoseconds now2 := metav1.Now().Rfc3339Copy() var statusToUpdate, updatedStatus *batchv1.Job err = retry.RetryOnConflict(retry.DefaultRetry, func() error { statusToUpdate, err = jClient.Get(context.TODO(), job.Name, metav1.GetOptions{}) if err != nil { return err } statusToUpdate.Status.StartTime = &now2 updatedStatus, err = jClient.UpdateStatus(context.TODO(), statusToUpdate, metav1.UpdateOptions{}) return err }) framework.ExpectNoError(err) framework.ExpectEqual(updatedStatus.Status.StartTime.Equal(&now2), true, fmt.Sprintf("updated object status expected to have updated StartTime %#v, got %#v", statusToUpdate.Status.StartTime, updatedStatus.Status.StartTime)) ginkgo.By("get /status") jResource := schema.GroupVersionResource{Group: "batch", Version: "v1", Resource: "jobs"} gottenStatus, err := f.DynamicClient.Resource(jResource).Namespace(ns).Get(context.TODO(), job.Name, metav1.GetOptions{}, "status") framework.ExpectNoError(err) statusUID, _, err := unstructured.NestedFieldCopy(gottenStatus.Object, "metadata", "uid") framework.ExpectNoError(err) framework.ExpectEqual(string(job.UID), statusUID, fmt.Sprintf("job.UID: %v expected to match statusUID: %v ", job.UID, statusUID)) }) </ins> }) // waitForJobFailure uses c to wait for up to timeout for the Job named jobName in namespace ns to fail.


publicIP := "" if ipConfig.PublicIPAddress != nil && ipConfig.PublicIPAddress.ID != nil { pipID := *ipConfig.PublicIPAddress.ID <del> pipName, err := getLastSegment(pipID) if err != nil { return "", "", fmt.Errorf("failed to get publicIP name for node %q with pipID %q", nodeName, pipID) </del> <ins> matches := vmssPIPConfigurationRE.FindStringSubmatch(pipID) if len(matches) == 7 { resourceGroupName := matches[1] virtualMachineScaleSetName := matches[2] virtualmachineIndex := matches[3] networkInterfaceName := matches[4] IPConfigurationName := matches[5] publicIPAddressName := matches[6] pip, existsPip, err := ss.getVMSSPublicIPAddress(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, IPConfigurationName, publicIPAddressName) if err != nil { klog.Errorf("ss.getVMSSPublicIPAddress() failed with error: %v", err) return "", "", err } if existsPip && pip.IPAddress != nil { publicIP = *pip.IPAddress } } else { klog.Warningf("Failed to get VMSS Public IP with ID %s", pipID) </ins> } <ins> } </ins> <del> resourceGroup, err := ss.GetNodeResourceGroup(nodeName) if err != nil { return "", "", err } </del> <ins> return internalIP, publicIP, nil } </ins> <del> pip, existsPip, err := ss.getPublicIPAddress(resourceGroup, pipName) if err != nil { return "", "", err } if existsPip { publicIP = *pip.IPAddress } </del> <ins> func (ss *scaleSet) getVMSSPublicIPAddress(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string, publicIPAddressName string) (pip network.PublicIPAddress, exists bool, err error) { var realErr error var message string ctx, cancel := getContextWithCancel() defer cancel() pip, err = ss.PublicIPAddressesClient.GetVirtualMachineScaleSetPublicIPAddress(ctx, resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, IPConfigurationName, publicIPAddressName, "") exists, message, realErr = checkResourceExistsFromError(err) if realErr != nil { return pip, false, realErr </ins> } <del> return internalIP, publicIP, nil </del> <ins> if !exists { klog.V(2).Infof("Public IP %q not found with message: %q", publicIPAddressName, message) return pip, false, nil } return pip, exists, err </ins> } // returns a list of private ips assigned to node


return g.service } <ins> type rateLimitedRoundTripper struct { rt      http.RoundTripper limiter flowcontrol.RateLimiter } func (rl *rateLimitedRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { rl.limiter.Accept() return rl.rt.RoundTrip(req) } </ins> func getProjectAndZone() (string, string, error) { result, err := metadata.Get("instance/zone") if err != nil {


<ins> /* Copyright 2023 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 service import "context" /* Copied from: k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2 */ // Service allows encrypting and decrypting data using an external Key Management Service. type Service interface { // Decrypt a given bytearray to obtain the original data as bytes. Decrypt(ctx context.Context, uid string, req *DecryptRequest) ([]byte, error) // Encrypt bytes to a ciphertext. Encrypt(ctx context.Context, uid string, data []byte) (*EncryptResponse, error) // Status returns the status of the KMS. Status(ctx context.Context) (*StatusResponse, error) } // EncryptResponse is the response from the Envelope service when encrypting data. type EncryptResponse struct { Ciphertext  []byte KeyID       string Annotations map[string][]byte } // DecryptRequest is the request to the Envelope service when decrypting data. type DecryptRequest struct { Ciphertext  []byte KeyID       string Annotations map[string][]byte } // StatusResponse is the response from the Envelope service when getting the status of the service. type StatusResponse struct { Version string Healthz string KeyID   string } </ins>


apps "k8s.io/api/apps/v1" "k8s.io/api/core/v1" <ins> apiequality "k8s.io/apimachinery/pkg/api/equality" </ins> "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels"


<ins> # Releasing Kubernetes This document explains how to create a Kubernetes release (as in version) and how the version information gets embedded into the built binaries. ## Origin of the Sources Kubernetes may be built from either a git tree (using `hack/build-go.sh`) or from a tarball (using either `hack/build-go.sh` or `go install`) or directly by the Go native build system (using `go get`). When building from git, we want to be able to insert specific information about the build tree at build time. In particular, we want to use the output of `git describe` to generate the version of Kubernetes and the status of the build tree (add a `-dirty` prefix if the tree was modified.) When building from a tarball or using the Go build system, we will not have access to the information about the git tree, but we still want to be able to tell whether this build corresponds to an exact release (e.g. v0.3) or is between releases (e.g. at some point in development between v0.3 and v0.4). ## Version Number Format In order to account for these use cases, there are some specific formats that may end up representing the Kubernetes version. Here are a few examples: - **v0.5**: This is official version 0.5 and this version will only be used when building from a clean git tree at the v0.5 git tag, or from a tree extracted from the tarball corresponding to that specific release. - **v0.5-15-g0123abcd4567**: This is the `git describe` output and it indicates that we are 15 commits past the v0.5 release and that the SHA1 of the commit where the binaries were built was `0123abcd4567`. It is only possible to have this level of detail in the version information when building from git, not when building from a tarball. - **v0.5-15-g0123abcd4567-dirty** or **v0.5-dirty**: The extra `-dirty` prefix means that the tree had local modifications or untracked files at the time of the build, so there's no guarantee that the source code matches exactly the state of the tree at the `0123abcd4567` commit or at the `v0.5` git tag (resp.) - **v0.5-dev**: This means we are building from a tarball or using `go get` or, if we have a git tree, we are using `go install` directly, so it is not possible to inject the git version into the build information. Additionally, this is not an official release, so the `-dev` prefix indicates that the version we are building is after `v0.5` but before `v0.6`. (There is actually an exception where a commit with `v0.5-dev` is not present on `v0.6`, see later for details.) ## Injecting Version into Binaries In order to cover the different build cases, we start by providing information that can be used when using only Go build tools or when we do not have the git version information available. To be able to provide a meaningful version in those cases, we set the contents of variables in a Go source file that will be used when no overrides are present. We are using `pkg/version/base.go` as the source of versioning in absence of information from git. Here is a sample of that file's contents: ``` var ( gitVersion   string = "v0.4-dev"  // version from git, output of $(git describe) gitCommit    string = ""          // sha1 from git, output of $(git rev-parse HEAD) ) ``` This means a build with `go install` or `go get` or a build from a tarball will yield binaries that will identify themselves as `v0.4-dev` and will not be able to provide you with a SHA1. To add the extra versioning information when building from git, the `hack/build-go.sh` script will gather that information (using `git describe` and `git rev-parse`) and then create a `-ldflags` string to pass to `go install` and tell the Go linker to override the contents of those variables at build time. It can, for instance, tell it to override `gitVersion` and set it to `v0.4-13-g4567bcdef6789-dirty` and set `gitCommit` to `4567bcdef6789...` which is the complete SHA1 of the (dirty) tree used at build time. ## Handling Official Versions Handling official versions from git is easy, as long as there is an annotated git tag pointing to a specific version then `git describe` will return that tag exactly which will match the idea of an official version (e.g. `v0.5`). Handling it on tarballs is a bit harder since the exact version string must be present in `pkg/version/base.go` for it to get embedded into the binaries. But simply creating a commit with `v0.5` on its own would mean that the commits coming after it would also get the `v0.5` version when built from tarball or `go get` while in fact they do not match `v0.5` (the one that was tagged) exactly. To handle that case, creating a new release should involve creating two adjacent commits where the first of them will set the version to `v0.5` and the second will set it to `v0.5-dev`. In that case, even in the presence of merges, there will be a single comit where the exact `v0.5` version will be used and all others around it will either have `v0.4-dev` or `v0.5-dev`. The diagram below illustrates it. ![Diagram of git commits involved in the release](./releasing.png) After working on `v0.4-dev` and merging PR 99 we decide it is time to release `v0.5`. So we start a new branch, create one commit to update `pkg/version/base.go` to include `gitVersion = "v0.5"` and `git commit` it. We test it and make sure everything is working as expected. Before sending a PR for it, we create a second commit on that same branch, updating `pkg/version/base.go` to include `gitVersion = "v0.5-dev"`. That will ensure that further builds (from tarball or `go install`) on that tree will always include the `-dev` prefix and will not have a `v0.5` version (since they do not match the official `v0.5` exactly.) We then send PR 100 with both commits in it. Once the PR is accepted, we can use `git tag -a` to create an annotated tag *pointing to the one commit* that has `v0.5` in `pkg/version/base.go` and push it to GitHub. (Unfortunately GitHub tags/releases are not annotated tags, so this needs to be done from a git client and pushed to GitHub using SSH.) ## Parallel Commits While we are working on releasing `v0.5`, other development takes place and other PRs get merged. For instance, in the example above, PRs 101 and 102 get merged to the master branch before the versioning PR gets merged. This is not a problem, it is only slightly inaccurate that checking out the tree at commit `012abc` or commit `345cde` or at the commit of the merges of PR 101 or 102 will yield a version of `v0.4-dev` *but* those commits are not present in `v0.5`. In that sense, there is a small window in which commits will get a `v0.4-dev` or `v0.4-N-gXXX` label and while they're indeed later than `v0.4` but they are not really before `v0.5` in that `v0.5` does not contain those commits. Unfortunately, there is not much we can do about it. On the other hand, other projects seem to live with that and it does not really become a large problem. As an example, Docker commit a327d9b91edf has a `v1.1.1-N-gXXX` label but it is not present in Docker `v1.2.0`: ``` $ git describe a327d9b91edf v1.1.1-822-ga327d9b91edf $ git log --oneline v1.2.0..a327d9b91edf a327d9b91edf Fix data space reporting from Kb/Mb to KB/MB (Non-empty output here means the commit is not present on v1.2.0.) ``` </ins>


cmds.AddCommand(NewCmdPlugin(f, in, out, err)) cmds.AddCommand(NewCmdVersion(f, out)) cmds.AddCommand(NewCmdApiVersions(f, out)) <ins> cmds.AddCommand(NewCmdApiResources(f, out)) </ins> cmds.AddCommand(NewCmdOptions(out)) return cmds


name: "TestPlugin1", inj:  injectedResult{FilterStatus: int(framework.Error)}, }, { name: "TestPlugin2", inj:  injectedResult{FilterStatus: int(framework.Error)},


Subsets:    []corev1.EndpointSubset{subset}, }, epSlice } <ins> func TestEndpointsAdapterEnsureEndpointSliceFromEndpoints(t *testing.T) { endpoints1, epSlice1 := generateEndpointsAndSlice("foo", "testing", []int{80, 443}, []string{"10.1.2.3", "10.1.2.4"}) endpoints2, epSlice2 := generateEndpointsAndSlice("foo", "testing", []int{80, 443}, []string{"10.1.2.3", "10.1.2.4", "10.1.2.5"}) testCases := map[string]struct { endpointSlicesEnabled bool expectedError         error expectedEndpointSlice *discovery.EndpointSlice endpointSlices        []*discovery.EndpointSlice namespaceParam        string endpointsParam        *corev1.Endpoints }{ "existing-endpointslice-no-change": { endpointSlicesEnabled: true, expectedError:         nil, expectedEndpointSlice: epSlice1, endpointSlices:        []*discovery.EndpointSlice{epSlice1}, namespaceParam:        "testing", endpointsParam:        endpoints1, }, "existing-endpointslice-change": { endpointSlicesEnabled: true, expectedError:         nil, expectedEndpointSlice: epSlice2, endpointSlices:        []*discovery.EndpointSlice{epSlice1}, namespaceParam:        "testing", endpointsParam:        endpoints2, }, "missing-endpointslice": { endpointSlicesEnabled: true, expectedError:         nil, expectedEndpointSlice: epSlice1, endpointSlices:        []*discovery.EndpointSlice{}, namespaceParam:        "testing", endpointsParam:        endpoints1, }, "endpointslices-disabled": { endpointSlicesEnabled: false, expectedError:         nil, expectedEndpointSlice: nil, endpointSlices:        []*discovery.EndpointSlice{}, namespaceParam:        "testing", endpointsParam:        endpoints1, }, } for name, testCase := range testCases { t.Run(name, func(t *testing.T) { client := fake.NewSimpleClientset() epAdapter := EndpointsAdapter{endpointClient: client.CoreV1()} if testCase.endpointSlicesEnabled { epAdapter.endpointSliceClient = client.DiscoveryV1alpha1() } for _, endpointSlice := range testCase.endpointSlices { _, err := client.DiscoveryV1alpha1().EndpointSlices(endpointSlice.Namespace).Create(endpointSlice) if err != nil { t.Fatalf("Error creating EndpointSlice: %v", err) } } err := epAdapter.EnsureEndpointSliceFromEndpoints(testCase.namespaceParam, testCase.endpointsParam) if !apiequality.Semantic.DeepEqual(testCase.expectedError, err) { t.Errorf("Expected error: %v, got: %v", testCase.expectedError, err) } endpointSlice, err := client.DiscoveryV1alpha1().EndpointSlices(testCase.namespaceParam).Get(testCase.endpointsParam.Name, metav1.GetOptions{}) if err != nil && !errors.IsNotFound(err) { t.Fatalf("Error getting Endpoint Slice: %v", err) } if !apiequality.Semantic.DeepEqual(endpointSlice, testCase.expectedEndpointSlice) { t.Errorf("Expected Endpoint Slice: %v, got: %v", testCase.expectedEndpointSlice, endpointSlice) } }) } } </ins>


config.CloudProviderBackoffDuration = backoffDurationDefault } <del> // Do not add master nodes to standard LB by default. if config.ExcludeMasterFromStandardLB == nil { config.ExcludeMasterFromStandardLB = &defaultExcludeMasterFromStandardLB </del> <ins> if strings.EqualFold(config.LoadBalancerSku, loadBalancerSkuStandard) { // Do not add master nodes to standard LB by default. if config.ExcludeMasterFromStandardLB == nil { config.ExcludeMasterFromStandardLB = &defaultExcludeMasterFromStandardLB } // Enable outbound SNAT by default. if config.DisableOutboundSNAT == nil { config.DisableOutboundSNAT = &defaultDisableOutboundSNAT } } else { if config.DisableOutboundSNAT != nil && *config.DisableOutboundSNAT { return nil, fmt.Errorf("disableOutboundSNAT should only set when loadBalancerSku is standard") } </ins> } azClientConfig := &azClientConfig{


} } <del> func TestValidateCustomResource(t *testing.T) { type args struct { schema apiextensions.JSONSchemaProps object interface{} </del> <ins> func stripIntOrStringType(x interface{}) interface{} { switch x := x.(type) { case map[string]interface{}: if t, found := x["type"]; found { switch t := t.(type) { case []interface{}: if len(t) == 2 && t[0] == "integer" && t[1] == "string" && x["x-kubernetes-int-or-string"] == true { delete(x, "type") } } } for k := range x { x[k] = stripIntOrStringType(x[k]) } return x case []interface{}: for i := range x { x[i] = stripIntOrStringType(x[i]) } return x default: return x </ins> } <ins> } func TestValidateCustomResource(t *testing.T) { </ins> tests := []struct { <del> name    string args    args wantErr bool </del> <ins> name           string schema         apiextensions.JSONSchemaProps objects        []interface{} failingObjects []interface{} </ins> }{ <del> // TODO: make more complete {"!nullable against non-null", args{ apiextensions.JSONSchemaProps{ </del> <ins> {name: "!nullable", schema: apiextensions.JSONSchemaProps{ </ins> Properties: map[string]apiextensions.JSONSchemaProps{ "field": { Type:     "object",


{d: 8 * 24 * time.Hour, want: "8d"}, {d: 8*24*time.Hour + 23*time.Hour, want: "8d"}, {d: 2*365*24*time.Hour - time.Millisecond, want: "729d"}, <del> {d: 2 * 365 * 24 * time.Hour, want: "2y0d"}, {d: 2*365*24*time.Hour + 23*time.Hour, want: "2y0d"}, {d: 3 * 365 * 24 * time.Hour, want: "3y0d"}, </del> <ins> {d: 2 * 365 * 24 * time.Hour, want: "2y"}, {d: 2*365*24*time.Hour + 23*time.Hour, want: "2y"}, {d: 2*365*24*time.Hour + 23*time.Hour + 59*time.Minute, want: "2y"}, {d: 2*365*24*time.Hour + 24*time.Hour - time.Millisecond, want: "2y"}, {d: 2*365*24*time.Hour + 24*time.Hour, want: "2y1d"}, {d: 3 * 365 * 24 * time.Hour, want: "3y"}, {d: 4 * 365 * 24 * time.Hour, want: "4y"}, {d: 5 * 365 * 24 * time.Hour, want: "5y"}, {d: 6 * 365 * 24 * time.Hour, want: "6y"}, {d: 7 * 365 * 24 * time.Hour, want: "7y"}, </ins> {d: 8*365*24*time.Hour - time.Millisecond, want: "7y364d"}, {d: 8 * 365 * 24 * time.Hour, want: "8y"}, {d: 8*365*24*time.Hour + 364*24*time.Hour, want: "8y"},


# Wait for last batch of jobs kube::util::wait-for-jobs || { <del> echo -e "${color_red}Some commands failed.${color_norm}" >&2 </del> <ins> code=$? echo -e "${color_red}Failed to create firewall rule.${color_norm}" >&2 exit $code </ins> } }


framework.SkipUnlessProviderIs("gke") nsFlag := fmt.Sprintf("--namespace=%v", ns) podJson := readTestFileOrDie(kubectlInPodFilename) <ins> // Replace the host path to kubectl in json podString := strings.Replace(string(podJson), "$KUBECTL_PATH", framework.TestContext.KubectlPath, 1) </ins> By("validating api verions") <del> framework.RunKubectlOrDieInput(string(podJson), "create", "-f", "-", nsFlag) </del> <ins> framework.RunKubectlOrDieInput(podString, "create", "-f", "-", nsFlag) </ins> err := wait.PollImmediate(time.Second, time.Minute, func() (bool, error) { output := framework.RunKubectlOrDie("get", "pods/kubectl-in-pod", nsFlag) if strings.Contains(output, "Running") {


podLabels := map[string]string{"name": "nginx"} replicas := 1 Logf("Creating simple deployment %s", deploymentName) <del> _, err := c.Deployments(ns).Create(newDeployment(deploymentName, replicas, podLabels, "nginx", "nginx")) </del> <ins> _, err := c.Deployments(ns).Create(newDeployment(deploymentName, replicas, podLabels, "nginx", "nginx", extensions.RollingUpdateDeploymentStrategyType)) </ins> Expect(err).NotTo(HaveOccurred()) defer func() { deployment, err := c.Deployments(ns).Get(deploymentName)


} return parameters, nil default: <ins> sort.Slice(objs, func(i, j int) bool { obj1, obj2 := objs[i].(*resourcev1alpha2.ResourceClassParameters), objs[j].(*resourcev1alpha2.ResourceClassParameters) if obj1 == nil || obj2 == nil { return false } return obj1.Name < obj2.Name }) </ins> return nil, statusError(logger, fmt.Errorf("multiple generated class parameters for %s.%s %s found: %s", class.ParametersRef.Kind, class.ParametersRef.APIGroup, klog.KRef(class.Namespace, class.ParametersRef.Name), klog.KObjSlice(objs))) } }


ExitCode: 5, }, }, <del> map[string]error{"with-reason": testErrorReason, "succeed": testErrorReason}, []api.ContainerStatus{}, map[string]api.ContainerState{ </del> <ins> reasons:     map[string]error{"with-reason": testErrorReason, "succeed": testErrorReason}, oldStatuses: []api.ContainerStatus{}, expectedState: map[string]api.ContainerState{ </ins> "without-reason": {Terminated: &api.ContainerStateTerminated{ ExitCode:    1, ContainerID: emptyContainerID,


// be sure to unset environment variable https_proxy (if exported) before testing, otherwise the testing will fail unexpectedly. func TestRoundTripSocks5AndNewConnection(t *testing.T) { <del> t.Skip("Flake https://issues.k8s.io/107708") </del> localhostPool := localhostCertPool(t) for _, redirect := range []bool{false, true} {


input           *v1.Node want            bool }{ <ins> {want: false, input: &v1.Node{}}, {want: true, input: &v1.Node{Status: v1.NodeStatus{Conditions: []v1.NodeCondition{{Type: v1.NodeReady, Status: v1.ConditionTrue}}}}}, {want: false, input: &v1.Node{Status: v1.NodeStatus{Conditions: []v1.NodeCondition{{Type: v1.NodeReady, Status: v1.ConditionFalse}}}}}, {want: true, input: &v1.Node{Spec: v1.NodeSpec{Unschedulable: true}, Status: v1.NodeStatus{Conditions: []v1.NodeCondition{{Type: v1.NodeReady, Status: v1.ConditionTrue}}}}}, </ins> {want: true, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{}}}}, {want: true, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{labelNodeRoleMaster: ""}}}}, {want: true, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{labelNodeRoleExcludeBalancer: ""}}}},


hasPVC = true pvc, err := pl.PVCLister.PersistentVolumeClaims(pod.Namespace).Get(pvcName) if err != nil { <del> // The error has already enough context ("persistentvolumeclaim "myclaim" not found") </del> <ins> // The error usually has already enough context ("persistentvolumeclaim "myclaim" not found"), // but we can do better for generic ephemeral inline volumes where that situation // is normal directly after creating a pod. if ephemeral && apierrors.IsNotFound(err) { err = fmt.Errorf("waiting for ephemeral volume controller to create the persistentvolumeclaim %q", pvcName) } </ins> return hasPVC, err }


Name: "foo", }, Data: map[string][]byte{ <del> v1.DockerConfigKey: secretDataNoEmail, </del> <ins> v1.DockerConfigJsonKey: secretDataNoEmail, </ins> }, <del> Type: v1.SecretTypeDockercfg, </del> <ins> Type: v1.SecretTypeDockerConfigJson, </ins> }, expectErr: false, },


) func (c *FakeEvictions) Evict(eviction *policy.Eviction) error { <del> action := core.GetActionImpl{} action.Verb = "post" </del> <ins> action := core.CreateActionImpl{} action.Verb = "create" </ins> action.Namespace = c.ns action.Resource = schema.GroupVersionResource{Group: "", Version: "", Resource: "pods"} action.Subresource = "eviction" <ins> action.Object = eviction </ins> _, err := c.Fake.Invokes(action, eviction) return err }


export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH} <del> go get github.com/tools/godep && godep version go get github.com/jstemmer/go-junit-report </del> <ins> retry go get github.com/tools/godep && godep version retry go get github.com/jstemmer/go-junit-report </ins> # Enable the Go race detector. export KUBE_RACE=-race


// it is not used by Convert() other than storing it in the scope. // Not safe for objects with cyclic references! func (c *Converter) Convert(src, dest interface{}, flags FieldMatchingFlags, meta *Meta) error { <ins> return c.doConversion(src, dest, flags, meta, c.convert) } // DefaultConvert will translate src to dest if it knows how. Both must be pointers. // No conversion func is used. If the default copying mechanism // doesn't work on this type pair, an error will be returned. // Read the comments on the various FieldMatchingFlags constants to understand // what the 'flags' parameter does. // 'meta' is given to allow you to pass information to conversion functions, // it is not used by DefaultConvert() other than storing it in the scope. // Not safe for objects with cyclic references! func (c *Converter) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags, meta *Meta) error { return c.doConversion(src, dest, flags, meta, c.defaultConvert) } type conversionFunc func(sv, dv reflect.Value, scope *scope) error func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags, meta *Meta, f conversionFunc) error { </ins> dv, err := EnforcePtr(dest) if err != nil { return err


FindBoundSatsified:   false, }, eventReason: "FailedScheduling", <del> expectError: makePredicateError("1 VolumeBindingNoMatch, 1 VolumeNodeAffinityConflict"), </del> <ins> expectError: makePredicateError("1 node(s) didn't find available persistent volumes to bind, 1 node(s) had volume node affinity conflict"), </ins> }, "unbound,found-matches": { volumeBinderConfig: &persistentvolume.FakeVolumeBinderConfig{


<del> /* Copyright 2022 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 plugin import ( "context" "errors" "fmt" "net" "sync" "time" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials/insecure" utilversion "k8s.io/apimachinery/pkg/util/version" "k8s.io/klog/v2" drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha4" ) // 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") } existingPlugin := draPlugins.get(pluginName) if existingPlugin == nil { return nil, fmt.Errorf("plugin name %s not found in the list of registered DRA plugins", pluginName) } return existingPlugin, nil } type Plugin struct { backgroundCtx context.Context cancel        func(cause error) mutex                   sync.Mutex conn                    *grpc.ClientConn endpoint                string highestSupportedVersion *utilversion.Version clientCallTimeout       time.Duration } func (p *Plugin) getOrCreateGRPCConn() (*grpc.ClientConn, error) { p.mutex.Lock() defer p.mutex.Unlock() if p.conn != nil { return p.conn, nil } ctx := p.backgroundCtx logger := klog.FromContext(ctx) 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) }), ) if err != nil { return nil, err } ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() if ok := conn.WaitForStateChange(ctx, connectivity.Connecting); !ok { return nil, errors.New("timed out waiting for gRPC connection to be ready") } p.conn = conn return p.conn, nil } 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) conn, err := p.getOrCreateGRPCConn() if err != nil { return nil, err } ctx, cancel := context.WithTimeout(ctx, p.clientCallTimeout) defer cancel() 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 } 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() if err != nil { return nil, err } 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 } </del>


// EnvVarSource represents a source for the value of an EnvVar. message EnvVarSource { <del> // Selects a field of the pod: supports metadata.name, metadata.namespace, metadata.labels, metadata.annotations, </del> <ins> // Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`, </ins> // spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. // +optional optional ObjectFieldSelector fieldRef = 1;


allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&obj.ObjectMeta, false, ValidateThirdPartyResourceName, field.NewPath("metadata"))...) versions := sets.String{} <ins> if len(obj.Versions) == 0 { allErrs = append(allErrs, field.Required(field.NewPath("versions"), "must specify at least one version")) } </ins> for ix := range obj.Versions { version := &obj.Versions[ix] if len(version.Name) == 0 {


} else if exists { glog.Infof("Deleting old LB for previously uncached service %s whose endpoint %s doesn't match the service's desired IPs %v", namespacedName, endpoint, service.Spec.PublicIPs) <del> if err := s.ensureLBDeleted(service); err != nil { </del> <ins> if err := s.balancer.EnsureTCPLoadBalancerDeleted(s.loadBalancerName(service), s.zone.Region); err != nil { </ins> return err, retryable } }


}, "../examples/openshift-origin": { "openshift-origin-namespace": &api.Namespace{}, <del> "openshift-controller":       &api.ReplicationController{}, </del> <ins> "openshift-controller":       &extensions.Deployment{}, </ins> "openshift-service":          &api.Service{}, <del> "etcd-controller":            &api.ReplicationController{}, </del> <ins> "etcd-controller":            &extensions.Deployment{}, </ins> "etcd-service":               &api.Service{}, <del> "etcd-discovery-controller":  &api.ReplicationController{}, </del> <ins> "etcd-discovery-controller":  &extensions.Deployment{}, </ins> "etcd-discovery-service":     &api.Service{}, "secret":                     nil, },


return time.Since(start).Seconds() } <del> func newPodAndContainerCollector(containerCache kubecontainer.RuntimeCache) *podAndContainerCollector { return &podAndContainerCollector{ containerCache: containerCache, } } // Custom collector for current pod and container counts. type podAndContainerCollector struct { // Cache for accessing information about running containers. containerCache kubecontainer.RuntimeCache } // TODO(vmarmol): Split by source? var ( runningPodCountDesc = prometheus.NewDesc( prometheus.BuildFQName("", KubeletSubsystem, "running_pod_count"), "Number of pods currently running", nil, nil) runningContainerCountDesc = prometheus.NewDesc( prometheus.BuildFQName("", KubeletSubsystem, "running_container_count"), "Number of containers currently running", nil, nil) ) // Describe implements Prometheus' Describe method from the Collector interface. It sends all // available descriptions to the provided channel and retunrs once the last description has been sent. func (pc *podAndContainerCollector) Describe(ch chan<- *prometheus.Desc) { ch <- runningPodCountDesc ch <- runningContainerCountDesc } // Collect implements Prometheus' Collect method from the Collector interface. It's called by the Prometheus // registry when collecting metrics. func (pc *podAndContainerCollector) Collect(ch chan<- prometheus.Metric) { runningPods, err := pc.containerCache.GetPods() if err != nil { klog.Warningf("Failed to get running container information while collecting metrics: %v", err) return } runningContainers := 0 for _, p := range runningPods { runningContainers += len(p.Containers) } ch <- prometheus.MustNewConstMetric( runningPodCountDesc, prometheus.GaugeValue, float64(len(runningPods))) ch <- prometheus.MustNewConstMetric( runningContainerCountDesc, prometheus.GaugeValue, float64(runningContainers)) } </del> const configMapAPIPathFmt = "/api/v1/namespaces/%s/configmaps/%s" func configLabels(source *corev1.NodeConfigSource) (map[string]string, error) {


} for n := range visitedNamespaces { <ins> if len(o.Namespace) != 0 && n != o.Namespace { continue } </ins> for _, m := range namespacedRESTMappings { if err := p.prune(n, m); err != nil { return fmt.Errorf("error pruning namespaced object %v: %v", m.GroupVersionKind, err)


}, { "ImportPath": "github.com/evanphx/json-patch", <del> "Rev": "ed7cfbae1fffc071f71e068df27bf4f0521402d8" </del> <ins> "Rev": "94e38aa1586e8a6c8a75770bddf5ff84c48a106b" </ins> }, { "ImportPath": "github.com/exponent-io/jsonpath",


if (endpoints.subsets != null && !endpoints.subsets.isEmpty()){ for (Subset subset : endpoints.subsets) { for (Address address : subset.addresses) { <del> list.add(InetAddress.getByName(address.IP)); </del> <ins> list.add(InetAddress.getByName(address.ip)); </ins> } } } <del> } </del> <ins> logger.info("Available endpoints: " + list); } else { logger.warn("Endpoints are not available"); } </ins> } catch (IOException | NoSuchAlgorithmException | KeyManagementException ex) { logger.warn("Request to kubernetes apiserver failed", ex); }


// +k8s:deepcopy-gen=package <del> package testing </del> <ins> package testing // import "k8s.io/apimachinery/pkg/runtime/serializer/testing" </ins>


"k8s.io/api/core/v1" settings "k8s.io/api/settings/v1alpha1" <ins> "k8s.io/apimachinery/pkg/api/errors" </ins> metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/watch"


testCase.modifyRest(storage) } <del> err := storage.tryDefaultValidateServiceClusterIPFields(&testCase.svc) </del> <ins> err := storage.tryDefaultValidateServiceClusterIPFields(testCase.oldSvc, &testCase.svc) </ins> if err != nil && !testCase.expectError { t.Fatalf("error %v was not expected", err) }


type multiGroupVersioner struct { target             schema.GroupVersion acceptedGroupKinds []schema.GroupKind <ins> coerce             bool </ins> } // NewMultiGroupVersioner returns the provided group version for any kind that matches one of the provided group kinds.


// while making decisions. BalanceAttachedNodeVolumes featuregate.Feature = "BalanceAttachedNodeVolumes" <del> // owner: @kevtaylor // alpha: v1.14 // beta: v1.15 // ga: v1.17 // // Allow subpath environment variable substitution // Only applicable if the VolumeSubpath feature is also enabled VolumeSubpathEnvExpansion featuregate.Feature = "VolumeSubpathEnvExpansion" </del> // owner: @vladimirvivien // alpha: v1.11 // beta:  v1.14


legacyregistry.MustRegister(CgroupManagerDuration) legacyregistry.MustRegister(PodWorkerStartDuration) legacyregistry.MustRegister(ContainersPerPodCount) <del> legacyregistry.RawMustRegister(newPodAndContainerCollector(containerCache)) </del> legacyregistry.MustRegister(PLEGRelistDuration) legacyregistry.MustRegister(PLEGDiscardEvents) legacyregistry.MustRegister(PLEGRelistInterval)


}, } podWithHook := getPodWithHook("pod-with-prestop-https-hook", imageutils.GetPauseImageName(), lifecycle) <ins> // make sure we spawn the test pod on the same node as the webserver. nodeSelection := e2epod.NodeSelection{} e2epod.SetAffinity(&nodeSelection, targetNode) e2epod.SetNodeSelection(&podWithHook.Spec, nodeSelection) </ins> testPodWithHook(podWithHook) }) })


func main() { klog.InitFlags(nil) if err := app.Run(); err != nil { <del> fmt.Fprintf(os.Stderr, "error: %vn", err) </del> os.Exit(1) } <del> os.Exit(0) </del> }


glog.V(4).Infof("Pod %s deleted.", pod.Name) if d := dc.getDeploymentForPod(pod); d != nil && d.Spec.Strategy.Type == extensions.RecreateDeploymentStrategyType { // Sync if this Deployment now has no more Pods. <del> rsList, err := dc.getReplicaSetsForDeployment(d) </del> <ins> rsList, err := util.ListReplicaSets(d, util.RsListFromClient(dc.client)) </ins> if err != nil { return }


namespace := nsObj.(*api.Namespace) // upon first request to delete, we switch the phase to start namespace termination <del> if namespace.DeletionTimestamp == nil { </del> <ins> if namespace.DeletionTimestamp.IsZero() { </ins> now := util.Now() namespace.DeletionTimestamp = &now namespace.Status.Phase = api.NamespaceTerminating


<del> 2.50 </del> <ins> 2.51 </ins>


} output, err := json.Marshal(agg) require.NoError(t, err) <del> // Content-type is "aggregated" discovery format. w.Header().Set("Content-Type", AcceptV2Beta1) </del> <ins> // Content-Type is "aggregated" discovery format. Add extra parameter // to ensure we are resilient to these extra parameters. w.Header().Set("Content-Type", AcceptV2Beta1+"; charset=utf-8") </ins> w.WriteHeader(http.StatusOK) w.Write(output) }))


expectedErrMsg:      fmt.Errorf("getError"), }, { <del> name:                "NodeAddresses should report error if VMSS instanceID is invalid", nodeName:            "vm123456", metadataName:        "vmss_$123", vmType:              vmTypeVMSS, useInstanceMetadata: true, expectedErrMsg:      fmt.Errorf("failed to parse VMSS instanceID %q: strconv.ParseInt: parsing %q: invalid syntax", "$123", "$123"), }, { </del> name:                "NodeAddresses should report error if cloud.vmSet is nil", nodeName:            "vm1", vmType:              vmTypeStandard,


// GetOldReplicaSets returns the old replica sets targeted by the given Deployment; get PodList and ReplicaSetList from client interface. // Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets. func GetOldReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) { <del> rsList, err := ListReplicaSets(deployment, rsListFromClient(c)) </del> <ins> rsList, err := ListReplicaSets(deployment, RsListFromClient(c)) </ins> if err != nil { return nil, nil, err }


klog.V(3).Infof("Pod %q is terminated, but some containers have not been cleaned up: %s", format.Pod(pod), statusStr) return false } <del> // pod's sandboxes should be deleted if len(runtimeStatus.SandboxStatuses) > 0 { var sandboxStr string for _, sandbox := range runtimeStatus.SandboxStatuses { sandboxStr += fmt.Sprintf("%+v ", *sandbox) } klog.V(3).Infof("Pod %q is terminated, but some pod sandboxes have not been cleaned up: %s", format.Pod(pod), sandboxStr) return false } </del> if kl.podVolumesExist(pod.UID) && !kl.keepTerminatedPodVolumes { // We shouldn't delete pods whose volumes have not been cleaned up if we are not keeping terminated pod volumes klog.V(3).Infof("Pod %q is terminated, but some volumes have not been cleaned up", format.Pod(pod))


} for key, cluster := range config.Clusters { if len(cluster.CertificateAuthorityData) > 0 { <del> cluster.CertificateAuthorityData = redactedBytes </del> <ins> cluster.CertificateAuthorityData = dataOmittedBytes </ins> } config.Clusters[key] = cluster }


} return result, autorest.DetailedError{ StatusCode: http.StatusNotFound, <del> Message:    "Not such PIP", </del> <ins> Message:    "No such PIP", } } func (fAPC *fakeAzurePIPClient) GetVirtualMachineScaleSetPublicIPAddress(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string, publicIPAddressName string, expand string) (result network.PublicIPAddress, err error) { fAPC.mutex.Lock() defer fAPC.mutex.Unlock() if _, ok := fAPC.FakeStore[resourceGroupName]; ok { if entity, ok := fAPC.FakeStore[resourceGroupName][publicIPAddressName]; ok { return entity, nil } } return result, autorest.DetailedError{ StatusCode: http.StatusNotFound, Message:    "No such PIP", </ins> } }


oldPVC.Status.Conditions = nil newPVC.Status.Conditions = nil <ins> // TODO(apelisse): We don't have a good mechanism to // verify that only the things that should have changed // have changed. Ignore it for now. oldPVC.ObjectMeta.ManagedFields = nil newPVC.ObjectMeta.ManagedFields = nil </ins> // ensure no metadata changed. nodes should not be able to relabel, add finalizers/owners, etc if !apiequality.Semantic.DeepEqual(oldPVC, newPVC) { return admission.NewForbidden(a, fmt.Errorf("node %q is not allowed to update fields other than status.capacity and status.conditions: %v", nodeName, diff.ObjectReflectDiff(oldPVC, newPVC)))


//FilenameParam(enforceNamespace, o.Filenames...). FilenameParam(enforceNamespace, &o.FilenameOptions). Flatten() <del> if !o.Local { </del> <ins> if !cmdutil.GetDryRunFlag(cmd) { </ins> builder = builder. SelectorParam(o.Selector). ResourceTypeOrNameArgs(o.All, args...).


// pod setup jobKeyForget  bool restartCounts []int32 <ins> podPhase      v1.PodPhase </ins> // expectations expectedActive          int32


roleRef: kind: Role name: external-attacher-cfg <ins> apiGroup: rbac.authorization.k8s.io </ins>


// Create the controller and run it until we close stop. stop := make(chan struct{}) <ins> defer close(stop) </ins> go framework.New(cfg).Run(stop) // Let's add a few objects to the source. <del> for _, name := range []string{"a-hello", "b-controller", "c-framework"} { </del> <ins> testIDs := []string{"a-hello", "b-controller", "c-framework"} for _, name := range testIDs { </ins> // Note that these pods are not valid-- the fake source doesn't // call validation or anything. source.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: name}}) } // Let's wait for the controller to process the things we just added. <del> time.Sleep(500 * time.Millisecond) close(stop) </del> <ins> outputSet := util.StringSet{} for i := 0; i < len(testIDs); i++ { outputSet.Insert(<-deletionCounter) } </ins> <del> outputSetLock.Lock() </del> for _, key := range outputSet.List() { fmt.Println(key) }


"bytes" "fmt" "reflect" <ins> "regexp" </ins> "strings" "testing" "time"


// ValidateCSIDriverUpdate validates a CSIDriver. func ValidateCSIDriverUpdate(new, old *storage.CSIDriver) field.ErrorList { allErrs := apivalidation.ValidateObjectMetaUpdate(&new.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata")) <ins> allErrs = append(allErrs, validateCSIDriverSpec(&new.Spec, field.NewPath("spec"))...) </ins> // immutable fields should not be mutated. allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.AttachRequired, old.Spec.AttachRequired, field.NewPath("spec", "attachedRequired"))...) allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.FSGroupPolicy, old.Spec.FSGroupPolicy, field.NewPath("spec", "fsGroupPolicy"))...) allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.PodInfoOnMount, old.Spec.PodInfoOnMount, field.NewPath("spec", "podInfoOnMount"))...) allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.VolumeLifecycleModes, old.Spec.VolumeLifecycleModes, field.NewPath("spec", "volumeLifecycleModes"))...) <del> allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.StorageCapacity, old.Spec.StorageCapacity, field.NewPath("spec", "storageCapacity"))...) </del> allErrs = append(allErrs, validateTokenRequests(new.Spec.TokenRequests, field.NewPath("spec", "tokenRequests"))...) return allErrs


<ins> apiVersion: v1beta3 kind: LimitRange metadata: name: limits spec: limits: - default: cpu: 100m memory: 512Mi type: Container </ins>


"github.com/google/gofuzz" ) <ins> func TestConverter_DefaultConvert(t *testing.T) { type A struct { Foo string Baz int } type B struct { Bar string Baz int } c := NewConverter() c.Debug = t c.NameFunc = func(t reflect.Type) string { return "MyType" } // Ensure conversion funcs can call DefaultConvert to get default behavior, // then fixup remaining fields manually err := c.Register(func(in *A, out *B, s Scope) error { if err := s.DefaultConvert(in, out, IgnoreMissingFields); err != nil { return err } out.Bar = in.Foo return nil }) if err != nil { t.Fatalf("unexpected error %v", err) } x := A{"hello, intrepid test reader!", 3} y := B{} err = c.Convert(&x, &y, 0, nil) if err != nil { t.Fatalf("unexpected error %v", err) } if e, a := x.Foo, y.Bar; e != a { t.Errorf("expected %v, got %v", e, a) } if e, a := x.Baz, y.Baz; e != a { t.Errorf("expected %v, got %v", e, a) } } </ins> func TestConverter_CallsRegisteredFunctions(t *testing.T) { type A struct { Foo string


package remote import ( <ins> "os" </ins> "testing" "time"


"testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" <ins> "github.com/GoogleCloudPlatform/kubernetes/pkg/util" </ins> ) func TestNamespaceStrategy(t *testing.T) {


"":            "ServicePort contains information on service's port.", "name":        "The name of this port within the service. This must be a DNS_LABEL. All ports within a ServiceSpec must have unique names. When considering the endpoints for a Service, this must match the 'name' field in the EndpointPort. Optional if only one ServicePort is defined on this service.", "protocol":    "The IP protocol for this port. Supports "TCP", "UDP", and "SCTP". Default is TCP.", <del> "appProtocol": "The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and http://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol.", </del> <ins> "appProtocol": "The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol.", </ins> "port":        "The port that will be exposed by this service.", "targetPort":  "Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of the 'port' field is used (an identity map). This field is ignored for services with clusterIP=None, and should be omitted or set equal to the 'port' field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service", "nodePort":    "The port on each node on which this service is exposed when type is NodePort or LoadBalancer.  Usually assigned by the system. If a value is specified, in-range, and not in use it will be used, otherwise the operation will fail.  If not specified, a port will be allocated if this Service requires one.  If this field is specified when creating a Service which does not need it, creation will fail. This field will be wiped when updating a Service to no longer need it (e.g. changing type from NodePort to ClusterIP). More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport",


errCh.SendErrorWithCancel(err, cancel) return } <ins> klog.V(2).InfoS("Preemptor Pod preempted victim Pod", "preemptor", klog.KObj(pod), "victim", klog.KObj(victim), "node", c.Name()) </ins> } fh.EventRecorder().Eventf(victim, pod, v1.EventTypeNormal, "Preempted", "Preempting", "Preempted by a pod on node %v", c.Name()) }


} interval := time.NewTicker(time.Millisecond * 500) defer interval.Stop() <del> done := make(chan bool, 1) </del> <ins> done := make(chan bool) </ins> go func() { time.Sleep(time.Minute * 2) <del> done <- true </del> <ins> close(done) </ins> }() for { select {


CLUSTER_DIR?=$(shell pwd)/../../../cluster/ <del> BASEIMAGE=debian:stable-slim TEMP_DIR:=$(shell mktemp -d -t conformanceXXXXXX) </del> <ins> # This is defined in root Makefile, but some build contexts do not refer to them KUBE_BASE_IMAGE_REGISTRY?=k8s.gcr.io ifeq ($(ARCH),amd64) BASEIMAGE?=${KUBE_BASE_IMAGE_REGISTRY}/build-image/debian-base:v2.1.3 else BASEIMAGE?=${KUBE_BASE_IMAGE_REGISTRY}/build-image/debian-base-${ARCH}:v2.1.3 endif RUNNERIMAGE?=gcr.io/distroless/base:latest TEMP_DIR:=$(shell mktemp -d -t conformance-XXXXXX) </ins> all: build


"command":                  "Entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", "args":                     "Arguments to the entrypoint. The container image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", "workingDir":               "Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.", <del> "ports":                    "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 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. Cannot be updated.", </del> <ins> "ports":                    "List of ports to expose from the container. Not specifying a port here 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. Modifying this array with strategic merge patch may corrupt the data. For more information See https://github.com/kubernetes/kubernetes/issues/108255. Cannot be updated.", </ins> "envFrom":                  "List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", "env":                      "List of environment variables to set in the container. Cannot be updated.", "resources":                "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/",


} } } <ins> // Providing HardPodAffinitySymmetricWeight in the policy config is the new and preferred way of providing the value. // Give it higher precedence than scheduler CLI configuration when it is provided. if policy.HardPodAffinitySymmetricWeight != 0 { f.hardPodAffinitySymmetricWeight = policy.HardPodAffinitySymmetricWeight } </ins> return f.CreateFromKeys(predicateKeys, priorityKeys, extenders) }


"time" "github.com/golang/glog" <del> "github.com/golang/protobuf/proto" </del> cadvisorfs "github.com/google/cadvisor/fs" cadvisorapiv2 "github.com/google/cadvisor/info/v2"


runtimeapi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" <ins> "k8s.io/kubernetes/pkg/kubelet/dockertools" </ins> "k8s.io/kubernetes/pkg/kubelet/qos" "k8s.io/kubernetes/pkg/kubelet/types" )


capabilities.Setup(kcfg.AllowPrivileged, privilegedSources, 0) credentialprovider.SetPreferredDockercfgPath(kcfg.RootDirectory) <ins> glog.V(2).Infof("Using root directory: %v", kcfg.RootDirectory) </ins> builder := kcfg.Builder if builder == nil {


cluster/addons/fluentd-elasticsearch/es-image cluster/images/etcd/attachlease <ins> cluster/images/etcd/rollback </ins> cmd/gendocs cmd/genkubedocs cmd/genman


return "" } <ins> func podID(element interface{}) string { el := element.(*model.Sample) return fmt.Sprintf("%s::%s", el.Metric["namespace"], el.Metric["pod"]) } </ins> func containerID(element interface{}) string { el := element.(*model.Sample) return fmt.Sprintf("%s::%s::%s", el.Metric["namespace"], el.Metric["pod"], el.Metric["container"])


if err != nil { return err } <del> stat, err := framework.RunKubectl(namespace, "create", "-f", adapterURL) </del> <ins> stat, err := framework.RunKubectl("", "create", "-f", adapterURL) </ins> framework.Logf(stat) return err } <del> func createClusterAdminBinding(namespace string) error { </del> <ins> func createClusterAdminBinding() error { </ins> stdout, stderr, err := framework.RunCmd("gcloud", "config", "get-value", "core/account") if err != nil { framework.Logf(stderr)


nominatedPodToNode: make(map[ktypes.UID]string), } } <ins> // MakeNextPodFunc returns a function to retrieve the next pod from a given // scheduling queue func MakeNextPodFunc(queue SchedulingQueue) func() *v1.Pod { return func() *v1.Pod { pod, err := queue.Pop() if err == nil { klog.V(4).Infof("About to try and schedule pod %v/%v", pod.Namespace, pod.Name) return pod } klog.Errorf("Error while retrieving next pod from scheduling queue: %v", err) return nil } } </ins>


} t.Logf("rs._internal.apps -> rs.v1.apps") <del> data, err := runtime.Encode(extGroup.Codec(), rs) </del> <ins> data, err := runtime.Encode(extCodec, rs) </ins> if err != nil { t.Fatalf("unexpected encoding error: %v", err) }


return volumetypes.NewOperationContext(eventErr, detailedErr, migrated) } <del> klog.Infof(deviceToDetach.GenerateMsgDetailed("UnmountDevice succeeded", "")) </del> <ins> klog.Info(deviceToDetach.GenerateMsgDetailed("UnmountDevice succeeded", "")) </ins> // Update actual state of world markDeviceUnmountedErr := actualStateOfWorld.MarkDeviceAsUnmounted(


return types.NewErr("composited variable %q fails to compile: %v", a.name, a.result.Error) } <del> v, details, err := a.result.Program.Eval(a.activation) </del> <ins> v, details, err := a.result.Program.ContextEval(a.context, a.activation) </ins> if details == nil { return types.NewErr("unable to get evaluation details of variable %q", a.name) }


}, }, Command: []string{"/bin/sh"}, <del> Args:    []string{"-c", "python ./data_download.py && time -p python ./wide_deep.py --model_type=wide_deep --train_epochs=300 --epochs_between_evals=300 --batch_size=32561"}, </del> <ins> Args:    []string{"-c", "time -p python ./wide_deep.py --model_type=wide_deep --train_epochs=300 --epochs_between_evals=300 --batch_size=32561"}, </ins> } containers = append(containers, ctn)


serviceLister:                           serviceLister, serviceHasSynced:                        serviceHasSynced, nodeLister:                              nodeLister, <ins> nodeHasSynced:                           nodeHasSynced, </ins> masterServiceNamespace:                  masterServiceNamespace, streamingConnectionIdleTimeout:          kubeCfg.StreamingConnectionIdleTimeout.Duration, recorder:                                kubeDeps.Recorder,


# Post-condition: Only the default kubernetes services exist kube::test::get_object_assert services "{{range.items}}{{$id_field}}:{{end}}" 'kubernetes:' <ins> ### Create deployent and service # Pre-condition: no deployment exists kube::test::wait_object_assert deployment "{{range.items}}{{$id_field}}:{{end}}" '' # Command kubectl run testmetadata --image=nginx --replicas=2 --port=80 --expose --service-overrides='{ "metadata": { "annotations": { "zone-context": "home" } } } ' # Check result kube::test::get_object_assert deployment "{{range.items}}{{$id_field}}:{{end}}" 'testmetadata:' kube::test::get_object_assert 'service testmetadata' "{{.metadata.annotations}}" "map[zone-context:home]" ### Expose deployment as a new service # Command kubectl expose deployment testmetadata  --port=1000 --target-port=80 --type=NodePort --name=exposemetadata --overrides='{ "metadata": { "annotations": { "zone-context": "work" } } } ' # Check result kube::test::get_object_assert 'service exposemetadata' "{{.metadata.annotations}}" "map[zone-context:work]" # Clean-Up # Command kubectl delete service exposemetadata testmetadata "${kube_flags[@]}" if [[ "${WAIT_FOR_DELETION:-}" == "true" ]]; then kube::test::wait_object_assert services "{{range.items}}{{$id_field}}:{{end}}" 'kubernetes:' fi kubectl delete deployment testmetadata "${kube_flags[@]}" if [[ "${WAIT_FOR_DELETION:-}" == "true" ]]; then kube::test::wait_object_assert deployment "{{range.items}}{{$id_field}}:{{end}}" '' fi </ins> set +o nounset set +o errexit }


} output, err := json.Marshal(agg) require.NoError(t, err) <del> // Content-type is "aggregated" discovery format. w.Header().Set("Content-Type", AcceptV2Beta1) </del> <ins> // Content-type is "aggregated" discovery format. Add extra parameter // to ensure we are resilient to these extra parameters. w.Header().Set("Content-Type", AcceptV2Beta1+"; charset=utf-8") </ins> w.WriteHeader(status) w.Write(output) }))


if kl.kubeClient == nil { return kl.initialNode(context.TODO()) } <ins> // if we have a valid kube client, we wait for initial lister to sync if !kl.nodeHasSynced() { err := wait.PollImmediate(time.Second, maxWaitForAPIServerSync, func() (bool, error) { return kl.nodeHasSynced(), nil }) if err != nil { return nil, fmt.Errorf("nodes have not yet been read at least once, cannot construct node object") } } </ins> return kl.nodeLister.Get(string(kl.nodeName)) }


for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.LoadBalancerIPMode, tc.ipModeEnabled)() <del> s := core.LoadBalancerStatus{} tc.tweakLBStatus(&s) errs := ValidateLoadBalancerStatus(&s, field.NewPath("status")) </del> <ins> defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.AllowServiceLBStatusOnNonLB, tc.nonLBAllowed)() status := core.LoadBalancerStatus{} tc.tweakLBStatus(&status) spec := core.ServiceSpec{Type: core.ServiceTypeLoadBalancer} if tc.tweakSvcSpec != nil { tc.tweakSvcSpec(&spec) } errs := ValidateLoadBalancerStatus(&status, field.NewPath("status"), &spec) </ins> if len(errs) != tc.numErrs { t.Errorf("Unexpected error list for case %q(expected:%v got %v) - Errors:n %v", tc.name, tc.numErrs, len(errs), errs.ToAggregate()) }


expectError: false, }, { <del> name: "subpath-mounting-unix-socket", </del> <ins> name: "mount-unix-socket", </ins> prepare: func(base string) ([]string, string, string, error) { volpath, subpathMount := getTestPaths(base) mounts := []string{subpathMount}


<ins> # Rollback workflow Build it in this directory. Make sure you have etcd dependency ready. Last time we use etcd v3.0.7. ``` $ go build . ``` Run it: ``` $ ./rollback2 --data-dir $ETCD_DATA_DIR --ttl 1h ``` This will rollback KV pairs from v3 into v2. If a key was attached to a lease before, it will be created with given TTL (default to 1h). On success, it will print at the end: ``` Finished successfully ``` Repeat this on all etcd members. You can do simple check on keys (if any exists): ``` etcdctl ls / ``` Important Note ------ This tool isn't recommended to use if any problem comes up in etcd3 backend. Please report bugs and we will fix it soon. If it's still preferred to run this tool, please backup all your data beforehand. This tool will also back up datadir to same path with ".rollback.backup" suffix. Caveats: - The tool doesn't preserve versions of keys. - If any v2 data exists before rollback, they will be wiped out. - v3 data only exists in the backup after successful rollback. [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/images/etcd/rollback/README.md?pixel)]() </ins>  No newline at end of file


return nil case watch.Error: <del> watcher.Stop() watcherClosed = true // start another cycle return c.waitForVolumeDetachmentInternal(volumeHandle, attachID, timer, timeout) </del> <ins> klog.Warningf("waitForVolumeDetachmentInternal received watch error: %v", event) </ins> } case <-timer.C:


return utilfile.FileExists(pathname) } <ins> func (mounter *Mounter) EvalHostSymlinks(pathname string) (string, error) { return filepath.EvalSymlinks(pathname) } </ins> // formatAndMount uses unix utils to format and mount the given disk func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, fstype string, options []string) error { readOnly := false


`, inhibitDelayMax.Seconds()) logindOverridePath := filepath.Join(logindConfigDirectory, kubeletLogindConf) <del> if err := ioutil.WriteFile(logindOverridePath, []byte(inhibitOverride), 0755); err != nil { </del> <ins> if err := ioutil.WriteFile(logindOverridePath, []byte(inhibitOverride), 0644); err != nil { </ins> return fmt.Errorf("failed writing logind shutdown inhibit override file %v: %v", logindOverridePath, err) }


kubectl get services "${kube_flags[@]}" kubectl get services "service-${version}-test" "${kube_flags[@]}" kubectl delete service frontend "${kube_flags[@]}" <ins> servicesbefore="$(kubectl get services  -o template -t "{{ len .items }}" "${kube_flags[@]}")" kubectl create -f examples/guestbook/frontend-service.json "${kube_flags[@]}" kubectl create -f examples/guestbook/redis-slave-service.json "${kube_flags[@]}" kubectl delete services frontend redisslave # delete multiple services at once servicesafter="$(kubectl get services  -o template -t "{{ len .items }}" "${kube_flags[@]}")" [ "$((${servicesafter} - ${servicesbefore}))" -eq 0 ] </ins> kube::log::status "Testing kubectl(${version}:replicationcontrollers)" kubectl get replicationcontrollers "${kube_flags[@]}"


} func getFitPredicateFunctions(names sets.String, args PluginFactoryArgs) (map[string]predicates.FitPredicate, error) { <del> schedulerFactoryMutex.Lock() defer schedulerFactoryMutex.Unlock() </del> <ins> schedulerFactoryMutex.RLock() defer schedulerFactoryMutex.RUnlock() </ins> fitPredicates := map[string]predicates.FitPredicate{} for _, name := range names.List() {


func (b *Builder) ResourceTypeAndNameArgs(args ...string) *Builder { switch len(args) { case 2: <del> b.name = args[1] </del> <ins> b.names = append(b.names, args[1]) </ins> b.ResourceTypes(SplitResourceArgument(args[0])...) case 0: default: