Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Fix resource manager and debug
Browse files Browse the repository at this point in the history
  • Loading branch information
anandswaminathan committed Oct 2, 2020
1 parent e54c081 commit 50ccc6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 2 additions & 0 deletions go/tasks/plugins/array/k8s/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func LaunchAndCheckSubTasksState(ctx context.Context, tCtx core.TaskExecutionCon

for childIdx, existingPhaseIdx := range currentState.GetArrayStatus().Detailed.GetItems() {
existingPhase := core.Phases[existingPhaseIdx]
logger.Debugf(ctx, "Current phase and index %v - %v", childIdx, existingPhase)
indexStr := strconv.Itoa(childIdx)
podName := formatSubTaskName(ctx, tCtx.TaskExecutionMetadata().GetTaskExecutionID().GetGeneratedName(), indexStr)
if existingPhase.IsTerminal() {
Expand All @@ -68,6 +69,7 @@ func LaunchAndCheckSubTasksState(ctx context.Context, tCtx core.TaskExecutionCon

// Since we know we have already "processed" this terminal phase we can safely deallocate resource
err = deallocateResource(ctx, tCtx, config, childIdx)
logger.Debugf(ctx, "K8s array - deallocate resource")
if err != nil {
logger.Errorf(ctx, "Error releasing allocation token [%s] in LaunchAndCheckSubTasks [%s]", podName, err)
return currentState, logLinks, errors2.Wrapf(ErrCheckPodStatus, err, "Error releasing allocation token.")
Expand Down
18 changes: 4 additions & 14 deletions go/tasks/plugins/array/k8s/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ func allocateResource(ctx context.Context, tCtx core.TaskExecutionContext, confi
}

resourceNamespace := core.ResourceNamespace(config.ResourceConfig.PrimaryLabel)
resourceConstraintSpec := createResourceConstraintsSpec(ctx, tCtx)
resourceConstraintSpec := core.ResourceConstraintsSpec{
ProjectScopeResourceConstraint: nil,
NamespaceScopeResourceConstraint: nil,
}

allocationStatus, err := tCtx.ResourceManager().AllocateResource(ctx, resourceNamespace, podName, resourceConstraintSpec)
if err != nil {
Expand Down Expand Up @@ -223,16 +226,3 @@ func deallocateResource(ctx context.Context, tCtx core.TaskExecutionContext, con

return nil
}

func createResourceConstraintsSpec(ctx context.Context, _ core.TaskExecutionContext) core.ResourceConstraintsSpec {
constraintsSpec := core.ResourceConstraintsSpec{
ProjectScopeResourceConstraint: nil,
NamespaceScopeResourceConstraint: nil,
}

constraintsSpec.ProjectScopeResourceConstraint = &core.ResourceConstraint{Value: int64(1)}
constraintsSpec.NamespaceScopeResourceConstraint = &core.ResourceConstraint{Value: int64(1)}
logger.Infof(ctx, "Created a resource constraints spec: [%v]", constraintsSpec)

return constraintsSpec
}

0 comments on commit 50ccc6b

Please sign in to comment.