Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add completion status to every item in a pipeline
  • Loading branch information
Jaroslaw Cwiklik committed Sep 6, 2023
commit 9f67d0fa2afd7caffcae6c63137a453db7b9b75f
14 changes: 14 additions & 0 deletions config/crd/bases/mcad.ibm.com_appwrappers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,20 @@ spec:
properties:
condition:
type: string
itemGVK:
description: Group Version Kind
properties:
group:
type: string
kind:
type: string
version:
type: string
required:
- group
- kind
- version
type: object
name:
type: string
namespace:
Expand Down
14 changes: 14 additions & 0 deletions deployment/mcad-controller/crds/mcad.ibm.com_appwrappers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,20 @@ spec:
properties:
condition:
type: string
itemGVK:
description: Group Version Kind
properties:
group:
type: string
kind:
type: string
version:
type: string
required:
- group
- kind
- version
type: object
name:
type: string
namespace:
Expand Down
7 changes: 6 additions & 1 deletion pkg/apis/controller/v1beta1/appwrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,16 @@ type GenericItemCompletionStatus struct {
}

type GenericItem struct {
ItemGVK ItemGVK `json:"itemGVK"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Condition string `json:"condition"`
}

type ItemGVK struct {
Group string `json:"group"`
Version string `json:"version"`
Kind string `json:"kind"`
}
type AppWrapperState string

// enqueued, active, deleting, succeeded, failed
Expand Down
39 changes: 21 additions & 18 deletions pkg/controller/queuejob/queuejob_controller_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,20 +681,8 @@ func (qjm *XController) GetAggregatedResourcesPerGenericItem(cqj *arbv1.AppWrapp

// Gets all objects owned by AW from API server, check user supplied status and set whole AW status
func (qjm *XController) getAppWrapperCompletionStatus(caw *arbv1.AppWrapper) (arbv1.AppWrapperState, arbv1.GenericItemCompletionStatus) {
/*
statusField := reflect.ValueOf(caw.Status)
if statusField.Kind() != reflect.Struct {
klog.Errorf("[getAppWrapperCompletionStatus] Error reflecting Status, %#v", statusField)
return caw.Status.State, arbv1.GenericItemCompletionStatus{}
}
completionStatus := caw.Status.ItemCompletionStatus
itemCompletionStatusField := statusField.FieldByName("ItemCompletionStatus")
if !itemCompletionStatusField.IsValid() {
completionStatus = arbv1.GenericItemCompletionStatus{}
}
*/
completionStatus := arbv1.GenericItemCompletionStatus{}

completionStatus := arbv1.GenericItemCompletionStatus{}
_ = completionStatus
// Get all pods and related resources
countCompletionRequired := 0
Expand All @@ -709,12 +697,21 @@ func (qjm *XController) getAppWrapperCompletionStatus(caw *arbv1.AppWrapper) (ar
}
unstruct.Object = blob.(map[string]interface{}) //set object to the content of the blob after Unmarshalling
name := ""
namespace := ""
if md, ok := unstruct.Object["metadata"]; ok {
metadata := md.(map[string]interface{})
if objectName, ok := metadata["name"]; ok {
name = objectName.(string)
}
if objectName, ok := metadata["namespace"]; ok {
namespace = objectName.(string)
}
}
_, gvk, err := unstructured.UnstructuredJSONScheme.Decode(objectName.Raw, nil, nil)
if err != nil {
klog.Errorf("[getAppWrapperCompletionStatus] Error unmarshalling, err=%#v", err)
}

if len(name) == 0 {
klog.Warningf("[getAppWrapperCompletionStatus] object name not present for appwrapper: %v in namespace: %v", caw.Name, caw.Namespace)
}
Expand All @@ -726,10 +723,16 @@ func (qjm *XController) getAppWrapperCompletionStatus(caw *arbv1.AppWrapper) (ar
return caw.Status.State, completionStatus
} else {
_ = condition
genItemCompletionStatus := arbv1.GenericItem {
Name: caw.Name,
Namespace: caw.Namespace,
Condition: condition,

genItemCompletionStatus := arbv1.GenericItem{
ItemGVK: arbv1.ItemGVK{
Group: gvk.Group,
Version: gvk.Version,
Kind: gvk.Kind,
},
Name: name,
Namespace: namespace,
Condition: condition,
}
completionStatus.GenericItems = append(completionStatus.GenericItems, genItemCompletionStatus)
}
Expand Down Expand Up @@ -2146,7 +2149,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool
} else if qj.Status.CanRun && qj.Status.State == arbv1.AppWrapperStateActive {
//set appwrapper status to Complete or RunningHoldCompletion
derivedAwStatus, genericItemsCompletionStatus := cc.getAppWrapperCompletionStatus(qj)

//Set Appwrapper state to complete if all items in Appwrapper
//are completed
if derivedAwStatus == arbv1.AppWrapperStateRunningHoldCompletion {
Expand Down