-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAT-15097]: Delete System platform DB table while disabling ysql
Summary: Add changes to drop write_read_test table, consistency_check table while disabling ysql Test Plan: Tested manually on k8s and VM-based universe and verified that table no longer exists from master UI Reviewers: #yba-api-review!, sneelakantan, svarshney, muthu Reviewed By: svarshney, muthu Subscribers: muthu, yugaware Differential Revision: https://phorge.dev.yugabyte.com/D37892
- Loading branch information
Showing
10 changed files
with
167 additions
and
41 deletions.
There are no files selected for viewing
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
70 changes: 70 additions & 0 deletions
70
managed/src/main/java/com/yugabyte/yw/commissioner/tasks/subtasks/DropTable.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,70 @@ | ||
// Copyright (c) YugaByte, Inc. | ||
|
||
package com.yugabyte.yw.commissioner.tasks.subtasks; | ||
|
||
import com.yugabyte.yw.commissioner.BaseTaskDependencies; | ||
import com.yugabyte.yw.commissioner.tasks.UniverseTaskBase; | ||
import com.yugabyte.yw.common.PlatformServiceException; | ||
import com.yugabyte.yw.common.YcqlQueryExecutor; | ||
import com.yugabyte.yw.common.YsqlQueryExecutor; | ||
import com.yugabyte.yw.forms.UniverseTaskParams; | ||
import com.yugabyte.yw.models.Universe; | ||
import java.time.Duration; | ||
import javax.inject.Inject; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.yb.CommonTypes; | ||
|
||
@Slf4j | ||
public class DropTable extends UniverseTaskBase { | ||
@Inject | ||
protected DropTable(BaseTaskDependencies baseTaskDependencies) { | ||
super(baseTaskDependencies); | ||
} | ||
|
||
private static long WAIT_TIME_IN_MILLIS = 5000; | ||
|
||
@Inject YsqlQueryExecutor ysqlQueryExecutor; | ||
@Inject YcqlQueryExecutor ycqlQueryExecutor; | ||
|
||
public static class Params extends UniverseTaskParams { | ||
public String dbName; | ||
public String tableName; | ||
public CommonTypes.TableType tableType; | ||
} | ||
|
||
protected Params taskParams() { | ||
return (Params) taskParams; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return super.getName() + "(" + taskParams().getUniverseUUID() + ")"; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
log.info("Running {}", getName()); | ||
Universe universe = Universe.getOrBadRequest(taskParams().getUniverseUUID()); | ||
if (taskParams().tableType.equals(CommonTypes.TableType.PGSQL_TABLE_TYPE)) { | ||
try { | ||
ysqlQueryExecutor.dropTable(universe, taskParams().dbName, taskParams().tableName); | ||
waitFor(Duration.ofMillis(WAIT_TIME_IN_MILLIS)); | ||
} catch (PlatformServiceException e) { | ||
log.error("Error dropping table: " + e.getMessage()); | ||
throw e; | ||
} | ||
} else if (taskParams().tableType.equals(CommonTypes.TableType.YQL_TABLE_TYPE)) { | ||
throw new UnsupportedOperationException( | ||
"Un-implemented table type: " + taskParams().tableType); | ||
} else { | ||
throw new IllegalArgumentException("Unsupported table type: " + taskParams().tableType); | ||
} | ||
} catch (Exception e) { | ||
String msg = getName() + " failed with exception " + e.getMessage(); | ||
log.warn(msg, e.getMessage()); | ||
throw new RuntimeException(msg, e); | ||
} | ||
log.info("Completed {}", getName()); | ||
} | ||
} |
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.