Skip to content

Commit af0b1ee

Browse files
committed
[PLAT-12950]Allow aborting Support bundle task
Summary: Allow aborting support bundle creation task. Bundles are marked as `Aborted` and cleaned up by the GC. Test Plan: Verified that cancellation of support bundle creation task works and the left behind files are cleaned up by the GC. Reviewers: #yba-api-review!, nsingh, skurapati Reviewed By: skurapati Subscribers: anijhawan, sanketh, yugaware Differential Revision: https://phorge.dev.yugabyte.com/D40634
1 parent 6299bad commit af0b1ee

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

managed/src/main/java/com/yugabyte/yw/commissioner/SupportBundleCleanup.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ void scheduleRunner() {
6565
public synchronized void deleteSupportBundleIfOld(SupportBundle supportBundle)
6666
throws ParseException {
6767
int default_delete_days = config.getInt("yb.support_bundle.retention_days");
68-
69-
if (supportBundle.getStatus() == SupportBundleStatusType.Failed) {
68+
SupportBundleStatusType status = supportBundle.getStatus();
69+
if (status == SupportBundleStatusType.Failed || status == SupportBundleStatusType.Aborted) {
7070
supportBundleUtil.deleteSupportBundle(supportBundle);
7171

7272
log.info(
73-
"Automatically deleted Support Bundle with UUID: {}, with status = Failed",
74-
supportBundle.getBundleUUID());
73+
"Automatically deleted Support Bundle with UUID: {}, with status = {}",
74+
supportBundle.getBundleUUID(),
75+
status);
7576
} else if (supportBundle.getStatus() == SupportBundleStatusType.Running) {
7677
return;
7778
} else {

managed/src/main/java/com/yugabyte/yw/commissioner/tasks/CreateSupportBundle.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.typesafe.config.Config;
1717
import com.yugabyte.yw.commissioner.AbstractTaskBase;
1818
import com.yugabyte.yw.commissioner.BaseTaskDependencies;
19+
import com.yugabyte.yw.commissioner.ITask.Abortable;
1920
import com.yugabyte.yw.commissioner.TaskExecutor.SubTaskGroup;
2021
import com.yugabyte.yw.commissioner.tasks.params.SupportBundleTaskParams;
2122
import com.yugabyte.yw.commissioner.tasks.subtasks.CheckNodeReachable;
@@ -34,6 +35,7 @@
3435
import com.yugabyte.yw.models.Customer;
3536
import com.yugabyte.yw.models.SupportBundle;
3637
import com.yugabyte.yw.models.SupportBundle.SupportBundleStatusType;
38+
import com.yugabyte.yw.models.TaskInfo;
3739
import com.yugabyte.yw.models.Universe;
3840
import com.yugabyte.yw.models.helpers.BundleDetails;
3941
import com.yugabyte.yw.models.helpers.NodeDetails;
@@ -52,6 +54,7 @@
5254
import play.libs.Json;
5355

5456
@Slf4j
57+
@Abortable
5558
public class CreateSupportBundle extends AbstractTaskBase {
5659

5760
@Inject private UniverseInfoHandler universeInfoHandler;
@@ -86,11 +89,17 @@ public void run() {
8689
operatorStatusUpdater.markSupportBundleFinished(
8790
supportBundle, taskParams().getKubernetesResourceDetails(), gzipPath);
8891
} catch (Exception e) {
89-
taskParams().supportBundle.setStatus(SupportBundleStatusType.Failed);
90-
operatorStatusUpdater.markSupportBundleFailed(
91-
supportBundle, taskParams().getKubernetesResourceDetails());
92-
Throwables.throwIfUnchecked(e);
93-
throw new RuntimeException(e);
92+
TaskInfo taskInfo = getRunnableTask().getTaskInfo();
93+
if (taskInfo.getTaskState().equals(TaskInfo.State.Abort)) {
94+
log.info("Marking support bundle with UUID: {} as aborted.", supportBundle.getBundleUUID());
95+
supportBundle.setStatus(SupportBundleStatusType.Aborted);
96+
} else {
97+
supportBundle.setStatus(SupportBundleStatusType.Failed);
98+
operatorStatusUpdater.markSupportBundleFailed(
99+
supportBundle, taskParams().getKubernetesResourceDetails());
100+
Throwables.throwIfUnchecked(e);
101+
throw new RuntimeException(e);
102+
}
94103
} finally {
95104
supportBundle.update();
96105
}

managed/src/main/java/com/yugabyte/yw/models/SupportBundle.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public class SupportBundle extends Model {
8282
public enum SupportBundleStatusType {
8383
Running("Running"),
8484
Success("Success"),
85-
Failed("Failed");
85+
Failed("Failed"),
86+
Aborted("Aborted");
8687

8788
private final String status;
8889

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Copyright (c) YugaByte, Inc.
2+
3+
alter table if exists support_bundle drop constraint if exists ck_support_bundle_status;
4+
5+
alter table if exists support_bundle add constraint ck_support_bundle_status check (status in ('Running','Success','Failed','Aborted'));

managed/src/main/resources/swagger-strict.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12708,7 +12708,7 @@
1270812708
"type" : "string"
1270912709
},
1271012710
"status" : {
12711-
"enum" : [ "Running", "Success", "Failed" ],
12711+
"enum" : [ "Running", "Success", "Failed", "Aborted" ],
1271212712
"type" : "string"
1271312713
}
1271412714
},

managed/src/main/resources/swagger.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12825,7 +12825,7 @@
1282512825
"type" : "string"
1282612826
},
1282712827
"status" : {
12828-
"enum" : [ "Running", "Success", "Failed" ],
12828+
"enum" : [ "Running", "Success", "Failed", "Aborted" ],
1282912829
"type" : "string"
1283012830
}
1283112831
},

0 commit comments

Comments
 (0)