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

Method nestedCommandCheck

src/checks/checker_process.cpp:599–670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597
598
599Future<int> CheckerProcess::nestedCommandCheck(
600 const check::Command& cmd,
601 const runtime::Nested& nested)
602{
603 VLOG(1) << "Launching " << name << " for task '" << taskId << "'";
604
605 // We don't want recoverable errors, e.g., the agent responding with
606 // HTTP status code 503, to trigger a check failure.
607 //
608 // The future returned by this method represents the result of a
609 // check. It will be set to the exit status of the check command if it
610 // succeeded, to a `Failure` if there was a non-transient error, and
611 // discarded if there was a transient error.
612 auto promise = std::make_shared<Promise<int>>();
613
614 if (previousCheckContainerId.isSome()) {
615 agent::Call call;
616 call.set_type(agent::Call::REMOVE_NESTED_CONTAINER);
617
618 mesos::ContainerID previousId = previousCheckContainerId.get();
619
620 agent::Call::RemoveNestedContainer* removeContainer =
621 call.mutable_remove_nested_container();
622
623 removeContainer->mutable_container_id()->CopyFrom(
624 previousCheckContainerId.get());
625
626 http::Request request;
627 request.method = "POST";
628 request.url = nested.agentURL;
629 request.body = serialize(ContentType::PROTOBUF, evolve(call));
630 request.headers = {{"Accept", stringify(ContentType::PROTOBUF)},
631 {"Content-Type", stringify(ContentType::PROTOBUF)}};
632
633 if (nested.authorizationHeader.isSome()) {
634 request.headers["Authorization"] = nested.authorizationHeader.get();
635 }
636
637 http::request(request, false)
638 .onFailed(defer(self(),
639 [this, promise, previousId](const string& failure) {
640 LOG(WARNING) << "Connection to remove the nested container '"
641 << previousId << "' used for the " << name << " for"
642 << " task '" << taskId << "' failed: " << failure;
643
644 // Something went wrong while sending the request, we treat this
645 // as a transient failure and discard the promise.
646 promise->discard();
647 }))
648 .onReady(defer(self(),
649 [this, promise, cmd, nested, previousId]
650 (const http::Response& response) {
651 if (response.code != http::Status::OK) {
652 // The agent was unable to remove the check container, we
653 // treat this as a transient failure and discard the promise.
654 LOG(WARNING) << "Received '" << response.status << "' ("
655 << response.body << ") while removing the nested"
656 << " container '" << previousId << "' used for"

Callers

nothing calls this directly

Calls 11

requestFunction · 0.85
deferFunction · 0.85
NoneClass · 0.85
CopyFromMethod · 0.80
serializeFunction · 0.50
evolveFunction · 0.50
stringifyFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45
discardMethod · 0.45
futureMethod · 0.45

Tested by

no test coverage detected