Hello,
I need to write custom Allocation module, but I don't see a possibility to
load it dynamically using --modules command line argument.
This is the allocation module creation in master/main:
allocator::Allocator* allocator = new allocator::HierarchicalDRFAllocator();
(so it is just hardcoded)
Other modules are loaded dynamically like this:
if (flags.modules.isSome()) {
Try<Nothing> result = ModuleManager::load(flags.modules.get());
if (result.isError()) {
EXIT(1) << "Error loading modules: " << result.error();
}
}
...
// Create anonymous modules.
foreach (const string& name, ModuleManager::find<Anonymous>()) {
Try<Anonymous*> create = ModuleManager::create<Anonymous>(name);
if (create.isError()) {
EXIT(1) << "Failed to create anonymous module named '" << name << "'";
}
...
Authenticator* authenticator;
// TODO(tillt): Allow multiple authenticators to be loaded and enable
// the authenticatee to select the appropriate one. See MESOS-1939.
if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
LOG(INFO) << "Using default CRAM-MD5 authenticator";
authenticator = new cram_md5::CRAMMD5Authenticator();
} else {
Try<Authenticator*> module =
modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
if (module.isError()) {
EXIT(1) << "Could not create authenticator module '"
<< authenticatorNames[0] << "': " << module.error();
}
...
if (ModuleManager::contains<Isolator>(type)) {
Try<Isolator*> isolator = ModuleManager::create<Isolator>(type);
if (isolator.isError()) {
return Error(
"Could not create isolator " + type + ": " + isolator.error());
}
This is a list of supported modules which can be loaded dynamically:
kindToVersion["Anonymous"] = MESOS_VERSION;
kindToVersion["Authenticatee"] = MESOS_VERSION;
kindToVersion["Authenticator"] = MESOS_VERSION;
kindToVersion["Hook"] = MESOS_VERSION;
kindToVersion["Isolator"] = MESOS_VERSION;
kindToVersion["TestModule"] = MESOS_VERSION;
If allocation module is absent here, it will not pass such check:
Try<Nothing> ModuleManager::verifyModule(
const string& moduleName,
const ModuleBase* moduleBase)
{
...
if (!kindToVersion.contains(moduleBase->kind)) {
return Error("Unknown module kind: " + stringify(moduleBase->kind));
}
...
}
Mesos documentation also does not mention Allocation module as dynamically
loadable: http://mesos.apache.org/documentation/latest/modules/
Could you please help me, is there a possibility to use custom allocation
module with Mesos?
Best regards,
Dariia