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

add safety check before micro step and check pending license #1430

Merged
merged 2 commits into from
May 21, 2024
Merged
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
4 changes: 4 additions & 0 deletions cloudslang-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@
<version>${parent.version}</version>
</dependency>

<dependency>
<groupId>${score.group}</groupId>
<artifactId>score-worker-manager-api</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@
import io.cloudslang.lang.runtime.env.RunEnvironment;
import io.cloudslang.lang.runtime.events.LanguageEventData;
import io.cloudslang.score.api.execution.precondition.ExecutionPreconditionService;
import io.cloudslang.score.facade.execution.ExecutionStatus;
import io.cloudslang.score.lang.ExecutionRuntimeServices;
import io.cloudslang.score.lang.SystemContext;
import io.cloudslang.worker.management.WorkerConfigurationService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.Serializable;
Expand Down Expand Up @@ -85,6 +88,9 @@ public class ExecutableExecutionData extends AbstractExecutionData {
private final DebuggerBreakpointsHandler debuggerBreakpointsHandler;
private final ArgumentsBinding argumentsBinding;

@Autowired(required = false)
private WorkerConfigurationService workerConfigurationService;

public ExecutableExecutionData(ResultsBinding resultsBinding, InputsBinding inputsBinding,
OutputsBinding outputsBinding, ExecutionPreconditionService preconditionService,
MissingInputHandler missingInputHandler,
Expand Down Expand Up @@ -387,6 +393,16 @@ public void canExecute(@Param(ScoreLangConstants.RUN_ENV) RunEnvironment runEnv,
@Param(ScoreLangConstants.NODE_NAME_KEY) String nodeName,
@Param(ScoreLangConstants.NEXT_STEP_ID_KEY) Long nextStepId) {
try {
// check canceled, if it is then set next position to null and flow termination type
if (workerConfigurationService != null &&
(workerConfigurationService.isExecutionCancelled(executionRuntimeServices.getExecutionId()) ||
(executionRuntimeServices.getFlowTerminationType() == ExecutionStatus.CANCELED))) {
// NOTE: an execution can be cancelled directly from CancelExecutionService, if it's currently paused.
// Thus, if you change the code here, please check CancelExecutionService as well.
executionRuntimeServices.setFlowTerminationType(ExecutionStatus.CANCELED);
runEnv.putNextStepPosition(null);
return;
}
if (!isEmpty(runEnv.getExecutionPath().getParentPath())) {
// If it is start of a sub flow then the check should not happen
runEnv.putNextStepPosition(nextStepId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import io.cloudslang.score.events.ScoreEvent;
import io.cloudslang.score.lang.ExecutionRuntimeServices;
import io.cloudslang.score.lang.SystemContext;
import io.cloudslang.worker.management.WorkerConfigurationService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -481,6 +482,11 @@ public ArgumentsBinding argumentsBinding() {
return new ArgumentsBinding();
}

@Bean
public WorkerConfigurationService getWorkerConfigurationService() {
return mock(WorkerConfigurationService.class);
}

@Bean
public ExecutionPreconditionService executionPreconditionService() {
return mock(ExecutionPreconditionService.class);
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
<artifactId>score-api</artifactId>
<version>${score.version}</version>
</dependency>

<dependency>
<groupId>${score.group}</groupId>
<artifactId>score-worker-manager-api</artifactId>
<version>${score.version}</version>
</dependency>
<!-- Exclude the slf4j-log4j12 coming from score to avoid conflicts with log4j-slf4j-impl-->
<dependency>
<groupId>${score.group}</groupId>
Expand Down