Skip to content
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

Remap names in disabled actions list #2173

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ public enum SingularityAction {
DISABLE_ACTION(false),
ENABLE_ACTION(false),
VIEW_DISASTERS(false),
@Deprecated
FREEZE_SLAVE(true),
FREEZE_AGENT(true),
@Deprecated
ACTIVATE_SLAVE(true),
ACTIVATE_AGENT(true),
@Deprecated
DECOMMISSION_SLAVE(true),
DECOMMISSION_AGENT(true),
@Deprecated
VIEW_SLAVES(false),
VIEW_AGENTS(false),
FREEZE_RACK(true),
ACTIVATE_RACK(true),
DECOMMISSION_RACK(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,21 @@ public SingularityDisabledAction getDisabledAction(SingularityAction action) {
new SingularityDisabledAction(
action,
String.format(MESSAGE_FORMAT, action, DEFAULT_MESSAGE),
Optional.<String>empty(),
Optional.empty(),
Copy link
Contributor

@rosalind210 rosalind210 Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarification for me, why are you removing the <String> and <Long>?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

general cleanup. They were needed in older java versions, but not in newer ones. Been cleaning up files as I happen to edit them for other reasons

false,
Optional.<Long>empty()
Optional.empty()
)
);
}

public SingularityCreateResult disable(
SingularityAction action,
SingularityAction input,
Optional<String> maybeMessage,
Optional<SingularityUser> user,
boolean systemGenerated,
Optional<Long> expiresAt
) {
SingularityAction action = mapAction(input);
if (!action.isCanDisable()) {
throw new IllegalArgumentException(
String.format("Action %s cannot be disabled", action)
Expand All @@ -90,7 +91,7 @@ public SingularityCreateResult disable(
SingularityDisabledAction disabledAction = new SingularityDisabledAction(
action,
String.format(MESSAGE_FORMAT, action, maybeMessage.orElse(DEFAULT_MESSAGE)),
user.isPresent() ? Optional.of(user.get().getId()) : Optional.<String>empty(),
user.map(SingularityUser::getId),
systemGenerated,
expiresAt
);
Expand All @@ -99,7 +100,22 @@ public SingularityCreateResult disable(
}

public SingularityDeleteResult enable(SingularityAction action) {
return delete(getActionPath(action));
return delete(getActionPath(mapAction(action)));
}

private SingularityAction mapAction(SingularityAction action) {
switch (action) {
case FREEZE_SLAVE:
return SingularityAction.FREEZE_AGENT;
case ACTIVATE_SLAVE:
return SingularityAction.ACTIVATE_AGENT;
case DECOMMISSION_SLAVE:
return SingularityAction.DECOMMISSION_AGENT;
case VIEW_SLAVES:
return SingularityAction.VIEW_AGENTS;
default:
return action;
}
}

public List<SingularityDisabledAction> getDisabledActions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void decommissionAgent(
agentId,
maybeChangeRequest,
user,
SingularityAction.DECOMMISSION_SLAVE
SingularityAction.DECOMMISSION_AGENT
);
}

Expand Down Expand Up @@ -206,7 +206,7 @@ public void freezeAgent(
final Optional<SingularityMachineChangeRequest> maybeChangeRequest = Optional.ofNullable(
changeRequest
);
super.freeze(agentId, maybeChangeRequest, user, SingularityAction.FREEZE_SLAVE);
super.freeze(agentId, maybeChangeRequest, user, SingularityAction.FREEZE_AGENT);
}

@POST
Expand Down Expand Up @@ -244,7 +244,7 @@ public void activateAgent(
final Optional<SingularityMachineChangeRequest> maybeChangeRequest = Optional.ofNullable(
changeRequest
);
super.activate(agentId, maybeChangeRequest, user, SingularityAction.ACTIVATE_SLAVE);
super.activate(agentId, maybeChangeRequest, user, SingularityAction.ACTIVATE_AGENT);
}

@DELETE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void decommissionSlave(
slaveId,
maybeChangeRequest,
user,
SingularityAction.DECOMMISSION_SLAVE
SingularityAction.DECOMMISSION_AGENT
);
}

Expand Down Expand Up @@ -210,7 +210,7 @@ public void freezeSlave(
final Optional<SingularityMachineChangeRequest> maybeChangeRequest = Optional.ofNullable(
changeRequest
);
super.freeze(slaveId, maybeChangeRequest, user, SingularityAction.FREEZE_SLAVE);
super.freeze(slaveId, maybeChangeRequest, user, SingularityAction.FREEZE_AGENT);
}

@POST
Expand Down Expand Up @@ -248,7 +248,7 @@ public void activateSlave(
final Optional<SingularityMachineChangeRequest> maybeChangeRequest = Optional.ofNullable(
changeRequest
);
super.activate(slaveId, maybeChangeRequest, user, SingularityAction.ACTIVATE_SLAVE);
super.activate(slaveId, maybeChangeRequest, user, SingularityAction.ACTIVATE_AGENT);
}

@DELETE
Expand Down