MCPcopy Create free account
hub / github.com/apache/mesos / _deactivateAgent

Method _deactivateAgent

src/master/http.cpp:3894–3927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3892
3893
3894Future<Response> Master::Http::_deactivateAgent(
3895 const SlaveID& slaveId,
3896 const Owned<ObjectApprovers>& approvers) const
3897{
3898 if (!approvers->approved<DEACTIVATE_AGENT>()) {
3899 return Forbidden();
3900 }
3901
3902 // Check that the agent is either recovering, registered, or unreachable.
3903 if (!master->slaves.recovered.contains(slaveId) &&
3904 !master->slaves.registered.contains(slaveId) &&
3905 !master->slaves.unreachable.contains(slaveId)) {
3906 return BadRequest("Unknown agent");
3907 }
3908
3909 // Save the deactivation to the registry.
3910 return master->registrar->apply(Owned<RegistryOperation>(
3911 new DeactivateAgent(slaveId)))
3912 .onAny([](const Future<bool>& result) {
3913 CHECK_READY(result)
3914 << "Failed to deactivate agent in the registry";
3915 })
3916 .then(defer(master->self(), [this, slaveId](bool result) -> Response {
3917 // Deactivate the agent.
3918 master->slaves.deactivated.insert(slaveId);
3919
3920 Slave* slave = master->slaves.registered.get(slaveId);
3921 if (slave != nullptr) {
3922 master->deactivate(slave);
3923 }
3924
3925 return OK();
3926 }));
3927}
3928
3929
3930Future<Response> Master::Http::deactivateAgent(

Callers

nothing calls this directly

Calls 11

ForbiddenClass · 0.85
BadRequestClass · 0.85
deferFunction · 0.85
OKClass · 0.85
insertMethod · 0.80
containsMethod · 0.45
thenMethod · 0.45
applyMethod · 0.45
selfMethod · 0.45
getMethod · 0.45
deactivateMethod · 0.45

Tested by

no test coverage detected