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

Fixed logic to give the correct AppWrapper status transition #577

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions pkg/controller/queuejob/queuejob_controller_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,13 @@ 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 {

// Get all pods and related resources
// Count how many generic items specify a 'completionstatus'. For those that do specify it, check to see if the
// generic item reached any of the condition states provided in the YAML
totalCompletionsRequired := 0
countCompletionRequired := 0
for i, genericItem := range caw.Spec.AggrResources.GenericItems {
if len(genericItem.CompletionStatus) > 0 {
totalCompletionsRequired += 1
objectName := genericItem.GenericTemplate
var unstruct unstructured.Unstructured
unstruct.Object = make(map[string]interface{})
Expand All @@ -550,7 +553,7 @@ func (qjm *XController) getAppWrapperCompletionStatus(caw *arbv1.AppWrapper) arb
if !status {
klog.V(4).Infof("[getAppWrapperCompletionStatus] Item %d named %s not completed for appwrapper: '%s/%s'", i+1, name, caw.Namespace, caw.Name)
// early termination because a required item is not completed
return caw.Status.State
continue
}

// only consider count completion required for valid items
Expand All @@ -562,11 +565,11 @@ func (qjm *XController) getAppWrapperCompletionStatus(caw *arbv1.AppWrapper) arb

// Set new status only when completion required flag is present in genericitems array
if countCompletionRequired > 0 {
if caw.Status.Running == 0 && caw.Status.Pending == 0 {
if caw.Status.Running == 0 && caw.Status.Pending == 0 || countCompletionRequired == totalCompletionsRequired {
return arbv1.AppWrapperStateCompleted
}

if caw.Status.Pending > 0 || caw.Status.Running > 0 {
if caw.Status.Running > 0 || caw.Status.Pending > 0 {
return arbv1.AppWrapperStateRunningHoldCompletion
}
}
Expand Down
1 change: 1 addition & 0 deletions test/e2e-kuttl-deployment-01/steps/03-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ spec:
nvidia.com/gpu: 0
memory: 1Gi
- replicas: 1
completionstatus: Complete
custompodresources:
- replicas: 1
requests:
Expand Down
1 change: 1 addition & 0 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,7 @@ func createGenericDeploymentAWWithMultipleItems(context *context, name string) *
GenericTemplate: runtime.RawExtension{
Raw: rb1,
},
CompletionStatus: "Completed",
},
},
},
Expand Down