-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tasks): add a generic feature toggle for skippable tasks (#4008)
* feat(tasks): add a generic feature toggle for every task This would give us a consistent way to disable any task (moving straight to SKIPPED) without the need for each task implementation to reinvent the wheel. Also: * move toggle computing logic from StartTaskHandler to SkippableTask (this makes this setting overridable) * add documentation to SkippableTask * fix QueueIntegrationTest and StartTaskHandlerTest (the behavior is slightly different now, the task resolver must point to a concrete DummyTask instance so that we can call its `isEnabledPropertyName()` method) * opportunistically reduce mocking code duplication in QueueIntegrationTest
- Loading branch information
Showing
8 changed files
with
153 additions
and
51 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
orca-api/src/main/java/com/netflix/spinnaker/orca/api/pipeline/SkippableTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.netflix.spinnaker.orca.api.pipeline; | ||
|
||
/** | ||
* A skippable task can be configured via properties to go directly from NOT_STARTED to SKIPPED. By | ||
* default, the property name is: | ||
* | ||
* <p>tasks.$taskId.enabled | ||
* | ||
* <p>where `taskId` corresponds to the simple class name (without the package) with a lower case | ||
* first character. For example, a skippable class `com.foo.DummySkippableTask` could be disabled | ||
* via property | ||
* | ||
* <p>tasks.dummySkippableTask.enabled | ||
* | ||
* @see StartTaskHandler | ||
*/ | ||
public interface SkippableTask extends Task { | ||
static String isEnabledPropertyName(String name) { | ||
String loweredName = Character.toLowerCase(name.charAt(0)) + name.substring(1); | ||
return String.format("tasks.%s.enabled", loweredName); | ||
} | ||
|
||
default String isEnabledPropertyName() { | ||
return isEnabledPropertyName( | ||
getClass().getSimpleName().isBlank() ? getClass().getName() : getClass().getSimpleName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.