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

Method remove

src/resource_provider/daemon.cpp:312–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310
311
312Future<Nothing> LocalResourceProviderDaemonProcess::remove(
313 const string& type,
314 const string& name)
315{
316 if (configDir.isNone()) {
317 return Failure("Missing required flag --resource_provider_config_dir");
318 }
319
320 // Do nothing if the info has been removed for idempotency.
321 if (!providers[type].contains(name)) {
322 return Nothing();
323 }
324
325 ProviderData& data = providers[type].at(name);
326
327 // Return the same future if it is being removed for idempotency.
328 if (data.removing.isSome() && data.removing->isPending()) {
329 return data.removing.get();
330 }
331
332 // Destruct the resource provider instance to stop its container daemons, then
333 // do a best-effort cleanup of the standalone containers launched by the
334 // removed resource provider.
335 // TODO(chhsiao): This is not ideal since the daemon does not know how to
336 // perform resource-provider-specific cleanups. We should refactor this into a
337 // `LocalResourceProvider::stop` virtual function. However this also means
338 // that we need to ensure that we must have a resource provider instance with
339 // a running actor to invoke `stop`. Given that `launch` is asynchronous, we
340 // need to carefully redesign the state machine, and the semantics of the
341 // `{ADD,UPDATE,REMOVE}_RESOURCE_PROVIDER_CONFIG` API calls might be affected.
342 // In addition, we should consider how to reconcile orphaned containers.
343 data.provider.reset();
344 data.removing = cleanupContainers(data.info, data.authToken)
345 .then(defer(self(), [this, type, name]() -> Future<Nothing> {
346 Try<Nothing> rm = os::rm(providers[type].at(name).path);
347 if (rm.isError()) {
348 return Failure(
349 "Failed to remove config file '" + providers[type].at(name).path +
350 "': " + rm.error());
351 }
352
353 providers[type].erase(name);
354 return Nothing();
355 }));
356
357 return data.removing.get();
358}
359
360
361void LocalResourceProviderDaemonProcess::initialize()

Callers

nothing calls this directly

Calls 15

FailureClass · 0.85
NothingClass · 0.85
deferFunction · 0.85
atMethod · 0.80
errorMethod · 0.65
rmFunction · 0.50
dispatchFunction · 0.50
isNoneMethod · 0.45
containsMethod · 0.45
isSomeMethod · 0.45
isPendingMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected