Skip to content

Commit

Permalink
add: adjustments from feeback
Browse files Browse the repository at this point in the history
  • Loading branch information
VanillaSpoon committed Nov 20, 2023
1 parent 2bee4cd commit 0e6aa32
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/queuejob/queuejob_controller_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func (qjm *XController) getAppWrapperCompletionStatus(caw *arbv1.AppWrapper) arb
objectName := genericItem.GenericTemplate
unstruct, err := genericresource.UnmarshalToUnstructured(objectName.Raw)
if err != nil {
klog.Errorf("[getAppWrapperCompletionStatus] Error: %v", err)
klog.Errorf("[getAppWrapperCompletionStatus] Error unmarshalling appwrapper: %v", caw.Name)
}
name := ""
if md, ok := unstruct.Object["metadata"]; ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ func (gr *GenericResources) Cleanup(aw *arbv1.AppWrapper, awr *arbv1.AppWrapperG
}
// Default generic resource name
name := ""

namespaced := true
// todo:DELETEME dd := common.KubeClient.Discovery()
dd := gr.clients.Discovery()

dd := gr.clients.Discovery()
ext := awr.GenericTemplate
gvk, mapping, err := getResourceMapping(dd, ext.Raw, default_gvk)
if err != nil {
Expand Down Expand Up @@ -157,7 +155,7 @@ func (gr *GenericResources) SyncQueueJob(aw *arbv1.AppWrapper, awr *arbv1.AppWra

namespaced := true
name := ""
// todo:DELETEME dd := common.KubeClient.Discovery()

dd := gr.clients.Discovery()
ext := awr.GenericTemplate
_, mapping, err := getResourceMapping(dd, ext.Raw, nil)
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/queuejobresources/genericresource/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func getResourceMapping(dd discovery.DiscoveryInterface, raw []byte, defaultGVK
}


// checks if object has replicas and containers field
// hasFields checks if obj has replicas and containers field
func hasFields(obj runtime.RawExtension) (hasFields bool, replica float64, containers []v1.Container) {
unstruct, err := UnmarshalToUnstructured(obj.Raw)
if err != nil {
Expand Down Expand Up @@ -166,7 +166,7 @@ func hasFields(obj runtime.RawExtension) (hasFields bool, replica float64, conta
return isFound, replicas, objContainers
}

// checks if object has pod template spec and add new labels
// addLabelsToPodTemplateField checks if unstruct has pod template spec and add new labels
func addLabelsToPodTemplateField(unstruct *unstructured.Unstructured, labels map[string]string) (hasFields bool) {
spec, isFound, _ := unstructured.NestedMap(unstruct.UnstructuredContent(), "spec")
if !isFound {
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/queuejobresources/genericresource/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package genericresource

import (
"encoding/json"
"k8s.io/klog/v2"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
Expand All @@ -12,7 +11,6 @@ func UnmarshalToUnstructured(raw []byte) (unstruct unstructured.Unstructured, er
var blob interface{}
err = json.Unmarshal(raw, &blob)
if err != nil {
klog.Errorf("Error unmarshalling, err=%#v", err)
return unstruct, err
}
unstruct.Object = blob.(map[string]interface{})
Expand Down

0 comments on commit 0e6aa32

Please sign in to comment.