-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add decommission capability and removenode cmd #18530
Conversation
addresses #18495 (comment) |
Optional<WorkerInfo> targetWorker = getAllMembers().getWorkerById(worker.getIdentity()); | ||
if (!targetWorker.isPresent()) { | ||
throw new InvalidArgumentException( | ||
String.format("Unrecognized or non-existing worker:%s", worker.getIdentity())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String.format("Unrecognized or non-existing worker:%s", worker.getIdentity())); | |
String.format("Unrecognized or non-existing worker: %s", worker.getIdentity())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// Worker should already be offline | ||
if (targetWorker.get().getState() != WorkerState.LOST) { | ||
throw new InvalidArgumentException( | ||
String.format("Can't decommission running worker:%s, stop the worker" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String.format("Can't decommission running worker:%s, stop the worker" | |
String.format("Can't decommission running worker: %s, stop the worker" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* @return WorkerIdentity object | ||
* @throws InvalidArgumentException | ||
*/ | ||
public static WorkerIdentity fromString(String workerIdentityStr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this method close to toString
so that hopefully people will remember to keep the two implementations compatible when they change either of them in the future. Also please add a unit test to ensure the string representation generated by toString
can be correctly parsed by fromString
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done and done
|
||
@Override | ||
public String getUsage() { | ||
return "remove"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usage string looks like getCommandName() + " -n <worker_id> | -h"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for catching, done
|
||
@Override | ||
public String getDescription() { | ||
return "Remove given worker from the cluster"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "Remove given worker from the cluster"; | |
return "Remove a worker from the cluster, so that clients and other workers will not consider the removed worker for services. The worker must have been stopped before it can be safely removed from the cluster."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
membershipManager.decommission( | ||
new WorkerInfo().setIdentity(WorkerIdentity.fromString(workerId))); | ||
mPrintStream.println(String.format( | ||
"Successfully decommissioned worker:%s", workerId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Successfully decommissioned worker:%s", workerId)); | |
"Successfully decommissioned worker: %s", workerId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
String prefix = "worker-"; | ||
String errStr = "Unrecognized worker identity string."; | ||
if (!workerIdentityStr.startsWith(prefix)) { | ||
throw new InvalidArgumentException(errStr); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think missing the worker-
prefix warrants an error, i.e. both worker-1
and 1
should be considered valid inputs, and the parser should be tolerant of the optional prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i actually wanted to make sure tostring and fromstring are strictly paired, i've also added the warning comment should someone wants to change it.
try { | ||
return ParserV0.INSTANCE.fromLong(Long.parseLong(idStr)); | ||
} catch (NumberFormatException ex) { | ||
throw new InvalidArgumentException(errStr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Echo user input:
throw new InvalidArgumentException(errStr); | |
throw new InvalidArgumentException(errStr + ": " + workerIdentityStr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,97 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also make changes to nodes.go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes Rico is making the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added now with the running format:
bin/alluxio process remove-worker -n <worker_id>
membershipManager.decommission( | ||
new WorkerInfo().setIdentity(WorkerIdentity.fromString(workerId))); | ||
mPrintStream.println(String.format( | ||
"Successfully decommissioned worker: %s", workerId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Successfully decommissioned worker: %s", workerId)); | |
"Successfully removed worker from membership: %s", workerId)); |
i'd avoid using the word "decommission" from the user facing side as much as possible to avoid confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
dora/shell/src/main/java/alluxio/cli/fsadmin/nodes/RemoveWorkerCommand.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will you add the golang cli code as part of this PR?
just realized i haven't pushed yesterday, i just pushed the changes, can u take a quick look ? |
@@ -0,0 +1,46 @@ | |||
package process |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing license header in new file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…rCommand.java Co-authored-by: Bowen Ding <[email protected]>
alluxio-bot, merge this please. |
What changes are proposed in this pull request?
Add decommission capability for worker and removenode cli cmd to remove node from etcd registration
Why are the changes needed?
to add decommission capability for worker
Does this PR introduce any user facing changes?
New cli added for remove worker node