Skip to content

Commit

Permalink
ansible: Remove unused things
Browse files Browse the repository at this point in the history
None of the removed things are used:
- we never do anything with neither 'msg' nor 'logFile' arguments
  of 'AnsibleRunnerClient.processEvents'
- the 'AnsibleReturnValue' instance created in 'AnsibleCallback.doPolling'
  is used only locally and doesn't affect the logic
  • Loading branch information
tinez authored and tinez committed Jul 27, 2022
1 parent 3e0b763 commit 5dcc52f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.ovirt.engine.core.bll.tasks.interfaces.CommandCallback;
import org.ovirt.engine.core.common.AuditLogType;
import org.ovirt.engine.core.common.action.AnsibleCommandParameters;
import org.ovirt.engine.core.common.utils.ansible.AnsibleReturnCode;
import org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue;
import org.ovirt.engine.core.common.utils.ansible.AnsibleRunnerClient;
import org.ovirt.engine.core.common.utils.ansible.AnsibleRunnerLogger;
import org.ovirt.engine.core.compat.CommandStatus;
Expand Down Expand Up @@ -59,8 +57,6 @@ public void doPolling(Guid cmdId, List<Guid> childCmdIds) {
}
};

AnsibleReturnValue ret = new AnsibleReturnValue(AnsibleReturnCode.ERROR);
ret.setLogFile(runnerClient.getLogger().getLogFile());
int totalEvents;
// Get the current status of the playbook:
AnsibleRunnerClient.PlaybookStatus playbookStatus = runnerClient.getPlaybookStatus(playUuid);
Expand All @@ -72,13 +68,12 @@ public void doPolling(Guid cmdId, List<Guid> childCmdIds) {
if (msg.equalsIgnoreCase("running") || msg.equalsIgnoreCase("successful")
&& command.getParameters().getLastEventId() < totalEvents) {
command.getParameters().setLastEventId(runnerClient.processEvents(
playUuid, command.getParameters().getLastEventId(), fn, msg, ret.getLogFile()));
playUuid, command.getParameters().getLastEventId(), fn));
return;
} else if (msg.equalsIgnoreCase("successful")) {
log.info("Playbook (Play uuid = {}, command = {}) has completed!",
command.getParameters().getPlayUuid(), command.getActionType().name());
// Exit the processing if playbook finished:
ret.setAnsibleReturnCode(AnsibleReturnCode.OK);
command.setSucceeded(true);
command.setCommandStatus(CommandStatus.SUCCEEDED);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public AnsibleReturnValue runCommand(AnsibleCommandConfig commandConfig, int tim
AnsibleReturnValue ret = new AnsibleReturnValue(AnsibleReturnCode.ERROR);

String playUuid = null;
String msg = "";
AnsibleRunnerClient runnerClient = null;
try {
runnerClient = ansibleClientFactory.create(commandConfig);
Expand Down Expand Up @@ -182,7 +181,7 @@ public AnsibleReturnValue runCommand(AnsibleCommandConfig commandConfig, int tim
} finally {
// Make sure all events are proccessed even in case of failure:
if (playUuid != null && runnerClient != null && !async) {
runnerClient.processEvents(playUuid, ret.getLastEventId(), fn, msg, ret.getLogFile());
runnerClient.processEvents(playUuid, ret.getLastEventId(), fn);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -64,7 +63,7 @@ public AnsibleReturnValue artifactHandler(UUID uuid, int lastEventID, int timeou
int executionTime = 0;
setReturnValue(uuid);
while (!playHasEnded(uuid.toString(), lastEventID)) {
lastEventID = processEvents(uuid.toString(), lastEventID, fn, "", Paths.get(""));
lastEventID = processEvents(uuid.toString(), lastEventID, fn);
if (lastEventID == -1) {
return returnValue;
}
Expand Down Expand Up @@ -108,9 +107,7 @@ public String getJobEventsDir(String playUuid) {

public int processEvents(String playUuid,
int lastEventId,
BiConsumer<String, String> fn,
String msg,
Path logFile) {
BiConsumer<String, String> fn) {
String jobEvents = getJobEventsDir(playUuid);
while(true){
// get next event
Expand Down

0 comments on commit 5dcc52f

Please sign in to comment.