Compare commits

...

5 Commits
v0.2.0 ... main

Author SHA1 Message Date
Volcano Bot 04d1afc71d
Merge pull request #22 from Monokaix/dev
fix queue allocate err
2025-06-24 10:43:16 +08:00
Monokaix 6434092d7c fix queue allocate err
Signed-off-by: Monokaix <changxuzheng@huawei.com>
2025-06-19 15:43:46 +08:00
Volcano Bot 0aed15c49f
Merge pull request #21 from anryko/fix_docs_1
fix: docs example is broken
2025-06-19 15:31:09 +08:00
Andrej Svenke 3080740142 fix: docs example is broken
Signed-off-by: Andrej Svenke <anryko@nebius.com>
2025-06-11 11:24:29 +02:00
Volcano Bot f186d9c6de
Merge pull request #17 from tanberBro/main
bugfix: cache updates from events all use atomic locks and the calculation of allocated use rbi.DispatchStatus != api.Suspended.
2025-05-30 11:23:51 +08:00
6 changed files with 25 additions and 16 deletions

View File

@ -26,7 +26,7 @@ spec:
- --dispatch-period=1s
- -v=5
- 2>&1
imagePullPolicy: Never
imagePullPolicy: IfNotPresent
volumeMounts:
- name: webhook-config
mountPath: /etc/kubeconfig

View File

@ -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"]
---

View File

@ -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,
}

View File

@ -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.

View File

@ -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
}

View File

@ -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
}