Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-2205] remove the warning of processing nonexistent "namespa… #747

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions pkg/common/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,18 @@ func PodUnderCondition(pod *v1.Pod, condition *v1.PodCondition) bool {
// get namespace guaranteed resource from namespace annotation
func GetNamespaceGuaranteedFromAnnotation(namespaceObj *v1.Namespace) *si.Resource {
// retrieve guaranteed resource info from annotations
namespaceGuaranteed := GetNameSpaceAnnotationValue(namespaceObj, constants.NamespaceGuaranteed)
var namespaceGuaranteedMap map[string]string
err := json.Unmarshal([]byte(namespaceGuaranteed), &namespaceGuaranteedMap)
if err != nil {
log.Log(log.ShimUtils).Warn("Unable to process namespace.guaranteed annotation",
zap.String("namespace", namespaceObj.Name),
zap.String("namespace.guaranteed is", namespaceGuaranteed))
return nil
if guaranteed := GetNameSpaceAnnotationValue(namespaceObj, constants.NamespaceGuaranteed); guaranteed != "" {
var namespaceGuaranteedMap map[string]string
err := json.Unmarshal([]byte(guaranteed), &namespaceGuaranteedMap)
if err != nil {
log.Log(log.ShimUtils).Warn("Unable to process namespace.guaranteed annotation",
zap.String("namespace", namespaceObj.Name),
zap.String("namespace.guaranteed is", guaranteed))
return nil
}
return common.GetResource(namespaceGuaranteedMap)
}
return common.GetResource(namespaceGuaranteedMap)
return nil
}

func GetNamespaceQuotaFromAnnotation(namespaceObj *v1.Namespace) *si.Resource {
Expand Down
15 changes: 15 additions & 0 deletions pkg/common/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,21 @@ func TestGetNamespaceGuaranteedFromAnnotation(t *testing.T) {
},
},
}, nil},
{&v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "test",
Annotations: map[string]string{
constants.NamespaceGuaranteed: "error",
},
},
}, nil},
{&v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "test",
},
}, nil},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("namespace: %v", tc.namespace), func(t *testing.T) {
Expand Down
Loading