jiebi/CodeConvo huggingface dataset:
MatchLabels: map[string]string{f.UniqueName: "true"}, } <del> sideEffectsNone := admissionregistrationv1.SideEffectClassNone </del> _, err := createValidatingWebhookConfiguration(f, &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: configName, }, Webhooks: []admissionregistrationv1.ValidatingWebhook{ <del> { Name: "deny-unwanted-pod-container-name-and-label.k8s.io", Rules: []admissionregistrationv1.RuleWithOperations{{ Operations: []admissionregistrationv1.OperationType{admissionregistrationv1.Create}, Rule: admissionregistrationv1.Rule{ APIGroups:   []string{""}, APIVersions: []string{"v1"}, Resources:   []string{"pods"}, }, }}, ClientConfig: admissionregistrationv1.WebhookClientConfig{ Service: &admissionregistrationv1.ServiceReference{ Namespace: namespace, Name:      serviceName, Path:      strPtr("/pods"), Port:      pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, SideEffects:             &sideEffectsNone, AdmissionReviewVersions: []string{"v1beta1"}, // Scope the webhook to just this namespace NamespaceSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{f.UniqueName: "true"}, }, }, { Name: "deny-unwanted-configmap-data.k8s.io", Rules: []admissionregistrationv1.RuleWithOperations{{ Operations: []admissionregistrationv1.OperationType{admissionregistrationv1.Create, admissionregistrationv1.Update, admissionregistrationv1.Delete}, Rule: admissionregistrationv1.Rule{ APIGroups:   []string{""}, APIVersions: []string{"v1"}, Resources:   []string{"configmaps"}, }, }}, // The webhook skips the namespace that has label "skip-webhook-admission":"yes" NamespaceSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{f.UniqueName: "true"}, MatchExpressions: []metav1.LabelSelectorRequirement{ { Key:      skipNamespaceLabelKey, Operator: metav1.LabelSelectorOpNotIn, Values:   []string{skipNamespaceLabelValue}, }, }, }, ClientConfig: admissionregistrationv1.WebhookClientConfig{ Service: &admissionregistrationv1.ServiceReference{ Namespace: namespace, Name:      serviceName, Path:      strPtr("/configmaps"), Port:      pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, SideEffects:             &sideEffectsNone, AdmissionReviewVersions: []string{"v1beta1"}, }, </del> <ins> newDenyPodWebhookFixture(f, context), newDenyConfigMapWebhookFixture(f, context), </ins> // Server cannot talk to this webhook, so it always fails. // Because this webhook is configured fail-open, request should be admitted after the call fails. failOpenHook,
ginkgo.By("Registering the mutating configmap webhook via the AdmissionRegistration API") namespace := f.Namespace.Name <del> sideEffectsNone := admissionregistrationv1.SideEffectClassNone </del> _, err := createMutatingWebhookConfiguration(f, &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: configName, }, Webhooks: []admissionregistrationv1.MutatingWebhook{ <del> { Name: "adding-configmap-data-stage-1.k8s.io", Rules: []admissionregistrationv1.RuleWithOperations{{ Operations: []admissionregistrationv1.OperationType{admissionregistrationv1.Create}, Rule: admissionregistrationv1.Rule{ APIGroups:   []string{""}, APIVersions: []string{"v1"}, Resources:   []string{"configmaps"}, }, }}, ClientConfig: admissionregistrationv1.WebhookClientConfig{ Service: &admissionregistrationv1.ServiceReference{ Namespace: namespace, Name:      serviceName, Path:      strPtr("/mutating-configmaps"), Port:      pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, SideEffects:             &sideEffectsNone, AdmissionReviewVersions: []string{"v1beta1"}, // Scope the webhook to just this namespace NamespaceSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{f.UniqueName: "true"}, }, }, { Name: "adding-configmap-data-stage-2.k8s.io", Rules: []admissionregistrationv1.RuleWithOperations{{ Operations: []admissionregistrationv1.OperationType{admissionregistrationv1.Create}, Rule: admissionregistrationv1.Rule{ APIGroups:   []string{""}, APIVersions: []string{"v1"}, Resources:   []string{"configmaps"}, }, }}, ClientConfig: admissionregistrationv1.WebhookClientConfig{ Service: &admissionregistrationv1.ServiceReference{ Namespace: namespace, Name:      serviceName, Path:      strPtr("/mutating-configmaps"), Port:      pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, SideEffects:             &sideEffectsNone, AdmissionReviewVersions: []string{"v1beta1"}, // Scope the webhook to just this namespace NamespaceSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{f.UniqueName: "true"}, }, }, </del> <ins> newMutateConfigMapWebhookFixture(f, context, 1), newMutateConfigMapWebhookFixture(f, context, 2), </ins> }, }) framework.ExpectNoError(err, "registering mutating webhook config %s with namespace %s", configName, namespace)
} func nonCompliantConfigMap(f *framework.Framework) *v1.ConfigMap { <ins> return namedNonCompliantConfigMap(disallowedConfigMapName, f) } func namedNonCompliantConfigMap(name string, f *framework.Framework) *v1.ConfigMap { </ins> return &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ <del> Name: disallowedConfigMapName, </del> <ins> Name: name, </ins> }, Data: map[string]string{ "webhook-e2e-test": "webhook-disallow",
} func toBeMutatedConfigMap(f *framework.Framework) *v1.ConfigMap { <ins> return namedToBeMutatedConfigMap("to-be-mutated", f) } func namedToBeMutatedConfigMap(name string, f *framework.Framework) *v1.ConfigMap { </ins> return &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ <del> Name: "to-be-mutated", </del> <ins> Name: name, </ins> }, Data: map[string]string{ "mutation-start": "yes",
UserAssignedIdentityID string `json:"userAssignedIdentityID,omitempty" yaml:"userAssignedIdentityID,omitempty"` // The ID of the Azure Subscription that the cluster is deployed in SubscriptionID string `json:"subscriptionId,omitempty" yaml:"subscriptionId,omitempty"` <ins> // Identity system value for the deployment. This gets populate for Azure Stack case. IdentitySystem string `json:"identitySystem,omitempty" yaml:"identitySystem,omitempty"` </ins> } // GetServicePrincipalToken creates a new service principal token based on the configuration func GetServicePrincipalToken(config *AzureAuthConfig, env *azure.Environment) (*adal.ServicePrincipalToken, error) { <ins> var tenantID string if strings.EqualFold(config.IdentitySystem, ADFSIdentitySystem) { tenantID = "adfs" } else { tenantID = config.TenantID } </ins> if config.UseManagedIdentityExtension { klog.V(2).Infoln("azure: using managed identity extension to retrieve access token") msiEndpoint, err := adal.GetMSIVMEndpoint()
env.ServiceManagementEndpoint) } <del> oauthConfig, err := adal.NewOAuthConfig(env.ActiveDirectoryEndpoint, config.TenantID) </del> <ins> oauthConfig, err := adal.NewOAuthConfig(env.ActiveDirectoryEndpoint, tenantID) </ins> if err != nil { return nil, fmt.Errorf("creating the OAuth config: %v", err) }
"//staging/src/k8s.io/client-go/tools/watch:go_default_library", "//test/e2e/framework:go_default_library", "//test/e2e/framework/events:go_default_library", <del> "//test/e2e/framework/kubelet:go_default_library", </del> "//test/e2e/framework/network:go_default_library", "//test/e2e/framework/node:go_default_library", "//test/e2e/framework/pod:go_default_library",
podutil "k8s.io/kubernetes/pkg/api/v1/pod" "k8s.io/kubernetes/pkg/kubelet" "k8s.io/kubernetes/test/e2e/framework" <del> e2ekubelet "k8s.io/kubernetes/test/e2e/framework/kubelet" </del> e2epod "k8s.io/kubernetes/test/e2e/framework/pod" e2ewebsocket "k8s.io/kubernetes/test/e2e/framework/websocket" imageutils "k8s.io/kubernetes/test/utils/image"
err = podClient.Delete(context.TODO(), pod.Name, *metav1.NewDeleteOptions(30)) framework.ExpectNoError(err, "failed to delete pod") <del> ginkgo.By("verifying the kubelet observed the termination notice") err = wait.Poll(time.Second*5, time.Second*30, func() (bool, error) { podList, err := e2ekubelet.GetKubeletPods(f.ClientSet, pod.Spec.NodeName) if err != nil { framework.Logf("Unable to retrieve kubelet pods for node %v: %v", pod.Spec.NodeName, err) return false, nil } for _, kubeletPod := range podList.Items { if pod.Name != kubeletPod.Name { continue } if kubeletPod.ObjectMeta.DeletionTimestamp == nil { framework.Logf("deletion has not yet been observed") return false, nil } return true, nil } framework.Logf("no pod exists with the name we were looking for, assuming the termination request was observed and completed") return true, nil }) framework.ExpectNoError(err, "kubelet never observed the termination notice") </del> ginkgo.By("verifying pod deletion was observed") deleted := false var lastPod *v1.Pod
"//test/e2e/framework:go_default_library", "//test/e2e/framework/gpu:go_default_library", "//test/e2e/framework/job:go_default_library", <del> "//test/e2e/framework/kubelet:go_default_library", </del> "//test/e2e/framework/node:go_default_library", "//test/e2e/framework/pod:go_default_library", "//test/e2e/framework/providers/gce:go_default_library",
clientset "k8s.io/client-go/kubernetes" podutil "k8s.io/kubernetes/pkg/api/v1/pod" "k8s.io/kubernetes/test/e2e/framework" <del> e2ekubelet "k8s.io/kubernetes/test/e2e/framework/kubelet" </del> e2enode "k8s.io/kubernetes/test/e2e/framework/node" e2epod "k8s.io/kubernetes/test/e2e/framework/pod" e2erc "k8s.io/kubernetes/test/e2e/framework/rc"
framework.ExpectNoError(err) for _, node := range nodeList.Items { <del> framework.Logf("nLogging pods the kubelet thinks is on node %v before test", node.Name) printAllKubeletPods(cs, node.Name) </del> <ins> framework.Logf("nLogging pods the apiserver thinks is on node %v before test", node.Name) printAllPodsOnNode(cs, node.Name) </ins> } })
}) }) <del> // printAllKubeletPods outputs status of all kubelet pods into log. func printAllKubeletPods(c clientset.Interface, nodeName string) { podList, err := e2ekubelet.GetKubeletPods(c, nodeName) </del> <ins> // printAllPodsOnNode outputs status of all kubelet pods into log. func printAllPodsOnNode(c clientset.Interface, nodeName string) { podList, err := c.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{FieldSelector: "spec.nodeName=" + nodeName}) </ins> if err != nil { <del> framework.Logf("Unable to retrieve kubelet pods for node %v: %v", nodeName, err) </del> <ins> framework.Logf("Unable to retrieve pods for node %v: %v", nodeName, err) </ins> return } for _, p := range podList.Items {
Containers: []v1.Container{ { Name:  "nfs-provisioner", <del> Image: "quay.io/kubernetes_incubator/nfs-provisioner:v2.2.0-k8s1.12", </del> <ins> Image: "quay.io/kubernetes_incubator/nfs-provisioner:v2.2.2", </ins> SecurityContext: &v1.SecurityContext{ Capabilities: &v1.Capabilities{ Add: []v1.Capability{"DAC_READ_SEARCH"},
cmd.Flags().StringVar(&o.APIGroup, "api-group", o.APIGroup, "Limit to resources in the specified API group.") cmd.Flags().BoolVar(&o.Namespaced, "namespaced", o.Namespaced, "If false, non-namespaced resources will be returned, otherwise returning namespaced resources by default.") cmd.Flags().StringSliceVar(&o.Verbs, "verbs", o.Verbs, "Limit to resources that support the specified verbs.") <ins> cmd.Flags().StringVar(&o.SortBy, "sort-by", o.SortBy, "If non-empty, sort nodes list using specified field. The field can be either 'name' or 'kind'.") </ins> cmd.Flags().BoolVar(&o.Cached, "cached", o.Cached, "Use the cached list of resources if available.") return cmd }
if !supportedOutputTypes.Has(o.Output) { return fmt.Errorf("--output %v is not available", o.Output) } <ins> supportedSortTypes := sets.NewString("", "name", "kind") if len(o.SortBy) > 0 { if !supportedSortTypes.Has(o.SortBy) { return fmt.Errorf("--sort-by accepts only name or kind") } } </ins> return nil }
return err } <del> type sortableGroupResource []groupResource </del> <ins> type sortableResource struct { resources []groupResource sortBy    string } </ins> <del> 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) </del> <ins> func (s sortableResource) Len() int { return len(s.resources) } func (s sortableResource) Swap(i, j int) { s.resources[i], s.resources[j] = s.resources[j], s.resources[i] } func (s sortableResource) Less(i, j int) bool { ret := strings.Compare(s.compareValues(i, j)) </ins> if ret > 0 { return false } else if ret == 0 { <del> return strings.Compare(s[i].APIResource.Name, s[j].APIResource.Name) < 0 </del> <ins> return strings.Compare(s.resources[i].APIResource.Name, s.resources[j].APIResource.Name) < 0 </ins> } return true } <ins> func (s sortableResource) compareValues(i, j int) (string, string) { switch s.sortBy { case "name": return s.resources[i].APIResource.Name, s.resources[j].APIResource.Name case "kind": return s.resources[i].APIResource.Kind, s.resources[j].APIResource.Kind } return s.resources[i].APIGroup, s.resources[j].APIGroup } </ins>
import ( "fmt" "path" <del> "time" </del> "github.com/onsi/ginkgo" <del> "k8s.io/api/core/v1" </del> <ins> v1 "k8s.io/api/core/v1" </ins> metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/kubernetes/test/e2e/framework"
framework.ExpectNoError(err, "failed to get pod %s", pod.Name) ginkgo.By("Reading file content from the nginx-container") <del> resultString, err = framework.LookForStringInFile(f.Namespace.Name, pod.Name, busyBoxMainContainerName, busyBoxMainVolumeFilePath, message, 30*time.Second) framework.ExpectNoError(err, "failed to match expected string %s with %s", message, resultString) </del> <ins> result := f.ExecShellInContainer(pod.Name, busyBoxMainContainerName, fmt.Sprintf("cat %s", busyBoxMainVolumeFilePath)) framework.ExpectEqual(result, message, "failed to match expected string %s with %s", message, resultString) </ins> }) })
- Removed cadvisor metric labels `pod_name` and `container_name` to match instrumentation guidelines. Any Prometheus queries that match `pod_name` and `container_name` labels (e.g. cadvisor or kubelet probe metrics) must be updated to use `pod` and `container` instead. ([#80376](https://github.com/kubernetes/kubernetes/pull/80376), [@ehashman](https://github.com/ehashman)) <del> ### Depreciated/changed metrics </del> <ins> ### Deprecated/changed metrics </ins> - kube-controller-manager and cloud-controller-manager metrics are now marked as with the ALPHA stability level. ([#81624](https://github.com/kubernetes/kubernetes/pull/81624), [@logicalhan](https://github.com/logicalhan)) - kube-proxy metrics are now marked as with the ALPHA stability level. ([#81626](https://github.com/kubernetes/kubernetes/pull/81626), [@logicalhan](https://github.com/logicalhan))
embed = [":go_default_library"], deps = [ "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", <ins> "//staging/src/k8s.io/apiserver/pkg/endpoints/metrics:go_default_library", "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//staging/src/k8s.io/component-base/metrics/testutil:go_default_library", </ins> ], )
deps = [ "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library", <ins> "//staging/src/k8s.io/apiserver/pkg/endpoints/metrics:go_default_library", </ins> "//staging/src/k8s.io/apiserver/pkg/server/httplog:go_default_library", "//vendor/k8s.io/klog:go_default_library", ],
klog.V(5).Infof("Installing health checkers for (%v): %v", path, formatQuoted(checkerNames(checks...)...)) <del> mux.Handle(path, handleRootHealthz(checks...)) </del> <ins> mux.Handle(path, metrics.InstrumentHandlerFunc("GET", /* group = */ "", /* version = */ "", /* resource = */ "", /* subresource = */ path, /* scope = */ "", /* component = */ "", handleRootHealthz(checks...))) </ins> for _, check := range checks { mux.Handle(fmt.Sprintf("%s/%v", path, check.Name()), adaptCheckToHandler(check.Check)) }
"net/http/httptest" "net/url" "reflect" <ins> "strings" </ins> "testing" "k8s.io/apimachinery/pkg/util/sets" <ins> "k8s.io/apiserver/pkg/endpoints/metrics" "k8s.io/component-base/metrics/legacyregistry" "k8s.io/component-base/metrics/testutil" </ins> ) func TestInstallHandler(t *testing.T) {
} } <ins> func TestMetrics(t *testing.T) { mux := http.NewServeMux() InstallHandler(mux) InstallLivezHandler(mux) InstallReadyzHandler(mux) metrics.Register() metrics.Reset() paths := []string{"/healthz", "/livez", "/readyz"} for _, path := range paths { req, err := http.NewRequest("GET", fmt.Sprintf("http://example.com%s", path), nil) if err != nil { t.Errorf("%v", err) } mux.ServeHTTP(httptest.NewRecorder(), req) } expected := strings.NewReader(` # HELP apiserver_request_total [ALPHA] Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, client, and HTTP response contentType and code. # TYPE apiserver_request_total counter apiserver_request_total{client="unknown",code="200",component="",contentType="text/plain; charset=utf-8",dry_run="",group="",resource="",scope="",subresource="/healthz",verb="GET",version=""} 1 apiserver_request_total{client="unknown",code="200",component="",contentType="text/plain; charset=utf-8",dry_run="",group="",resource="",scope="",subresource="/livez",verb="GET",version=""} 1 apiserver_request_total{client="unknown",code="200",component="",contentType="text/plain; charset=utf-8",dry_run="",group="",resource="",scope="",subresource="/readyz",verb="GET",version=""} 1 `) if err := testutil.GatherAndCompare(legacyregistry.DefaultGatherer, expected, "apiserver_request_total"); err != nil { t.Error(err) } } </ins> func createGetRequestWithUrl(rawUrlString string) *http.Request { url, _ := url.Parse(rawUrlString) return &http.Request{
return err } <del> return wait.Poll(time.Second, b.bindTimeout, func() (bool, error) { </del> <ins> err = wait.Poll(time.Second, b.bindTimeout, func() (bool, error) { </ins> b, err := b.checkBindings(assumedPod, bindings, claimsToProvision) return b, err }) <ins> if err != nil { pvcName := "" if len(claimsToProvision) > 0 { pvcName = claimsToProvision[0].Name } return fmt.Errorf("Failed to bind volumes: provisioning failed for PVC %q: %v", pvcName, err) } return nil </ins> } func getPodName(pod *v1.Pod) string {
} } <del> // If the kubelet config controller is available, and dynamic config is enabled, start the config and status sync loops if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && len(s.DynamicConfigDir.Value()) > 0 && kubeDeps.KubeletConfigController != nil && !standaloneMode && !s.RunOnce { if err := kubeDeps.KubeletConfigController.StartSync(kubeDeps.KubeClient, kubeDeps.EventClient, string(nodeName)); err != nil { return err } } </del> if kubeDeps.Auth == nil { auth, err := BuildAuth(nodeName, kubeDeps.KubeClient, s.KubeletConfiguration) if err != nil {
return err } <ins> // If the kubelet config controller is available, and dynamic config is enabled, start the config and status sync loops if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && len(s.DynamicConfigDir.Value()) > 0 && kubeDeps.KubeletConfigController != nil && !standaloneMode && !s.RunOnce { if err := kubeDeps.KubeletConfigController.StartSync(kubeDeps.KubeClient, kubeDeps.EventClient, string(nodeName)); err != nil { return err } } </ins> if s.HealthzPort > 0 { mux := http.NewServeMux() healthz.InstallHandler(mux)
StabilityLevel: metrics.ALPHA, }, ) <del> PreemptionVictims = metrics.NewGauge( &metrics.GaugeOpts{ Subsystem:      SchedulerSubsystem, Name:           "pod_preemption_victims", Help:           "Number of selected preemption victims", </del> <ins> PreemptionVictims = metrics.NewHistogram( &metrics.HistogramOpts{ Subsystem: SchedulerSubsystem, Name:      "pod_preemption_victims", Help:      "Number of selected preemption victims", // we think #victims>50 is pretty rare, therefore [50, +Inf) is considered a single bucket. Buckets:        metrics.LinearBuckets(5, 5, 10), </ins> StabilityLevel: metrics.ALPHA, }) PreemptionAttempts = metrics.NewCounter(
sched.Recorder.Eventf(victim, preemptor, v1.EventTypeNormal, "Preempted", "Preempting", "Preempted by %v/%v on node %v", preemptor.Namespace, preemptor.Name, nodeName) } <del> metrics.PreemptionVictims.Set(float64(len(victims))) </del> <ins> metrics.PreemptionVictims.Observe(float64(len(victims))) </ins> } // Clearing nominated pods should happen outside of "if node != nil". Node could // be nil when a pod with nominated node name is eligible to preempt again,
func ValidatePolicy(policy schedulerapi.Policy) error { var validationErrors []error <ins> priorities := make(map[string]schedulerapi.PriorityPolicy, len(policy.Priorities)) </ins> for _, priority := range policy.Priorities { if priority.Weight <= 0 || priority.Weight >= framework.MaxWeight { validationErrors = append(validationErrors, fmt.Errorf("Priority %s should have a positive weight applied to it or it has overflown", priority.Name)) } <ins> validationErrors = append(validationErrors, validatePriorityRedeclared(priorities, priority)) } predicates := make(map[string]schedulerapi.PredicatePolicy, len(policy.Predicates)) for _, predicate := range policy.Predicates { validationErrors = append(validationErrors, validatePredicateRedeclared(predicates, predicate)) </ins> } binders := 0
return utilerrors.NewAggregate(validationErrors) } <ins> // validatePriorityRedeclared checks if any custom priorities have been declared multiple times in the policy config // by examining the specified priority arguments func validatePriorityRedeclared(priorities map[string]schedulerapi.PriorityPolicy, priority schedulerapi.PriorityPolicy) error { var priorityType string if priority.Argument != nil { if priority.Argument.LabelPreference != nil { priorityType = "LabelPreference" } else if priority.Argument.RequestedToCapacityRatioArguments != nil { priorityType = "RequestedToCapacityRatioArguments" } else if priority.Argument.ServiceAntiAffinity != nil { priorityType = "ServiceAntiAffinity" } else { return fmt.Errorf("No priority arguments set for priority %s", priority.Name) } if existing, alreadyDeclared := priorities[priorityType]; alreadyDeclared { return fmt.Errorf("Priority '%s' redeclares custom priority '%s', from:'%s'", priority.Name, priorityType, existing.Name) } priorities[priorityType] = priority } return nil } // validatePredicateRedeclared checks if any custom predicates have been declared multiple times in the policy config // by examining the specified predicate arguments func validatePredicateRedeclared(predicates map[string]schedulerapi.PredicatePolicy, predicate schedulerapi.PredicatePolicy) error { var predicateType string if predicate.Argument != nil { if predicate.Argument.LabelsPresence != nil { predicateType = "LabelsPresence" } else if predicate.Argument.ServiceAffinity != nil { predicateType = "ServiceAffinity" } else { return fmt.Errorf("No priority arguments set for priority %s", predicate.Name) } if existing, alreadyDeclared := predicates[predicateType]; alreadyDeclared { return fmt.Errorf("Predicate '%s' redeclares custom predicate '%s', from:'%s'", predicate.Name, predicateType, existing.Name) } predicates[predicateType] = predicate } return nil } </ins> // validateExtendedResourceName checks whether the specified name is a valid // extended resource name. func validateExtendedResourceName(name v1.ResourceName) []error {