diff --git a/packages/master/src/Master.js b/packages/master/src/Master.js index 6fb10989..e4605896 100644 --- a/packages/master/src/Master.js +++ b/packages/master/src/Master.js @@ -45,8 +45,8 @@ class Master { constructor(clusterLogger, pluginInfos, configPath, config) { this.clusterLogger = clusterLogger; /** - * Mapping of plugin name to info objects for known plugins - * @type {Map} + * Array of plugin info objects for known plugins + * @type {Array} */ this.pluginInfos = pluginInfos; this.configPath = configPath; diff --git a/packages/master/src/SlaveConnection.js b/packages/master/src/SlaveConnection.js index 35564264..c011d01f 100644 --- a/packages/master/src/SlaveConnection.js +++ b/packages/master/src/SlaveConnection.js @@ -23,6 +23,7 @@ class SlaveConnection extends BaseConnection { this._name = registerData.name; this._version = registerData.version; this.plugins = new Map(Object.entries(registerData.plugins)); + this._checkPluginVersions(); this._master.slaves.set(this._id, { agent: this._agent, @@ -57,6 +58,30 @@ class SlaveConnection extends BaseConnection { }); } + _checkPluginVersions() { + let pluginInfos = new Map(this._master.pluginInfos.map(i => [i.name, i])); + for (let [name, version] of this.plugins) { + let info = pluginInfos.get(name); + if (!info) { + logger.warn(`Slave ${this._name} has plugin ${name} ${version} which the master does not have`); + continue; + } + + if (info.version !== version) { + logger.warn( + `Slave ${this._name} has plugin ${name} ${version} which does not match the version of this ` + + `plugin on the master (${info.version})` + ); + } + } + + for (let [name, info] of pluginInfos) { + if (!this.plugins.has(name)) { + logger.warn(`Slave ${this._name} is missing plugin ${name} ${info.version}`); + } + } + } + /** * ID of the slave this connection is connected to * diff --git a/packages/master/src/WsServer.js b/packages/master/src/WsServer.js index 2be97122..2523873c 100644 --- a/packages/master/src/WsServer.js +++ b/packages/master/src/WsServer.js @@ -269,7 +269,16 @@ ${err.stack}` await connection.disconnect(1008, "Registered from another connection"); } - logger.verbose(`WsServer | registered slave ${data.id} version ${data.version}`); + logger.info( + `WsServer | registered slave ${data.name} (${data.id}) using agent ${data.agent} ${data.version}` + ); + if (data.agent === "Clusterio Slave" && data.version !== packageVersion) { + logger.warn( + `Slave ${data.name} (${data.id}) connected using version ${data.version} which does not match ` + + `the version of the master is currently running (${packageVersion}). It may not work as expected.` + ); + } + connection = new SlaveConnection(data, connector, this.master); connector.on("close", () => { if (this.slaveConnections.get(data.id) === connection) {