提交 04a874ac 编写于 作者: I Ing. Pavel Janousek

[JENKINS-31098] Deletage remove a node back to Computer.doDoDelete()

上级 6aba76dc
...@@ -29,6 +29,7 @@ import hudson.model.Node; ...@@ -29,6 +29,7 @@ import hudson.model.Node;
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Argument;
import java.nio.file.AccessDeniedException;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -77,15 +78,12 @@ public class DeleteNodeCommand extends CLICommand { ...@@ -77,15 +78,12 @@ public class DeleteNodeCommand extends CLICommand {
continue; continue;
} }
try { node.toComputer().doDoDelete();
node.checkPermission(Computer.DELETE); } catch (AccessDeniedException e) {
} catch (Exception e) { stderr.println(e.getMessage());
stderr.println(e.getMessage()); errorOccurred = true;
errorOccurred = true; //noinspection UnnecessaryContinue
continue; continue;
}
jenkins.removeNode(node);
} catch (Exception e) { } catch (Exception e) {
final String errorMsg = String.format("Unexpected exception occurred during deletion of node '%s': %s", final String errorMsg = String.format("Unexpected exception occurred during deletion of node '%s': %s",
node == null ? "(null)" : node.toComputer().getName(), node == null ? "(null)" : node.toComputer().getName(),
......
...@@ -48,7 +48,7 @@ public class DeleteNodeCommandTest { ...@@ -48,7 +48,7 @@ public class DeleteNodeCommandTest {
@Before public void setUp() { @Before public void setUp() {
command = new CLICommandInvoker(j, new DeleteNodeCommand()); command = new CLICommandInvoker(j, "delete-node");
} }
@Test public void deleteNodeShouldFailWithoutNodeDeletePermission() throws Exception { @Test public void deleteNodeShouldFailWithoutNodeDeletePermission() throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册