pbacsko commented on a change in pull request #336: URL: https://github.com/apache/incubator-yunikorn-k8shim/pull/336#discussion_r787549205
########## File path: pkg/schedulerplugin/scheduler_plugin.go ########## @@ -0,0 +1,209 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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 schedulerplugin + +import ( + "context" + "fmt" + "sync" + + "go.uber.org/zap" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/informers" + "k8s.io/kubernetes/pkg/scheduler/framework" + + "github.com/apache/incubator-yunikorn-core/pkg/entrypoint" + "github.com/apache/incubator-yunikorn-k8shim/pkg/cache" + "github.com/apache/incubator-yunikorn-k8shim/pkg/common/events" + "github.com/apache/incubator-yunikorn-k8shim/pkg/common/utils" + "github.com/apache/incubator-yunikorn-k8shim/pkg/conf" + "github.com/apache/incubator-yunikorn-k8shim/pkg/dispatcher" + "github.com/apache/incubator-yunikorn-k8shim/pkg/log" + pluginconf "github.com/apache/incubator-yunikorn-k8shim/pkg/schedulerplugin/conf" + "github.com/apache/incubator-yunikorn-k8shim/pkg/shim" + "github.com/apache/incubator-yunikorn-scheduler-interface/lib/go/api" +) + +const ( + SchedulerPluginName = "YuniKornPlugin" +) + +// YuniKornSchedulerPlugin provides an implementation of several lifecycle methods of the Kubernetes scheduling framework: +// https://kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework/ +// +// PreFilter: Used to notify the default scheduler that a particular pod has been marked ready for scheduling by YuniKorn +// +// Filter: Used to notify the default scheduler that a particular pod/node combination is ready to be scheduled +// +// PostBind: Used to notify YuniKorn that a pod has been scheduled successfully +// +// Pod Allocations: +// +// The YuniKorn scheduler is always running in the background, making decisions about which pods to allocate to which +// nodes. When a decision is made, that pod is marked as having a "pending" pod allocation, which means YuniKorn has +// allocated the pod, but the default scheduler (via the plugin interface) has not yet been notified. +// +// Once PreFilter() has been called for a particular pod, that allocation is marked as "in progress" meaning it has been +// communicated to the default scheduler, but has not yet been fulfilled. +// +// Finally, in PostBind(), the allocation is removed as we now know that the pod has been allocated successfully. +// If a pending or in-progress allocation is detected for a pod in PreFilter(), we remove the allocation and force the +// pod to be rescheduled, as this means the prior allocation could not be completed successfully by the default +// scheduler for some reason. +type YuniKornSchedulerPlugin struct { Review comment: Solid comment, it's great to have this here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@yunikorn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org