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

Method updateSlave

src/master/allocator/mesos/hierarchical.cpp:1112–1174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1110
1111
1112void HierarchicalAllocatorProcess::updateSlave(
1113 const SlaveID& slaveId,
1114 const SlaveInfo& info,
1115 const Option<Resources>& total,
1116 const Option<vector<SlaveInfo::Capability>>& capabilities)
1117{
1118 CHECK(initialized);
1119 CHECK_EQ(slaveId, info.id());
1120
1121 Slave& slave = *CHECK_NOTNONE(getSlave(slaveId));
1122
1123 bool updated = false;
1124
1125 // Remove all offer filters for this slave if it was restarted with changed
1126 // attributes. We do this because schedulers might have decided that they're
1127 // not interested in offers from this slave based on the non-presence of some
1128 // required attributes, and right now they have no other way of learning
1129 // about this change.
1130 // TODO(bennoe): Once the agent lifecycle design is implemented, there is a
1131 // better way to notify frameworks about such changes and let them make this
1132 // decision. We should think about ways to safely remove this check at that
1133 // point in time.
1134 if (!(Attributes(info.attributes()) == Attributes(slave.info.attributes()))) {
1135 updated = true;
1136 removeFilters(slaveId);
1137 }
1138
1139 if (!(slave.info == info)) {
1140 updated = true;
1141
1142 // We unconditionally overwrite the old domain and hostname: Even though
1143 // the master places some restrictions on this (i.e. agents are not allowed
1144 // to reregister with a different hostname) inside the allocator it
1145 // doesn't matter, as the algorithm will work correctly either way.
1146 slave.info = info;
1147 }
1148
1149 // Update agent capabilities.
1150 if (capabilities.isSome()) {
1151 protobuf::slave::Capabilities newCapabilities(capabilities.get());
1152 protobuf::slave::Capabilities oldCapabilities(slave.capabilities);
1153
1154 slave.capabilities = newCapabilities;
1155
1156 if (newCapabilities != oldCapabilities) {
1157 updated = true;
1158
1159 LOG(INFO) << "Agent " << slaveId << " (" << slave.info.hostname() << ")"
1160 << " updated with capabilities " << slave.capabilities;
1161 }
1162 }
1163
1164 if (total.isSome()) {
1165 updated = updateSlaveTotal(slaveId, total.get()) || updated;
1166
1167 LOG(INFO) << "Agent " << slaveId << " (" << slave.info.hostname() << ")"
1168 << " updated with total resources " << total.get();
1169 }

Callers

nothing calls this directly

Calls 5

getSlaveFunction · 0.85
AttributesClass · 0.50
idMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected