mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 00:23:12 +09:00
Merge pull request #1211 from bbassie/fix/pairing-restart-pending
Don't flag a restart when a new host pairs
This commit is contained in:
1 parent
61f2b01172
commit
154ebe294a
2 files changed
+9
No files matched your search
@@ -297,9 +297,12 @@ export async function ensurePaired(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// The host has not started yet, so the new token needs no restart.
|
||||||
|
const restartRequired = config.restartRequired;
|
||||||
config.set("host.id", result.hostId);
|
config.set("host.id", result.hostId);
|
||||||
config.set("host.name", result.name);
|
config.set("host.name", result.name);
|
||||||
config.set("host.controller_token", result.token);
|
config.set("host.controller_token", result.token);
|
||||||
|
config.restartRequired = restartRequired;
|
||||||
await config.save();
|
await config.save();
|
||||||
logger.info(`Host approved as "${result.name}" with id ${result.hostId}`);
|
logger.info(`Host approved as "${result.name}" with id ${result.hostId}`);
|
||||||
}
|
}
|
||||||
@@ -252,6 +252,7 @@ describe("host/src/pairing", function() {
|
|||||||
config = new lib.HostConfig("host", undefined, path.join(directory, "config-host.json"));
|
config = new lib.HostConfig("host", undefined, path.join(directory, "config-host.json"));
|
||||||
config.set("host.name", "My Host");
|
config.set("host.name", "My Host");
|
||||||
config.set("host.controller_url", stub.url);
|
config.set("host.controller_url", stub.url);
|
||||||
|
config.restartRequired = false;
|
||||||
});
|
});
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await fs.rm(directory, { recursive: true, force: true, maxRetries: 10 });
|
await fs.rm(directory, { recursive: true, force: true, maxRetries: 10 });
|
||||||
@@ -279,6 +280,9 @@ describe("host/src/pairing", function() {
|
|||||||
assert.equal(saved["host.id"], 1234);
|
assert.equal(saved["host.id"], 1234);
|
||||||
assert.equal(saved["host.name"], "Approved");
|
assert.equal(saved["host.name"], "Approved");
|
||||||
assert.equal(saved["host.controller_token"], "host-token");
|
assert.equal(saved["host.controller_token"], "host-token");
|
||||||
|
assert.equal(config.restartRequired, false, "pairing flagged a restart");
|
||||||
|
config.set("host.controller_token", "other-token");
|
||||||
|
assert.equal(config.restartRequired, true, "later change did not flag a restart");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does nothing when the controller accepts the saved token", async function() {
|
it("does nothing when the controller accepts the saved token", async function() {
|
||||||
@@ -294,6 +298,7 @@ describe("host/src/pairing", function() {
|
|||||||
|
|
||||||
it("asks to join again with the user token when the saved token is not accepted", async function() {
|
it("asks to join again with the user token when the saved token is not accepted", async function() {
|
||||||
config.set("host.controller_token", "revoked-token");
|
config.set("host.controller_token", "revoked-token");
|
||||||
|
config.restartRequired = false;
|
||||||
stub.handler = ({ url, headers }) => {
|
stub.handler = ({ url, headers }) => {
|
||||||
if (url === "/api/host-pairing/check") {
|
if (url === "/api/host-pairing/check") {
|
||||||
return [401, undefined];
|
return [401, undefined];
|
||||||
@@ -307,6 +312,7 @@ describe("host/src/pairing", function() {
|
|||||||
assert.equal(saved["host.id"], 5);
|
assert.equal(saved["host.id"], 5);
|
||||||
assert.equal(saved["host.controller_token"], "new-token");
|
assert.equal(saved["host.controller_token"], "new-token");
|
||||||
assert(!JSON.stringify(saved).includes("user-token"), "user token must not be saved");
|
assert(!JSON.stringify(saved).includes("user-token"), "user token must not be saved");
|
||||||
|
assert.equal(config.restartRequired, false, "pairing flagged a restart");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("stops when aborted while checking the saved token", async function() {
|
it("stops when aborted while checking the saved token", async function() {
|
||||||
|
|||||||
Reference in new issue
Block a user