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

MINOR [GEN-799]: add option to disable manual trigger using scheduleType #17031

Merged
merged 4 commits into from
Jul 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@ WHERE name IN (
'columnValuesSumToBeBetween',
'columnValuesToBeBetween',
'tableRowCountToBeBetween'
);
);

-- Update schedule type for applications
UPDATE installed_apps
SET json = JSON_MERGE_PATCH(json, '{"scheduleType": "ScheduledOrManual"}')
WHERE JSON_UNQUOTE(json->'$.scheduleType') = 'Scheduled';

-- recreate all scheduled apps
DELETE FROM apps_marketplace
WHERE JSON_UNQUOTE(json->'$.scheduleType') = 'Scheduled';
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ WHERE name IN (
'tableRowCountToBeBetween'
);

-- Update schedule type for applications
UPDATE installed_apps
SET json = json || '{"scheduleType": "ScheduledOrManual"}'
WHERE json->>'scheduleType' = 'Scheduled';

-- recreate all scheduled apps
DELETE FROM apps_marketplace
WHERE json->>'scheduleType' = 'Scheduled';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.openmetadata.service.apps.scheduler.AbstractOmAppJobListener.JOB_LISTENER_NAME;
import static org.openmetadata.service.apps.scheduler.AppScheduler.APP_NAME;
import static org.openmetadata.service.exception.CatalogExceptionMessage.LIVE_APP_SCHEDULE_ERR;
import static org.openmetadata.service.exception.CatalogExceptionMessage.NO_MANUAL_TRIGGER_ERR;

import java.util.List;
import lombok.Getter;
Expand Down Expand Up @@ -90,13 +90,13 @@ public void install() {
@Override
public void triggerOnDemand() {
// Validate Native Application
if (app.getScheduleType().equals(ScheduleType.Scheduled)) {
if (app.getScheduleType().equals(ScheduleType.ScheduledOrManual)) {
AppRuntime runtime = getAppRuntime(app);
validateServerExecutableApp(runtime);
// Trigger the application
AppScheduler.getInstance().triggerOnDemandApplication(app);
} else {
throw new IllegalArgumentException(LIVE_APP_SCHEDULE_ERR);
throw new IllegalArgumentException(NO_MANUAL_TRIGGER_ERR);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public final class CatalogExceptionMessage {
public static final String TOKEN_EXPIRY_ERROR =
"Email Verification Token %s is expired. Please issue a new request for email verification.";
public static final String INVALID_BOT_USER = "Revoke Token can only be applied to Bot Users.";
public static final String LIVE_APP_SCHEDULE_ERR = "Live Application cannot scheduled.";
public static final String NO_MANUAL_TRIGGER_ERR = "App does not support manual trigger.";
public static final String INVALID_APP_TYPE = "Application Type is not valid.";

private CatalogExceptionMessage() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"developerUrl": "https://www.getcollate.io",
"privacyPolicyUrl": "https://www.getcollate.io",
"supportEmail": "support@getcollate.io",
"scheduleType": "Scheduled",
"scheduleType": "ScheduledOrManual",
"permission": "All",
"className": "org.openmetadata.service.apps.bundles.insights.DataInsightsApp",
"runtime": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"developerUrl": "https://www.getcollate.io",
"privacyPolicyUrl": "https://www.getcollate.io",
"supportEmail": "support@getcollate.io",
"scheduleType": "Scheduled",
"scheduleType": "ScheduledOrManual",
"permission": "All",
"className": "org.openmetadata.service.apps.bundles.insights.DataInsightsReportApp",
"runtime": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"developerUrl": "https://www.getcollate.io",
"privacyPolicyUrl": "https://www.getcollate.io",
"supportEmail": "support@getcollate.io",
"scheduleType": "Scheduled",
"scheduleType": "ScheduledOrManual",
"permission": "All",
"className": "org.openmetadata.service.apps.bundles.searchIndex.SearchIndexApp",
"runtime": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ void post_trigger_app_200() throws HttpResponseException, InterruptedException {
}
}

@Test
void post_trigger_no_trigger_app_400() {
assertResponseContains(
() -> postTriggerApp("ExampleAppNoTrigger", ADMIN_AUTH_HEADERS),
BAD_REQUEST,
"App does not support manual trigger.");
}

@Override
public void validateCreatedEntity(
App createdEntity, CreateApp request, Map<String, String> authHeaders)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "ExampleAppNoTrigger",
"displayName": "Example App No Trigger",
"appConfiguration": {},
"appSchedule": {
"scheduleTimeline": "Custom",
"cronExpression": "0 0 1/1 * *"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "ExampleAppNoTrigger",
"displayName": "Example App No Trigger",
"description": "An example app without manual trigger.",
"features": "Dont try this at home.",
"appType": "internal",
"appScreenshots": [
],
"developer": "ACME Labs",
"developerUrl": "https://www.example.com",
"privacyPolicyUrl": "https://www.example.com",
"supportEmail": "use@example.com",
"scheduleType": "Scheduled",
"permission": "All",
"className": "org.openmetadata.service.apps.bundles.searchIndex.SearchIndexApp",
"runtime": {
"enabled": true
},
"appConfiguration": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@
"type": "string",
"enum": [
"Live",
"Scheduled"
"Scheduled",
"ScheduledOrManual"
],
"javaEnums": [
{
"name": "Live"
},
{
"name": "Scheduled"
},
{
"name": "ScheduledOrManual"
}
]
},
Expand Down
Loading