zhuqi-lucas commented on code in PR #569:
URL: https://github.com/apache/yunikorn-core/pull/569#discussion_r1258234375
##########
pkg/scheduler/objects/queue.go:
##########
@@ -663,29 +663,61 @@ 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("application resource
quota has at least one 0 value: cannot set queue limit",
+ 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))
+
+ // 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))
+ } else if !resources.StrictlyGreaterThanZero(guaranteedRes) {
+ log.Log(log.SchedQueue).Warn("application guaranteed
resource has at least one 0 value: cannot set queue guaranteed resource",
+ zap.Stringer("guaranteedResource",
guaranteedRes))
+ guaranteedRes = nil // Skip setting guaranteed resource
if it has a value <= 0
+ }
+ }
+
+ if quotaErr != nil && guaranteedErr != nil {
Review Comment:
Sure, will address the return when logging.
--
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]