Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
|
04d1afc71d | |
|
6434092d7c | |
|
0aed15c49f | |
|
3080740142 | |
|
f186d9c6de |
|
@ -26,7 +26,7 @@ spec:
|
|||
- --dispatch-period=1s
|
||||
- -v=5
|
||||
- 2>&1
|
||||
imagePullPolicy: Never
|
||||
imagePullPolicy: IfNotPresent
|
||||
volumeMounts:
|
||||
- name: webhook-config
|
||||
mountPath: /etc/kubeconfig
|
||||
|
|
|
@ -32,7 +32,7 @@ spec:
|
|||
- -v=5
|
||||
- 2>&1
|
||||
image: volcanosh/volcano-global-webhook-manager:latest
|
||||
imagePullPolicy: Never
|
||||
imagePullPolicy: IfNotPresent
|
||||
volumeMounts:
|
||||
- mountPath: /admission.local.config/certificates
|
||||
name: admission-certs
|
||||
|
@ -79,7 +79,7 @@ spec:
|
|||
containers:
|
||||
- name: main
|
||||
image: volcanosh/volcano-global-webhook-manager:latest
|
||||
imagePullPolicy: Never
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["./gen-admission-secret.sh", "--service", "volcano-global-webhook", "--namespace",
|
||||
"volcano-global", "--secret", "volcano-global-webhook-cert"]
|
||||
---
|
||||
|
|
|
@ -19,6 +19,7 @@ package api
|
|||
import (
|
||||
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
volcanoapi "volcano.sh/volcano/pkg/scheduler/api"
|
||||
)
|
||||
|
||||
type DispatchStatus int16
|
||||
|
@ -35,6 +36,7 @@ type ResourceBindingInfo struct {
|
|||
Queue string
|
||||
PriorityClassName string
|
||||
DispatchStatus DispatchStatus
|
||||
ResReq *volcanoapi.Resource
|
||||
|
||||
// Update it when snapshot.
|
||||
Priority int32
|
||||
|
@ -47,6 +49,7 @@ func (rbi *ResourceBindingInfo) DeepCopy() *ResourceBindingInfo {
|
|||
Queue: rbi.Queue,
|
||||
PriorityClassName: rbi.PriorityClassName,
|
||||
DispatchStatus: rbi.DispatchStatus,
|
||||
ResReq: rbi.ResReq.Clone(),
|
||||
|
||||
Priority: rbi.Priority,
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
"volcano.sh/apis/pkg/apis/scheduling"
|
||||
"volcano.sh/apis/pkg/apis/scheduling/scheme"
|
||||
schedulingapi "volcano.sh/volcano/pkg/scheduler/api"
|
||||
volcanoapi "volcano.sh/volcano/pkg/scheduler/api"
|
||||
|
||||
"volcano.sh/volcano-global/pkg/dispatcher/api"
|
||||
"volcano.sh/volcano-global/pkg/utils"
|
||||
|
@ -237,6 +238,13 @@ func (dc *DispatcherCache) setResourceBinding(rb *workv1alpha2.ResourceBinding)
|
|||
PriorityClassName: workload.PriorityClassName(),
|
||||
DispatchStatus: api.UnSuspended,
|
||||
}
|
||||
|
||||
resReq := volcanoapi.EmptyResource()
|
||||
if rb.Spec.ReplicaRequirements != nil {
|
||||
resReq = volcanoapi.NewResource(rb.Spec.ReplicaRequirements.ResourceRequest).Multi(float64(rb.Spec.Replicas))
|
||||
}
|
||||
newResourceBindingInfo.ResReq = resReq
|
||||
|
||||
// Currently, our failurePolicy is set to Fail, which ensures that no unexpected ResourceBindings will exist.
|
||||
// When a ResourceBinding is created, it will definitely be updated to Suspend, so we don't need to check the Status,
|
||||
// so rb should be suspended normally.
|
||||
|
|
|
@ -123,8 +123,7 @@ func (cp *capacityPlugin) buildQueueAttrs(ssn *framework.Session) {
|
|||
cp.queueOpts[queue.UID] = attr
|
||||
}
|
||||
if rbi.DispatchStatus != api.Suspended {
|
||||
resRes := volcanoapi.NewResource(rbi.ResourceBinding.Spec.ReplicaRequirements.ResourceRequest).Multi(float64(rbi.ResourceBinding.Spec.Replicas))
|
||||
attr.allocated = attr.allocated.Add(resRes)
|
||||
attr.allocated = attr.allocated.Add(rbi.ResReq)
|
||||
}
|
||||
}
|
||||
for _, attr := range cp.queueOpts {
|
||||
|
@ -136,12 +135,11 @@ func (cp *capacityPlugin) buildQueueAttrs(ssn *framework.Session) {
|
|||
|
||||
func (cp *capacityPlugin) allocatableFunc(qi *volcanoapi.QueueInfo, candidate *api.ResourceBindingInfo) bool {
|
||||
attr := cp.queueOpts[qi.UID]
|
||||
resReq := volcanoapi.NewResource(candidate.ResourceBinding.Spec.ReplicaRequirements.ResourceRequest).Multi(float64(candidate.ResourceBinding.Spec.Replicas))
|
||||
futureUsed := attr.allocated.Clone().Add(resReq)
|
||||
allocatable := futureUsed.LessEqualWithDimension(attr.realCapability, resReq)
|
||||
futureUsed := attr.allocated.Clone().Add(candidate.ResReq)
|
||||
allocatable := futureUsed.LessEqualWithDimension(attr.realCapability, candidate.ResReq)
|
||||
if !allocatable {
|
||||
klog.V(3).Infof("Queue <%v>: realCapability <%v>, allocated <%v>; Candidate <%v/%v>: resource request <%v>",
|
||||
qi.Name, attr.realCapability, attr.allocated, candidate.ResourceBinding.Namespace, candidate.ResourceBinding.Name, resReq)
|
||||
qi.Name, attr.realCapability, attr.allocated, candidate.ResourceBinding.Namespace, candidate.ResourceBinding.Name, candidate.ResReq)
|
||||
}
|
||||
return allocatable
|
||||
}
|
||||
|
@ -153,11 +151,10 @@ func (cp *capacityPlugin) allocateFunc(rbi *api.ResourceBindingInfo) error {
|
|||
klog.Error(err)
|
||||
return err
|
||||
}
|
||||
resReq := volcanoapi.NewResource(rbi.ResourceBinding.Spec.ReplicaRequirements.ResourceRequest).Multi(float64(rbi.ResourceBinding.Spec.Replicas))
|
||||
attr.allocated.Add(resReq)
|
||||
attr.allocated.Add(rbi.ResReq)
|
||||
cp.updateShare(attr)
|
||||
klog.V(4).Infof("Capacity allocateFunc: ResourceBindingInfo <%v/%v>, resreq <%v>, share <%v>",
|
||||
rbi.ResourceBinding.Namespace, rbi.ResourceBinding.Name, resReq, attr.share)
|
||||
rbi.ResourceBinding.Namespace, rbi.ResourceBinding.Name, rbi.ResReq, attr.share)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -168,11 +165,10 @@ func (cp *capacityPlugin) deallocateFunc(rbi *api.ResourceBindingInfo) error {
|
|||
klog.Error(err)
|
||||
return err
|
||||
}
|
||||
resReq := volcanoapi.NewResource(rbi.ResourceBinding.Spec.ReplicaRequirements.ResourceRequest).Multi(float64(rbi.ResourceBinding.Spec.Replicas))
|
||||
attr.allocated.Sub(resReq)
|
||||
attr.allocated.Sub(rbi.ResReq)
|
||||
cp.updateShare(attr)
|
||||
klog.V(4).Infof("Capacity deallocateFunc: ResourceBindingInfo <%v/%v>, resreq <%v>, share <%v>",
|
||||
rbi.ResourceBinding.Namespace, rbi.ResourceBinding.Name, resReq, attr.share)
|
||||
rbi.ResourceBinding.Namespace, rbi.ResourceBinding.Name, rbi.ResReq, attr.share)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import (
|
|||
schedulingv1beta1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1"
|
||||
)
|
||||
|
||||
const defaultQueue = "default"
|
||||
|
||||
// GetObjQueue returns the queue name of an obj.
|
||||
// There are 3 ways to get queue name for now:
|
||||
// scheduling.volcano.sh/queue-name support only annotation
|
||||
|
@ -39,5 +41,5 @@ func GetObjQueue(obj metav1.Object) string {
|
|||
if _, ok := annotations[schedulingv1beta1.QueueNameAnnotationKey]; ok {
|
||||
return annotations[schedulingv1beta1.QueueNameAnnotationKey]
|
||||
}
|
||||
return ""
|
||||
return defaultQueue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue