| 12793 | |
| 12794 | |
| 12795 | void Slave::markOperationAsOrphan(Operation* operation) |
| 12796 | { |
| 12797 | // Only non-speculative operations can be orphaned. |
| 12798 | if (protobuf::isSpeculativeOperation(operation->info())) { |
| 12799 | return; |
| 12800 | } |
| 12801 | |
| 12802 | LOG(INFO) << "Marking operation " << operation->uuid() |
| 12803 | << (operation->info().has_id() |
| 12804 | ? " (ID: " + operation->info().id().value() + ")" |
| 12805 | : "") |
| 12806 | << (operation->has_slave_id() |
| 12807 | ? " (Agent: " + operation->slave_id().value() + ")" |
| 12808 | : "") |
| 12809 | << (operation->has_framework_id() |
| 12810 | ? " (Framework: " + operation->framework_id().value() + ")" |
| 12811 | : "") |
| 12812 | << " in state " << operation->latest_status().state() |
| 12813 | << " as an orphan"; |
| 12814 | |
| 12815 | orphanedOperations.insert(operation->uuid()); |
| 12816 | |
| 12817 | // Only non-terminal orphans require additional resource math. |
| 12818 | if (protobuf::isTerminalState(operation->latest_status().state())) { |
| 12819 | return; |
| 12820 | } |
| 12821 | |
| 12822 | // Orphaned operations have no framework, and hence cannot be accounted |
| 12823 | // for within the allocator. Instead, the operation's resources are removed |
| 12824 | // from the agent's total resources until the operation terminates. |
| 12825 | recoverResources(operation); |
| 12826 | |
| 12827 | Try<Resources> consumed = protobuf::getConsumedResources(operation->info()); |
| 12828 | CHECK_SOME(consumed); |
| 12829 | |
| 12830 | Resources consumedUnallocated = consumed.get(); |
| 12831 | consumedUnallocated.unallocate(); |
| 12832 | |
| 12833 | CHECK(totalResources.contains(consumedUnallocated)) |
| 12834 | << "Unknown resources from orphan operation: " << consumedUnallocated; |
| 12835 | |
| 12836 | totalResources -= consumedUnallocated; |
| 12837 | } |
| 12838 | |
| 12839 | |
| 12840 | Operation* Slave::getOperation(const UUID& uuid) const |
no test coverage detected