jiebi/CodeConvo huggingface dataset:
namespace quota. The creation MUST fail release: v1.15 file: test/e2e/apps/rc.go <ins> - testname: Replication Controller, lifecycle codename: '[sig-apps] ReplicationController should test the lifecycle of a ReplicationController [Conformance]' description: A Replication Controller (RC) is created, read, patched, and deleted with verification. release: v1.20 file: test/e2e/apps/rc.go </ins> - testname: StatefulSet, Burst Scaling codename: '[sig-apps] StatefulSet [k8s.io] Basic StatefulSet functionality [StatefulSetBasic] Burst scaling should run to completion even with unhealthy pods [Slow] [Conformance]'
testRCReleaseControlledNotMatching(f) }) <del> ginkgo.It("[Flaky] should test the lifecycle of a ReplicationController", func() { </del> <ins> /* Release: v1.20 Testname: Replication Controller, lifecycle Description: A Replication Controller (RC) is created, read, patched, and deleted with verification. */ framework.ConformanceIt("should test the lifecycle of a ReplicationController", func() { </ins> testRcName := "rc-test" testRcNamespace := ns testRcInitialReplicaCount := int32(1)
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/uuid" <ins> "k8s.io/apimachinery/pkg/util/wait" </ins> "k8s.io/kubernetes/test/e2e/framework" <ins> imageutils "k8s.io/kubernetes/test/utils/image" "time" </ins> "github.com/onsi/ginkgo" ) <ins> const ( podTemplateRetryPeriod  = 1 * time.Second podTemplateRetryTimeout = 1 * time.Minute ) </ins> var _ = ginkgo.Describe("[sig-node] PodTemplates", func() { f := framework.NewDefaultFramework("podtemplate") /*
framework.ExpectNoError(err, "failed to list PodTemplate") framework.ExpectEqual(len(podTemplateList.Items), 0, "PodTemplate list returned items, failed to delete PodTemplate") }) <ins> ginkgo.It("should delete a collection of pod templates", func() { podTemplateNames := []string{"test-podtemplate-1", "test-podtemplate-2", "test-podtemplate-3"} ginkgo.By("Create set of pod templates") // create a set of pod templates in test namespace for _, podTemplateName := range podTemplateNames { _, err := f.ClientSet.CoreV1().PodTemplates(f.Namespace.Name).Create(context.TODO(), &v1.PodTemplate{ ObjectMeta: metav1.ObjectMeta{ Name:   podTemplateName, Labels: map[string]string{"podtemplate-set": "true"}, }, Template: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ {Name: "token-test", Image: imageutils.GetE2EImage(imageutils.Agnhost)}, }, }, }, }, metav1.CreateOptions{}) framework.ExpectNoError(err, "failed to create pod template") framework.Logf("created %v", podTemplateName) } ginkgo.By("get a list of pod templates with a label in the current namespace") // get a list of pod templates podTemplateList, err := f.ClientSet.CoreV1().PodTemplates(f.Namespace.Name).List(context.TODO(), metav1.ListOptions{ LabelSelector: "podtemplate-set=true", }) framework.ExpectNoError(err, "failed to get a list of pod templates") framework.ExpectEqual(len(podTemplateList.Items), len(podTemplateNames), "looking for expected number of pod templates") ginkgo.By("delete collection of pod templates") // delete collection framework.Logf("requesting DeleteCollection of pod templates") err = f.ClientSet.CoreV1().PodTemplates(f.Namespace.Name).DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{ LabelSelector: "podtemplate-set=true"}) framework.ExpectNoError(err, "failed to delete all pod templates") ginkgo.By("check that the list of pod templates matches the requested quantity") err = wait.PollImmediate(podTemplateRetryPeriod, podTemplateRetryTimeout, checkPodTemplateListQuantity(f, "podtemplate-set=true", 0)) framework.ExpectNoError(err, "failed to count required pod templates") }) </ins> }) <ins> func checkPodTemplateListQuantity(f *framework.Framework, label string, quantity int) func() (bool, error) { return func() (bool, error) { var err error framework.Logf("requesting list of pod templates to confirm quantity") list, err := f.ClientSet.CoreV1().PodTemplates(f.Namespace.Name).List(context.TODO(), metav1.ListOptions{ LabelSelector: label}) if err != nil { return false, err } if len(list.Items) != quantity { return false, err } return true, nil } } </ins>
visible at runtime in the container. release: v1.9 file: test/e2e/common/downward_api.go <ins> - testname: PodTemplate, delete a collection codename: '[sig-node] PodTemplates should delete a collection of pod templates [Conformance]' description: A set of Pod Templates is created with a label selector which MUST be found when listed. The set of Pod Templates is deleted and MUST NOT show up when listed by its label selector. release: v1.19 file: test/e2e/common/podtemplates.go </ins> - testname: PodTemplate lifecycle codename: '[sig-node] PodTemplates should run the lifecycle of PodTemplates [Conformance]' description: Attempt to create a PodTemplate. Patch the created PodTemplate. Fetching
framework.ExpectEqual(len(podTemplateList.Items), 0, "PodTemplate list returned items, failed to delete PodTemplate") }) <del> ginkgo.It("should delete a collection of pod templates", func() { </del> <ins> /* Release : v1.19 Testname: PodTemplate, delete a collection Description: A set of Pod Templates is created with a label selector which MUST be found when listed. The set of Pod Templates is deleted and MUST NOT show up when listed by its label selector. */ framework.ConformanceIt("should delete a collection of pod templates", func() { </ins> podTemplateNames := []string{"test-podtemplate-1", "test-podtemplate-2", "test-podtemplate-3"} ginkgo.By("Create set of pod templates")
) nodeAuthorizer := node.NewAuthorizer(graph, nodeidentifier.NewDefaultNodeIdentifier(), bootstrappolicy.NodeRules()) authorizers = append(authorizers, nodeAuthorizer) <ins> ruleResolvers = append(ruleResolvers, nodeAuthorizer) </ins> case modes.ModeAlwaysAllow: alwaysAllowAuthorizer := authorizerfactory.NewAlwaysAllowAuthorizer()
"//staging/src/k8s.io/api/rbac/v1:go_default_library", "//staging/src/k8s.io/api/storage/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", <ins> "//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library", </ins> "//staging/src/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/client-go/informers/core/v1:go_default_library",
rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/runtime/schema" <ins> "k8s.io/apiserver/pkg/authentication/user" </ins> "k8s.io/apiserver/pkg/authorization/authorizer" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/component-base/featuregate"
features featuregate.FeatureGate } <ins> var _ = authorizer.Authorizer(&NodeAuthorizer{}) var _ = authorizer.RuleResolver(&NodeAuthorizer{}) </ins> // NewAuthorizer returns a new node authorizer <del> func NewAuthorizer(graph *Graph, identifier nodeidentifier.NodeIdentifier, rules []rbacv1.PolicyRule) authorizer.Authorizer { </del> <ins> func NewAuthorizer(graph *Graph, identifier nodeidentifier.NodeIdentifier, rules []rbacv1.PolicyRule) *NodeAuthorizer { </ins> return &NodeAuthorizer{ graph:      graph, identifier: identifier,
csiNodeResource   = storageapi.Resource("csinodes") ) <ins> func (r *NodeAuthorizer) RulesFor(user user.Info, namespace string) ([]authorizer.ResourceRuleInfo, []authorizer.NonResourceRuleInfo, bool, error) { if _, isNode := r.identifier.NodeIdentity(user); isNode { // indicate nodes do not have fully enumerated permissions return nil, nil, true, fmt.Errorf("node authorizer does not support user rule resolution") } return nil, nil, false, nil } </ins> func (r *NodeAuthorizer) Authorize(ctx context.Context, attrs authorizer.Attributes) (authorizer.Decision, string, error) { nodeName, isNode := r.identifier.NodeIdentity(attrs.GetUser()) if !isNode {
populate(g, nodes, pods, pvs, attachments) identifier := nodeidentifier.NewDefaultNodeIdentifier() <del> authz := NewAuthorizer(g, identifier, bootstrappolicy.NodeRules()).(*NodeAuthorizer) </del> <ins> authz := NewAuthorizer(g, identifier, bootstrappolicy.NodeRules()) </ins> node0 := &user.DefaultInfo{Name: "system:node:node0", Groups: []string{"system:nodes"}}
} watchCache := newWatchCache( <del> config.KeyFunc, cacher.processEvent, config.GetAttrsFunc, config.Versioner, config.Indexers, objType) </del> <ins> config.CacheCapacity, config.KeyFunc, cacher.processEvent, config.GetAttrsFunc, config.Versioner, config.Indexers, objType) </ins> listerWatcher := NewCacherListerWatcher(config.Storage, config.ResourcePrefix, config.NewListFunc) reflectorName := "storage/cacher.go:" + config.ResourcePrefix
indexers *cache.Indexers, objectType reflect.Type) *watchCache { wc := &watchCache{ <del> capacity:            defaultLowerBoundCapacity, keyFunc:             keyFunc, getAttrsFunc:        getAttrsFunc, cache:               make([]*watchCacheEvent, defaultLowerBoundCapacity), lowerBoundCapacity:  defaultLowerBoundCapacity, upperBoundCapacity:  defaultUpperBoundCapacity, </del> <ins> capacity:     capacity, keyFunc:      keyFunc, getAttrsFunc: getAttrsFunc, cache:        make([]*watchCacheEvent, capacity), // TODO get rid of them once we stop passing capacity as a parameter to watch cache. lowerBoundCapacity:  min(capacity, defaultLowerBoundCapacity), upperBoundCapacity:  max(capacity, defaultUpperBoundCapacity), </ins> startIndex:          0, endIndex:            0, store:               cache.NewIndexer(storeElementKey, storeElementIndexers(indexers)),
} versioner := etcd3.APIObjectVersioner{} mockHandler := func(*watchCacheEvent) {} <del> wc := newWatchCache(keyFunc, mockHandler, getAttrsFunc, versioner, indexers, reflect.TypeOf(&example.Pod{})) // To preserve behavior of tests that assume a given capacity, // resize it to th expected size. wc.capacity = capacity wc.cache = make([]*watchCacheEvent, capacity) wc.lowerBoundCapacity = min(capacity, defaultLowerBoundCapacity) wc.upperBoundCapacity = max(capacity, defaultUpperBoundCapacity) </del> <ins> wc := newWatchCache(capacity, keyFunc, mockHandler, getAttrsFunc, versioner, indexers, reflect.TypeOf(&example.Pod{})) </ins> wc.clock = clock.NewFakeClock(time.Now()) return wc }
// Thus we customize buckets significantly, to empower both usecases. Buckets: []float64{0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40, 50, 60}, <del> StabilityLevel: compbasemetrics.ALPHA, </del> <ins> StabilityLevel: compbasemetrics.STABLE, </ins> }, []string{"verb", "dry_run", "group", "version", "resource", "subresource", "scope", "component"}, )
<ins> - name: apiserver_request_duration_seconds help: Response latency distribution in seconds for each verb, dry run value, group, version, resource, subresource, scope and component. type: Histogram stabilityLevel: STABLE labels: - component - dry_run - group - resource - scope - subresource - verb - version buckets: - 0.05 - 0.1 - 0.15 - 0.2 - 0.25 - 0.3 - 0.35 - 0.4 - 0.45 - 0.5 - 0.6 - 0.7 - 0.8 - 0.9 - 1 - 1.25 - 1.5 - 1.75 - 2 - 2.5 - 3 - 3.5 - 4 - 4.5 - 5 - 6 - 7 - 8 - 9 - 10 - 15 - 20 - 25 - 30 - 40 - 50 - 60 </ins> - name: apiserver_request_total help: Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, and HTTP response code.
// We want the IPs to end up in order by interface (in particular, we want eth0's // IPs first), but macs isn't necessarily sorted in that order so we have to // explicitly order by device-number (device-number == the "0" in "eth0"). <del> macIPs := make(map[int]string) </del> <ins> var macIDs []string macDevNum := make(map[string]int) </ins> for _, macID := range strings.Split(macs, "n") { if macID == "" { continue
klog.Warningf("Bad device-number %q for interface %sn", numStr, macID) continue } <ins> macIDs = append(macIDs, macID) macDevNum[macID] = num } // Sort macIDs by interface device-number sort.Slice(macIDs, func(i, j int) bool { return macDevNum[macIDs[i]] < macDevNum[macIDs[j]] }) for _, macID := range macIDs { </ins> ipPath := path.Join("network/interfaces/macs/", macID, "local-ipv4s") <del> macIPs[num], err = c.metadata.GetMetadata(ipPath) </del> <ins> internalIPs, err := c.metadata.GetMetadata(ipPath) </ins> if err != nil { return nil, fmt.Errorf("error querying AWS metadata for %q: %q", ipPath, err) } <del> } for i := 0; i < len(macIPs); i++ { internalIPs := macIPs[i] if internalIPs == "" { continue } </del> for _, internalIP := range strings.Split(internalIPs, "n") { if internalIP == "" { continue
if len(keySplit) == 5 && keySplit[4] == "device-number" { for i, macElem := range m.aws.networkInterfacesMacs { if macParam == macElem { <del> return fmt.Sprintf("%dn", i), nil </del> <ins> n := i if n > 0 { // Introduce an artificial gap, just to test eg: [eth0, eth2] n++ } return fmt.Sprintf("%dn", n), nil </ins> } } }
// TestBindPlugin tests invocation of bind plugins. func TestBindPlugin(t *testing.T) { testContext := testutils.InitTestAPIServer(t, "bind-plugin", nil) <del> bindPlugin1 := &BindPlugin{PluginName: "bind-plugin-1", client: testContext.ClientSet} bindPlugin2 := &BindPlugin{PluginName: "bind-plugin-2", client: testContext.ClientSet} </del> <ins> bindPlugin1 := &BindPlugin{name: "bind-plugin-1", client: testContext.ClientSet} bindPlugin2 := &BindPlugin{name: "bind-plugin-2", client: testContext.ClientSet} </ins> reservePlugin := &ReservePlugin{name: "mock-reserve-plugin"} postBindPlugin := &PostBindPlugin{name: "mock-post-bind-plugin"} // Create a plugin registry for testing. Register reserve, bind, and
// Input args must follow the format and sequence of ebtables list output. Otherwise, EnsureRule will always create // new rules and causing duplicates. EnsureRule(position RulePosition, table Table, chain Chain, args ...string) (bool, error) <ins> // DeleteRule checks if the specified rule is present and, if so, deletes it. DeleteRule(table Table, chain Chain, args ...string) error </ins> // EnsureChain checks if the specified chain is present and, if not, creates it.  If the rule existed, return true. EnsureChain(table Table, chain Chain) (bool, error) // DeleteChain deletes the specified chain.  If the chain did not exist, return error.
return exist, nil } <ins> func (runner *runner) DeleteRule(table Table, chain Chain, args ...string) error { exist := true fullArgs := makeFullArgs(table, opListChain, chain, fullMac) out, err := runner.exec.Command(cmdebtables, fullArgs...).CombinedOutput() if err != nil { exist = false } else { exist = checkIfRuleExists(string(out), args...) } if !exist { return nil } fullArgs = makeFullArgs(table, opDeleteRule, chain, args...) out, err = runner.exec.Command(cmdebtables, fullArgs...).CombinedOutput() if err != nil { return fmt.Errorf("Failed to delete rule: %v, output: %s", err, out) } return nil } </ins> func (runner *runner) EnsureChain(table Table, chain Chain) (bool, error) { exist := true
t.Errorf("expected error: %q", errStr) } } <ins> func TestDeleteRule(t *testing.T) { fcmd := fakeexec.FakeCmd{ CombinedOutputScript: []fakeexec.FakeAction{ // Exists func() ([]byte, []byte, error) { return []byte(`Bridge table: filter Bridge chain: OUTPUT, entries: 4, policy: ACCEPT -j TEST `), nil, nil }, // Fail to delete func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 2} }, // Does not Exists. func() ([]byte, []byte, error) { return []byte(`Bridge table: filter Bridge chain: TEST, entries: 0, policy: ACCEPT`), nil, nil }, }, } fexec := fakeexec.FakeExec{ CommandScript: []fakeexec.FakeCommandAction{ func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) }, func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) }, func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) }, }, } runner := New(&fexec) err := runner.DeleteRule(TableFilter, ChainOutput, "-j", "TEST") errStr := "Failed to delete rule: exit 2, output: " if err == nil || err.Error() != errStr { t.Errorf("expected error: %q", errStr) } err = runner.DeleteRule(TableFilter, ChainOutput, "-j", "TEST") if err != nil { t.Errorf("expected err = nil") } } </ins>
touch "staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go" echo > api/api-rules/violation_exceptions.list echo > api/api-rules/codegen_violation_exceptions.list <del> if make generated_files >/dev/null; then </del> <ins> if make generated_files >/dev/null 2>&1; then </ins> echo "Expected make generated_files to fail with API violations." echo "" exit 1
continue fi # Skip a directory if 1) it has no files and 2) all the subdirectories contain a go.mod file. <del> if [[ -z "$(find "${DEPS_DIR}/${PACKAGE}" -mindepth 1 -maxdepth 1 -type f)" ]]; then </del> <ins> if [[ -z "$(find "${DEPS_DIR}/${PACKAGE}/" -mindepth 1 -maxdepth 1 -type f)" ]]; then </ins> misses_go_mod=false while read -d "" -r SUBDIR; do if [[ ! -e "${SUBDIR}/go.mod" ]]; then misses_go_mod=true break fi <del> done < <(find "${DEPS_DIR}/${PACKAGE}" -mindepth 1 -maxdepth 1 -type d -print0) </del> <ins> done < <(find "${DEPS_DIR}/${PACKAGE}/" -mindepth 1 -maxdepth 1 -type d -print0) </ins> if [[ $misses_go_mod = false ]]; then echo "${PACKAGE} has no files, skipping" >&2 continue
) const ( <del> // Taken from lmctfy https://github.com/google/lmctfy/blob/master/lmctfy/controllers/cpu_controller.cc MinShares     = 2 </del> <ins> // These limits are defined in the kernel: // https://github.com/torvalds/linux/blob/0bddd227f3dc55975e2b8dfa7fc6f959b062a2c7/kernel/sched/sched.h#L427-L428 MinShares = 2 MaxShares = 262144 </ins> SharesPerCPU  = 1024 MilliCPUToCPU = 1000
"//staging/src/k8s.io/client-go/util/testing:go_default_library", "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", "//staging/src/k8s.io/component-base/version:go_default_library", <ins> "//vendor/github.com/golang/groupcache/lru:go_default_library", </ins> "//vendor/github.com/google/cadvisor/info/v1:go_default_library", "//vendor/github.com/google/cadvisor/info/v2:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library",
// lastStatusReportTime is the time when node status was last reported. lastStatusReportTime time.Time <ins> // lastContainerStartedTime is the time of the last ContainerStarted event observed per pod lastContainerStartedTime *timeCache </ins> // syncNodeStatusMux is a lock on updating the node status, because this path is not thread-safe. // This lock is used by Kubelet.syncNodeStatus function and shouldn't be used anywhere else. syncNodeStatusMux sync.Mutex
} kl.podWorkers.ForgetWorker(pod.UID) <ins> // make sure our runtimeCache is at least as fresh as the last container started event we observed. // this ensures we correctly send graceful deletion signals to all containers we've reported started. if lastContainerStarted, ok := kl.lastContainerStartedTime.Get(pod.UID); ok { if err := kl.runtimeCache.ForceUpdateIfOlder(lastContainerStarted); err != nil { return fmt.Errorf("error updating containers: %v", err) } } </ins> // Runtime cache may not have been updated to with the pod, but it's okay // because the periodic cleanup routine will attempt to delete again later. runningPods, err := kl.runtimeCache.GetPods()
kl.sourcesReady.AddSource(u.Source) case e := <-plegCh: <ins> if e.Type == pleg.ContainerStarted { // record the most recent time we observed a container start for this pod. // this lets us selectively invalidate the runtimeCache when processing a delete for this pod // to make sure we don't miss handling graceful termination for containers we reported as having started. kl.lastContainerStartedTime.Add(e.ID, time.Now()) } </ins> if isSyncPodWorthy(e) { // PLEG event for a pod; sync it. if pod, ok := kl.podManager.GetPodByUID(e.ID); ok {
<ins> /* Copyright 2020 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 kubelet import ( "sync" "time" "github.com/golang/groupcache/lru" "k8s.io/apimachinery/pkg/types" ) // timeCache stores a time keyed by uid type timeCache struct { lock  sync.RWMutex cache *lru.Cache } // maxTimeCacheEntries is the cache entry number in lru cache. 1000 is a proper number // for our 100 pods per node target. If we support more pods per node in the future, we // may want to increase the number. const maxTimeCacheEntries = 1000 func newTimeCache() *timeCache { return &timeCache{cache: lru.New(maxTimeCacheEntries)} } func (c *timeCache) Add(uid types.UID, t time.Time) { c.lock.Lock() defer c.lock.Unlock() c.cache.Add(uid, t) } func (c *timeCache) Remove(uid types.UID) { c.lock.Lock() defer c.lock.Unlock() c.cache.Remove(uid) } func (c *timeCache) Get(uid types.UID) (time.Time, bool) { c.lock.RLock() defer c.lock.RUnlock() value, ok := c.cache.Get(uid) if !ok { return time.Time{}, false } t, ok := value.(time.Time) if !ok { return time.Time{}, false } return t, true } </ins>
<ins> /* Copyright 2020 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 kubelet import ( "testing" "time" "github.com/golang/groupcache/lru" ) func TestTimeCache(t *testing.T) { cache := &timeCache{cache: lru.New(2)} if a, ok := cache.Get("123"); ok { t.Errorf("expected cache miss, got %v, %v", a, ok) } now := time.Now() soon := now.Add(time.Minute) cache.Add("now", now) cache.Add("soon", soon) if a, ok := cache.Get("now"); !ok || !a.Equal(now) { t.Errorf("expected cache hit matching %v, got %v, %v", now, a, ok) } if a, ok := cache.Get("soon"); !ok || !a.Equal(soon) { t.Errorf("expected cache hit matching %v, got %v, %v", soon, a, ok) } then := now.Add(-time.Minute) cache.Add("then", then) if a, ok := cache.Get("now"); ok { t.Errorf("expected cache miss from oldest evicted value, got %v, %v", a, ok) } if a, ok := cache.Get("soon"); !ok || !a.Equal(soon) { t.Errorf("expected cache hit matching %v, got %v, %v", soon, a, ok) } if a, ok := cache.Get("then"); !ok || !a.Equal(then) { t.Errorf("expected cache hit matching %v, got %v, %v", then, a, ok) } } </ins>
} // DeletePodWithWaitByName deletes the named and namespaced pod and waits for the pod to be terminated. Resilient to the pod <del> // not existing. Also waits for all owned resources to be deleted. </del> <ins> // not existing. </ins> func DeletePodWithWaitByName(c clientset.Interface, podName, podNamespace string) error { e2elog.Logf("Deleting pod %q in namespace %q", podName, podNamespace) <del> deletionPolicy := metav1.DeletePropagationForeground err := c.CoreV1().Pods(podNamespace).Delete(context.TODO(), podName, metav1.DeleteOptions{ // If the pod is the owner of some resources (like ephemeral inline volumes), // then we want to be sure that those are also gone before we return. // Blocking pod deletion via metav1.DeletePropagationForeground achieves that. PropagationPolicy: &deletionPolicy, }) </del> <ins> err := c.CoreV1().Pods(podNamespace).Delete(context.TODO(), podName, metav1.DeleteOptions{}) </ins> if err != nil { if apierrors.IsNotFound(err) { return nil // assume pod was already deleted