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

Method doReliableRegistration

src/slave/slave.cpp:1953–2139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1951
1952
1953void Slave::doReliableRegistration(Duration maxBackoff)
1954{
1955 if (master.isNone()) {
1956 LOG(INFO) << "Skipping registration because no master present";
1957 return;
1958 }
1959
1960 if (credential.isSome() && !authenticated) {
1961 LOG(INFO) << "Skipping registration because not authenticated";
1962 return;
1963 }
1964
1965 if (state == RUNNING) { // Slave (re-)registered with the master.
1966 return;
1967 }
1968
1969 if (state == TERMINATING) {
1970 LOG(INFO) << "Skipping registration because agent is terminating";
1971 return;
1972 }
1973
1974 CHECK(state == DISCONNECTED) << state;
1975
1976 CHECK_NE("cleanup", flags.recover);
1977
1978 // Ensure there is a link to the master before we start
1979 // communicating with it. We want to link after the initial
1980 // registration backoff in order to avoid all of the agents
1981 // establishing connections with the master at once.
1982 // See MESOS-5330.
1983 link(master.get());
1984
1985 if (!info.has_id()) {
1986 // Registering for the first time.
1987 RegisterSlaveMessage message;
1988 message.set_version(MESOS_VERSION);
1989 message.mutable_slave()->CopyFrom(info);
1990
1991 message.mutable_agent_capabilities()->CopyFrom(
1992 capabilities.toRepeatedPtrField());
1993
1994 // Include checkpointed resources.
1995 message.mutable_checkpointed_resources()->CopyFrom(checkpointedResources);
1996
1997 message.mutable_resource_version_uuid()->CopyFrom(resourceVersion);
1998
1999 // If the `Try` from `downgradeResources` returns an `Error`, we currently
2000 // continue to send the resources to the master in a partially downgraded
2001 // state. This implies that an agent with refined reservations cannot work
2002 // with versions of master before reservation refinement support, which was
2003 // introduced in 1.4.0.
2004 //
2005 // TODO(mpark): Do something smarter with the result once something
2006 // like a master capability is introduced.
2007 downgradeResources(&message);
2008
2009 send(master.get(), message);
2010 } else {

Callers

nothing calls this directly

Calls 10

downgradeResourcesFunction · 0.85
minFunction · 0.85
randomFunction · 0.85
CopyFromMethod · 0.80
toRepeatedPtrFieldMethod · 0.80
sendFunction · 0.50
delayFunction · 0.50
isNoneMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected