Skip to content

Commit

Permalink
ansible: set initial event number
Browse files Browse the repository at this point in the history
If the ansible playbook execution happened faster than the engine, we
may get a successful status and the correct number of events. In that
case we may skip the event processing in the ansible callback. Which may
lead us to wrong data returned to the command itself.

Change-Id: I432938a7fc241701eb260c1fbc460d1de7149092
Signed-off-by: Liran Rotenberg <lrotenbe@redhat.com>
  • Loading branch information
liranr23 committed Jun 27, 2022
1 parent 0e52e51 commit 515c6d0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void doPolling(Guid cmdId, List<Guid> childCmdIds) {
// Process the events if the playbook is running:
totalEvents = runnerClient.getTotalEvents(playUuid);

if (msg.equalsIgnoreCase("running") || msg.equalsIgnoreCase("successful")
if (msg.equalsIgnoreCase("running") || totalEvents == 0 || msg.equalsIgnoreCase("successful")
&& command.getParameters().getLastEventId() < totalEvents) {
command.getParameters().setLastEventId(runnerClient.processEvents(
playUuid, command.getParameters().getLastEventId(), fn, msg, ret.getLogFile()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ protected void executeCommand() {
throw new EngineException(EngineError.GeneralException);
} else {
getParameters().setPlayUuid(ansibleReturnValue.getPlayUuid());
//getParameters().setLastEventId(ansibleReturnValue.getPlayUuid());
getParameters().setLogFile(ansibleReturnValue.getLogFile().toString());
getParameters().setLastEventId(ansibleReturnValue.getLastEventId());
persistCommand(getParameters().getParentCommand(), true);
setSucceeded(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class AnsibleCommandParameters extends ActionParametersBase {
public AnsibleCommandParameters() {
super();
this.playUuid = UUID.randomUUID().toString();
this.lastEventId = 0;
}

public int getLastEventId() {
Expand Down

0 comments on commit 515c6d0

Please sign in to comment.