Rename Master to Controller

The role of the master server as the party controlling every part of the
cluster is not well reflected in its name and has caused confusion among
users on several occasions.  Rename master to controller to better
reflects its role.
This commit is contained in:
Hornwitser committed 2023-02-22 15:30:51 +01:00
1 parent 6ae4c8ef46
commit 70ad295a89
119 files changed
+1394 -1376

No files matched your search

+3 -3
View File
@@ -37,7 +37,7 @@ For example, installing the Subspace Storage plugin:
npm install @clusterio/plugin-subspace_storage
npx clusterioctl plugin add @clusterio/plugin-subspace_storage
Since the `plugin-list.json` is shared between master, slave and ctl you usually only need to do this once per machine.
Since the `plugin-list.json` is shared between controller, slave and ctl you usually only need to do this once per machine.
#### `plugin remove <name>`
@@ -51,7 +51,7 @@ For example, uninstalling the Subspace Storage plugin:
npx clusterioctl plugin remove subspace_storage
npm uninstall @clusterio/plugin-subspace_storage
Since the `plugin-list.json` is shared between master, slave and ctl you usually only need to do this once per machine.
Since the `plugin-list.json` is shared between controller, slave and ctl you usually only need to do this once per machine.
#### `plugin list`
@@ -62,7 +62,7 @@ Lists the plugins set up to be available by name followed by path.
### `config-control`
Manage the ctl configuration.
This allows setting the url and token to the master server to manage.
This allows setting the url and token to the controller to manage.
#### `config-control set <config-entry> [value]`
+11 -11
View File
@@ -24,7 +24,7 @@ const commands = require("./src/commands");
/**
* Connector for control connection to master server
* Connector for control connection to controller
* @private
*/
class ControlConnector extends libLink.WebSocketClientConnector {
@@ -46,22 +46,22 @@ class ControlConnector extends libLink.WebSocketClientConnector {
/**
* Handles running the control
*
* Connects to the master server over WebSocket and sends commands to it.
* Connects to the controller over WebSocket and sends commands to it.
* @static
*/
class Control extends libLink.Link {
constructor(connector, controlConfig, tlsCa, controlPlugins) {
super("control", "master", connector);
super("control", "controller", connector);
libLink.attachAllMessages(this);
/**
* Control config used for connecting to the master.
* Control config used for connecting to the controller.
* @type {module:lib/config.ControlConfig}
*/
this.config = controlConfig;
/**
* Certificate authority used to validate TLS connections to the master.
* Certificate authority used to validate TLS connections to the controller.
* @type {?string}
*/
this.tlsCa = tlsCa;
@@ -97,13 +97,13 @@ class Control extends libLink.Link {
async setLogSubscriptions({
all = false,
master = false,
controller = false,
slave_ids = [],
instance_ids = [],
max_level = null,
}) {
await libLink.messages.setLogSubscriptions.send(this, {
all, master, slave_ids, instance_ids, max_level,
all, controller, slave_ids, instance_ids, max_level,
});
}
@@ -251,8 +251,8 @@ async function startControl() {
targetCommand = targetCommand.get(commandPath.shift());
}
// The remaining commands require connecting to the master server.
if (!controlConfig.get("control.master_url") || !controlConfig.get("control.master_token")) {
// The remaining commands require connecting to the controller.
if (!controlConfig.get("control.controller_url") || !controlConfig.get("control.controller_token")) {
logger.error("Missing URL and/or token to connect with. See README.md for setting up access.");
process.exitCode = 1;
return;
@@ -265,10 +265,10 @@ async function startControl() {
}
let controlConnector = new ControlConnector(
controlConfig.get("control.master_url"),
controlConfig.get("control.controller_url"),
controlConfig.get("control.max_reconnect_delay"),
tlsCa,
controlConfig.get("control.master_token")
controlConfig.get("control.controller_token")
);
let control = new Control(controlConnector, controlConfig, tlsCa, controlPlugins);
try {
+47 -45
View File
@@ -84,14 +84,14 @@ async function serializedConfigToString(serializedConfig, configGroup, disallowe
return allConfigElements;
}
const masterCommands = new libCommand.CommandTree({ name: "master", description: "Master management" });
const masterConfigCommands = new libCommand.CommandTree({
name: "config", alias: ["c"], description: "master config management",
const controllerCommands = new libCommand.CommandTree({ name: "controller", description: "Controller management" });
const controllerConfigCommands = new libCommand.CommandTree({
name: "config", alias: ["c"], description: "controller config management",
});
masterConfigCommands.add(new libCommand.Command({
definition: ["list", "List master configuration"],
controllerConfigCommands.add(new libCommand.Command({
definition: ["list", "List controller configuration"],
handler: async function(args, control) {
let response = await libLink.messages.getMasterConfig.send(control);
let response = await libLink.messages.getControllerConfig.send(control);
for (let group of response.serialized_config.groups) {
for (let [name, value] of Object.entries(group.fields)) {
@@ -101,8 +101,8 @@ masterConfigCommands.add(new libCommand.Command({
},
}));
masterConfigCommands.add(new libCommand.Command({
definition: ["set <field> [value]", "Set field in master config", (yargs) => {
controllerConfigCommands.add(new libCommand.Command({
definition: ["set <field> [value]", "Set field in controller config", (yargs) => {
yargs.positional("field", { describe: "Field to set", type: "string" });
yargs.positional("value", { describe: "Value to set", type: "string" });
yargs.options({
@@ -115,15 +115,15 @@ masterConfigCommands.add(new libCommand.Command({
} else if (args.value === undefined) {
args.value = "";
}
await libLink.messages.setMasterConfigField.send(control, {
await libLink.messages.setControllerConfigField.send(control, {
field: args.field,
value: args.value,
});
},
}));
masterConfigCommands.add(new libCommand.Command({
definition: ["set-prop <field> <prop> [value]", "Set property of field in master config", (yargs) => {
controllerConfigCommands.add(new libCommand.Command({
definition: ["set-prop <field> <prop> [value]", "Set property of field in controller config", (yargs) => {
yargs.positional("field", { describe: "Field to set", type: "string" });
yargs.positional("prop", { describe: "Property to set", type: "string" });
yargs.positional("value", { describe: "JSON parsed value to set", type: "string" });
@@ -150,11 +150,11 @@ masterConfigCommands.add(new libCommand.Command({
}
request.value = args.value;
}
await libLink.messages.setMasterConfigProp.send(control, request);
await libLink.messages.setControllerConfigProp.send(control, request);
},
}));
masterConfigCommands.add(new libCommand.Command({
definition: ["edit [editor]", "Edit master configuration", (yargs) => {
controllerConfigCommands.add(new libCommand.Command({
definition: ["edit [editor]", "Edit controller configuration", (yargs) => {
yargs.positional("editor", {
describe: "Editor to use",
type: "string",
@@ -162,14 +162,16 @@ masterConfigCommands.add(new libCommand.Command({
});
}],
handler: async function(args, control) {
let response = await libLink.messages.getMasterConfig.send(control);
let response = await libLink.messages.getControllerConfig.send(control);
let tmpFile = await libFileOps.getTempFile("ctl-", "-tmp", os.tmpdir());
let editor = await getEditor(args.editor);
if (editor === -1) {
throw new libErrors.CommandError(`No editor avalible. Checked CLI input, EDITOR and VISUAL env vars
Try "ctl master config edit <editor of choice>"`);
Try "ctl controller config edit <editor of choice>"`);
}
let allConfigElements = await serializedConfigToString(response.serialized_config, libConfig.MasterConfig, {});
let allConfigElements = await serializedConfigToString(
response.serialized_config, libConfig.ControllerConfig, {}
);
await fs.writeFile(tmpFile, allConfigElements, (err) => {
if (err) {
throw err;
@@ -189,7 +191,7 @@ masterConfigCommands.add(new libCommand.Command({
for (let index in final) {
if (index in final) {
try {
await libLink.messages.setMasterConfigField.send(control, {
await libLink.messages.setControllerConfigField.send(control, {
field: index,
value: final[index],
});
@@ -213,16 +215,16 @@ masterConfigCommands.add(new libCommand.Command({
},
}));
masterCommands.add(masterConfigCommands);
controllerCommands.add(controllerConfigCommands);
const masterPluginCommands = new libCommand.CommandTree({
name: "plugin", alias: ["p"], description: "master plugin inspection",
const controllerPluginCommands = new libCommand.CommandTree({
name: "plugin", alias: ["p"], description: "controller plugin inspection",
});
masterPluginCommands.add(new libCommand.Command({
definition: ["list", "List plugins on master"],
controllerPluginCommands.add(new libCommand.Command({
definition: ["list", "List plugins on controller"],
handler: async function(args, control) {
let url = new URL(control.config.get("control.master_url"));
let url = new URL(control.config.get("control.controller_url"));
url.pathname += "api/plugins";
let response = await phin({
url,
@@ -232,12 +234,12 @@ masterPluginCommands.add(new libCommand.Command({
print(asTable(response.body));
},
}));
masterCommands.add(masterPluginCommands);
controllerCommands.add(controllerPluginCommands);
const slaveCommands = new libCommand.CommandTree({ name: "slave", description: "Slave management" });
slaveCommands.add(new libCommand.Command({
definition: [["list", "l"], "List slaves connected to the master"],
definition: [["list", "l"], "List slaves connected to the controller"],
handler: async function(args, control) {
let response = await libLink.messages.listSlaves.send(control);
print(asTable(response.list));
@@ -293,7 +295,7 @@ const instanceCommands = new libCommand.CommandTree({
name: "instance", alias: ["i"], description: "Instance management",
});
instanceCommands.add(new libCommand.Command({
definition: [["list", "l"], "List instances known to the master"],
definition: [["list", "l"], "List instances known to the controller"],
handler: async function(args, control) {
let response = await libLink.messages.listInstances.send(control);
print(asTable(response.list));
@@ -315,7 +317,7 @@ instanceCommands.add(new libCommand.Command({
instanceConfig.set("instance.id", args.id);
}
instanceConfig.set("instance.name", args.name);
let serialized_config = instanceConfig.serialize("master");
let serialized_config = instanceConfig.serialize("controller");
await libLink.messages.createInstance.send(control, { serialized_config });
},
}));
@@ -426,7 +428,7 @@ instanceConfigCommands.add(new libCommand.Command({
let editor = await getEditor(args.editor);
if (editor === -1) {
throw new libErrors.CommandError(`No editor avalible. Checked CLI input, EDITOR and VISUAL env vars
Try "ctl master config edit <editor of choice>"`);
Try "ctl controller config edit <editor of choice>"`);
}
let disallowedList = {"instance.id": 0, "instance.assigned_slave": 0, "factorio.settings": 0};
let allConfigElements = await serializedConfigToString(
@@ -614,7 +616,7 @@ instanceSaveCommands.add(new libCommand.Command({
let content = await fs.readFile(args.filepath);
let instanceId = await libCommand.resolveInstance(control, args.instance);
let url = new URL(control.config.get("control.master_url"));
let url = new URL(control.config.get("control.controller_url"));
url.pathname += "api/upload-save";
url.searchParams.append("instance_id", instanceId);
url.searchParams.append("filename", filename);
@@ -622,7 +624,7 @@ instanceSaveCommands.add(new libCommand.Command({
let result = await phin({
url, method: "POST",
headers: {
"X-Access-Token": control.config.get("control.master_token"),
"X-Access-Token": control.config.get("control.controller_token"),
"Content-Type": "application/zip",
},
core: { ca: control.tlsCa },
@@ -688,7 +690,7 @@ instanceSaveCommands.add(new libCommand.Command({
save: args.save,
});
let url = new URL(control.config.get("control.master_url"));
let url = new URL(control.config.get("control.controller_url"));
url.pathname += `api/stream/${result.stream_id}`;
let response = await phin({
url, method: "GET",
@@ -1233,14 +1235,14 @@ modCommands.add(new libCommand.Command({
// phin doesn't support streaming requests :(
let content = await fs.readFile(args.file);
let url = new URL(control.config.get("control.master_url"));
let url = new URL(control.config.get("control.controller_url"));
url.pathname += "api/upload-mod";
url.searchParams.append("filename", filename);
let result = await phin({
url, method: "POST",
headers: {
"X-Access-Token": control.config.get("control.master_token"),
"X-Access-Token": control.config.get("control.controller_token"),
"Content-Type": "application/zip",
},
core: { ca: control.tlsCa },
@@ -1278,7 +1280,7 @@ modCommands.add(new libCommand.Command({
version: args.modVersion,
});
let url = new URL(control.config.get("control.master_url"));
let url = new URL(control.config.get("control.controller_url"));
url.pathname += `api/stream/${result.stream_id}`;
let response = await phin({
url, method: "GET",
@@ -1583,20 +1585,20 @@ logCommands.add(new libCommand.Command({
definition: ["follow", "follow cluster log", (yargs) => {
yargs.options({
"all": { describe: "Follow the whole cluster log", nargs: 0, type: "boolean", default: false },
"master": { describe: "Follow log of the master server", nargs: 0, type: "boolean", default: false },
"controller": { describe: "Follow log of the controller", nargs: 0, type: "boolean", default: false },
"slave": { describe: "Follow log of given slave", nargs: 1, type: "string", default: null },
"instance": { describe: "Follow log of given instance", nargs: 1, type: "string", default: null },
});
}],
handler: async function(args, control) {
if (!args.all && !args.master && !args.slave && !args.instance) {
logger.error("At least one of --all, --master, --slave and --instance must be passed");
if (!args.all && !args.controller && !args.slave && !args.instance) {
logger.error("At least one of --all, --controller, --slave and --instance must be passed");
process.exitCode = 1;
return;
}
let instance_ids = args.instance ? [await libCommand.resolveInstance(control, args.instance)] : [];
let slave_ids = args.slave ? [await libCommand.resolveSlave(control, args.slave)] : [];
await control.setLogSubscriptions({ all: args.all, master: args.master, slave_ids, instance_ids });
await control.setLogSubscriptions({ all: args.all, controller: args.controller, slave_ids, instance_ids });
control.keepOpen = true;
},
}));
@@ -1605,7 +1607,7 @@ logCommands.add(new libCommand.Command({
definition: ["query", "Query cluster log", (yargs) => {
yargs.options({
"all": { describe: "Query the whole cluster log", nargs: 0, type: "boolean", default: false },
"master": { describe: "Query log of the master server", nargs: 0, type: "boolean", default: false },
"controller": { describe: "Query log of the controller", nargs: 0, type: "boolean", default: false },
"slave": { describe: "Query log of given slave", nargs: 1, type: "string", default: null },
"instance": { describe: "Query log of given instance", nargs: 1, type: "string", default: null },
"max-level": { describe: "Maximum log level to return", nargs: 1, type: "string", default: null },
@@ -1614,8 +1616,8 @@ logCommands.add(new libCommand.Command({
});
}],
handler: async function(args, control) {
if (!args.all && !args.master && !args.slave && !args.instance) {
logger.error("At least one of --all, --master, --slave and --instance must be passed");
if (!args.all && !args.controller && !args.slave && !args.instance) {
logger.error("At least one of --all, --controller, --slave and --instance must be passed");
process.exitCode = 1;
return;
}
@@ -1623,7 +1625,7 @@ logCommands.add(new libCommand.Command({
let slave_ids = args.slave ? [await libCommand.resolveSlave(control, args.slave)] : [];
let result = await libLink.messages.queryLog.send(control, {
all: args.all,
master: args.master,
controller: args.controller,
slave_ids,
instance_ids,
max_level: args.maxLevel,
@@ -1651,7 +1653,7 @@ logCommands.add(new libCommand.Command({
const debugCommands = new libCommand.CommandTree({ name: "debug", description: "Debugging utilities" });
debugCommands.add(new libCommand.Command({
definition: ["dump-ws", "Dump WebSocket messages sent and received by master", (yargs) => { }],
definition: ["dump-ws", "Dump WebSocket messages sent and received by controller", (yargs) => { }],
handler: async function(args, control) {
await libLink.messages.debugDumpWs.send(control);
control.keepOpen = true;
@@ -1660,7 +1662,7 @@ debugCommands.add(new libCommand.Command({
async function registerCommands(controlPlugins, yargs) {
const rootCommands = new libCommand.CommandTree({ name: "clusterioctl", description: "Manage cluster" });
rootCommands.add(masterCommands);
rootCommands.add(controllerCommands);
rootCommands.add(slaveCommands);
rootCommands.add(instanceCommands);
rootCommands.add(modPackCommands);