-
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-13282] Support manually decommissioning a node from the on-prem…
… provider Summary: Allow user to manually decommission a node from `FREE` to `DECOMMISSIONED` state. This allows user to skip picking up the nodes when a new universe is created. A node placed this way will skip the node cleanup when user tries to recommission a node. Endpoint call is as follows: ``` curl --location --request PUT '<YBA_base_url>:9000/api/v1/customers/<customer_uuid>/providers/<provider_uuid>/instances/<node_instance_ip>/state' \ --header 'X-AUTH-YW-API-TOKEN: <api-token>' \ --header 'Content-Type: application/json' \ --data '{ "state": "DECOMMISSIONED" }' ``` Also, add improvement to prevent race condition between task submitting and finishing before customer task object is saved to YBA db. Test Plan: Added UTs for all below scenarios: 1. User has a node in FREE state and calls the endpoint to set the node instance to `DECOMMISSIONED` state. Validate that the `manually_decommissioned` bit is set as true. If user calls the same endpoint but with state as `FREE` state, we should see the node instance move to `FREE` state with the `manually_decommissioned` bit in YBA db set to false. Also, validate that no clean up is done. 2. Validate original behavior of node being placed in decommissioned state if node cleanup fails and that the `manually_decommissioned` bit is set to false. Also, if we call the endpoint to set the node to `FREE` state, it will run the clean up. Reviewers: nsingh, sanketh, hzare, rmadhavan Reviewed By: nsingh Subscribers: sanketh, yugaware Differential Revision: https://phorge.dev.yugabyte.com/D39747
- Loading branch information
1 parent
e8c9e7d
commit ae0af56
Showing
14 changed files
with
356 additions
and
72 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
46 changes: 46 additions & 0 deletions
46
managed/src/main/java/com/yugabyte/yw/commissioner/tasks/DecommissionNodeInstance.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,46 @@ | ||
// Copyright (c) YugaByte, Inc. | ||
|
||
package com.yugabyte.yw.commissioner.tasks; | ||
|
||
import com.yugabyte.yw.commissioner.AbstractTaskBase; | ||
import com.yugabyte.yw.commissioner.BaseTaskDependencies; | ||
import com.yugabyte.yw.commissioner.tasks.params.DetachedNodeTaskParams; | ||
import com.yugabyte.yw.models.NodeInstance; | ||
import com.yugabyte.yw.models.NodeInstance.State; | ||
import javax.inject.Inject; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class DecommissionNodeInstance extends AbstractTaskBase { | ||
|
||
@Inject | ||
protected DecommissionNodeInstance(BaseTaskDependencies baseTaskDependencies) { | ||
super(baseTaskDependencies); | ||
} | ||
|
||
@Override | ||
protected DetachedNodeTaskParams taskParams() { | ||
return (DetachedNodeTaskParams) taskParams; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
NodeInstance nodeInstance = NodeInstance.getOrBadRequest(taskParams().getNodeUuid()); | ||
|
||
if (nodeInstance.getState() != NodeInstance.State.FREE) { | ||
throw new RuntimeException( | ||
String.format( | ||
"Node instance %s in %s state cannot be manually decommissioned. Node instance must" | ||
+ " be in %s state to be recommissioned.", | ||
nodeInstance.getNodeUuid(), nodeInstance.getState(), NodeInstance.State.FREE)); | ||
} | ||
|
||
nodeInstance.setState(State.DECOMMISSIONED); | ||
nodeInstance.setManuallyDecommissioned(true); | ||
nodeInstance.update(); | ||
log.debug( | ||
"Successfully set node instance {} to {} state", | ||
nodeInstance.getNodeUuid(), | ||
State.DECOMMISSIONED); | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
.../src/main/resources/db/migration/default_/common/V382__alter_node_instance_Add_column.sql
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,3 @@ | ||
-- Copyright (c) YugaByte, Inc. | ||
|
||
ALTER TABLE IF EXISTS node_instance ADD COLUMN if NOT EXISTS manually_decommissioned boolean DEFAULT false NOT NULL; |
Oops, something went wrong.