Skip to content

Commit

Permalink
fix(titus): Loading front50 app should be optional (#3955)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed Aug 16, 2019
1 parent 8cf11dd commit 8e37e6a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public Result apply(@NotNull LoadFront50AppCommand command, @NotNull Saga saga)
}
} catch (Exception e) {
log.error("Failed to load front50 application attributes for {}", command.getAppName(), e);
if (command.isAllowMissing()) {
// It's ok to not load the front50 application
return new Result();
}
throw new SystemException(
format("Failed to load front50 application: %s", command.getAppName()), e);
}
Expand All @@ -128,25 +132,24 @@ public Result apply(@NotNull LoadFront50AppCommand command, @NotNull Saga saga)
public static class LoadFront50AppCommand extends SagaCommand {
@Nonnull private final String appName;
@Nonnull private final SagaCommand nextCommand;
@Nonnull private final boolean allowMissing;

public LoadFront50AppCommand(
@NotNull String sagaName,
@NotNull String sagaId,
@Nonnull String appName,
@Nonnull SagaCommand nextCommand) {
@Nonnull SagaCommand nextCommand,
boolean allowMissing) {
super(sagaName, sagaId);
this.appName = appName;
this.nextCommand = nextCommand;
this.allowMissing = allowMissing;
}
}

/**
* Marks a SagaCommand as being aware of the result of the LoadFront50App SagaAction.
*
* <p>TODO(rz): Refactor SagaCommand (and by proxy, SpinnakerEvent) to be an interface
*/
/** Marks a SagaCommand as being aware of the result of the LoadFront50App SagaAction. */
interface Front50AppAware {
void setFront50App(@Nonnull Front50App app);
void setFront50App(Front50App app);
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public PrepareTitusDeployCommand(
}

@Override
public void setFront50App(@Nonnull LoadFront50App.Front50App app) {
public void setFront50App(LoadFront50App.Front50App app) {
this.front50App = app;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static class SubmitTitusJobCommand extends SagaCommand implements Front50
@Nonnull private final SubmitJobRequest submitJobRequest;
@Nonnull private final String nextServerGroupName;
@Nullable private final TargetGroupLookupHelper.TargetGroupLookupResult targetGroupLookupResult;
@NonFinal private LoadFront50App.Front50App front50App;
@Nullable @NonFinal private LoadFront50App.Front50App front50App;

public SubmitTitusJobCommand(
@NotNull String sagaName,
Expand All @@ -184,7 +184,7 @@ public SubmitTitusJobCommand(
}

@Override
public void setFront50App(@Nonnull LoadFront50App.Front50App app) {
public void setFront50App(LoadFront50App.Front50App app) {
this.front50App = app;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public TitusDeploymentResult handle(
sagaName,
sagaId,
inputDescription.getApplication(),
new PrepareTitusDeployCommand(sagaName, sagaId, inputDescription)));
new PrepareTitusDeployCommand(sagaName, sagaId, inputDescription),
true));

if (result == null) {
// "This should never happen"
Expand Down

0 comments on commit 8e37e6a

Please sign in to comment.