zhuqi-lucas commented on code in PR #569:
URL: https://github.com/apache/yunikorn-core/pull/569#discussion_r1260837632
##########
pkg/scheduler/objects/queue.go:
##########
@@ -663,29 +663,60 @@ func (sq *Queue) AddApplication(app *Application) {
// YUNIKORN-199: update the quota from the namespace
// get the tag with the quota
quota := app.GetTag(common.AppTagNamespaceResourceQuota)
- if quota == "" {
+ // get the tag with the guaranteed resource
+ guaranteed := app.GetTag(common.AppTagNamespaceResourceGuaranteed)
+ if quota == "" && guaranteed == "" {
return
}
+
+ var quotaRes, guaranteedRes *resources.Resource
+ var quotaErr, guaranteedErr error
+
// need to set a quota: convert json string to resource
- res, err := resources.NewResourceFromString(quota)
- if err != nil {
- log.Log(log.SchedQueue).Warn("application resource quota
conversion failure",
- zap.String("json quota string", quota),
- zap.Error(err))
- return
+ if quota != "" {
+ quotaRes, quotaErr = resources.NewResourceFromString(quota)
+ if quotaErr != nil {
+ log.Log(log.SchedQueue).Warn("application resource
quota conversion failure",
+ zap.String("json quota string", quota),
+ zap.Error(quotaErr))
+ } else if !resources.StrictlyGreaterThanZero(quotaRes) {
+ log.Log(log.SchedQueue).Warn("Max resource quantities
should be greater than zero: cannot set queue max resource",
+ zap.Stringer("maxResource", quotaRes))
+ quotaRes = nil // Skip setting quota if it has a value
<= 0
+ }
}
- if !resources.StrictlyGreaterThanZero(res) {
- log.Log(log.SchedQueue).Warn("application resource quota has at
least one 0 value: cannot set queue limit",
- zap.Stringer("maxResource", res))
- return
+
+ // need to set guaranteed resource: convert json string to resource
+ if guaranteed != "" {
+ guaranteedRes, guaranteedErr =
resources.NewResourceFromString(guaranteed)
+ if guaranteedErr != nil {
+ log.Log(log.SchedQueue).Warn("application guaranteed
resource conversion failure",
+ zap.String("json guaranteed string",
guaranteed),
+ zap.Error(guaranteedErr))
+ if quotaErr != nil {
Review Comment:
I think we should use quotaErr here, because we only need to return for both
quotaErr != nil and guaranteedErr != nil
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]