Repository navigation
[YUNIKORN-3509] Fix placeholder accounting on allocation rollback #1190
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -472,7 +472,8 @@ func (sa *Application) clearPlaceholderTimer() { | |
| func (sa *Application) timeoutPlaceholderProcessing() { | ||
| sa.Lock() | ||
| defer sa.Unlock() | ||
| if (sa.IsRunning() || sa.IsCompleting()) && !resources.IsZero(sa.allocatedPlaceholder) { | ||
| // a rollback can leave a started application without allocated placeholders: Case 2 must not release its real allocations | ||
| if sa.IsRunning() || sa.IsCompleting() { | ||
| // Case 1: if all app's placeholders are allocated, only part of them gets replaced, just delete the remaining placeholders | ||
| var toRelease []*Allocation | ||
| replacing := 0 | ||
|
|
@@ -962,7 +963,8 @@ func (sa *Application) DeallocateAsk(allocKey string) (*resources.Resource, erro | |
| // This is used when the shim fails to bind a pod after the core has allocated it, | ||
| // allowing the task to be re-scheduled on a different node. | ||
| // The application must be in Accepted or Running state for rollback to succeed. | ||
| func (sa *Application) RollbackAllocation(allocKey string) (*resources.Resource, error) { | ||
| // Returns the rolled back allocation. | ||
| func (sa *Application) RollbackAllocation(allocKey string) (*Allocation, error) { | ||
| sa.Lock() | ||
| defer sa.Unlock() | ||
|
|
||
|
|
@@ -980,7 +982,7 @@ func (sa *Application) RollbackAllocation(allocKey string) (*resources.Resource, | |
| } | ||
|
|
||
| // Restore pending FIRST. This ensures hasZeroAllocations() sees pending > 0 when | ||
| // we later decrement allocatedResource, preventing a spurious CompleteApplication event. | ||
| // we later decrement allocatedResource for a non-placeholder, preventing a spurious CompleteApplication event. | ||
| if _, err := sa.deallocateAsk(ask); err != nil { | ||
| return nil, fmt.Errorf("failed to deallocate ask %s during rollback on app %s: %w", allocKey, sa.ApplicationID, err) | ||
| } | ||
|
|
@@ -989,8 +991,18 @@ func (sa *Application) RollbackAllocation(allocKey string) (*resources.Resource, | |
| ask.SetNodeID("") | ||
|
|
||
| res := ask.GetAllocatedResource() | ||
| sa.allocatedResource = resources.Sub(sa.allocatedResource, res) | ||
| sa.allocatedResource.Prune() | ||
| if ask.IsPlaceholder() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are missing the rollback for at least the app state: when the last placeholder allocation was allocated the state of the app was progressed. We need to check if that needs rollback |
||
| sa.allocatedPlaceholder = resources.Sub(sa.allocatedPlaceholder, res) | ||
| sa.allocatedPlaceholder.Prune() | ||
| // keep the placeholder timer: the gang deadline counts from the first placeholder allocation and also | ||
| // covers this placeholder when it is allocated again | ||
| if resources.IsZero(sa.allocatedPlaceholder) { | ||
| sa.hasPlaceholderAlloc = false | ||
| } | ||
|
Comment on lines
+997
to
+1001
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If placeholders are being allocated there will not be real allocations. If we roll back to zero it means that there is no placeholder allocated (anymore) all due to rollback. There is no replacement happening yet as that requires all placeholders to be allocated. At this point we should clear the timer and not leave it running. Setting the flag to false means we clear the timer. |
||
| } else { | ||
| sa.allocatedResource = resources.Sub(sa.allocatedResource, res) | ||
| sa.allocatedResource.Prune() | ||
| } | ||
| sa.decUserResourceUsage(res, false) | ||
| delete(sa.allocations, allocKey) | ||
|
Comment on lines
1006
to
1007
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing rollback of |
||
|
|
||
|
|
@@ -1000,7 +1012,7 @@ func (sa *Application) RollbackAllocation(allocKey string) (*resources.Resource, | |
| zap.String("appID", sa.ApplicationID), | ||
| zap.String("allocationKey", allocKey)) | ||
|
|
||
| return res, nil | ||
| return ask, nil | ||
| } | ||
|
|
||
| func (sa *Application) allocateAsk(ask *Allocation) (*resources.Resource, error) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not remove this check