Fix setting instance config fields not being saved

If only the config of an instance is updated the dirty flag of the
instance is not set, which results in changes being discarded when the
controller shuts down afterwards.

Fix by always triggering the update logic when an instance field is
changed.
This commit is contained in:
Hornwitser committed 2024-10-28 19:30:03 +01:00
1 parent 300db5cbfd
commit 34da073800
2 files changed
+12 -4

No files matched your search

+11 -1
View File
@@ -17,7 +17,9 @@ class MockInstanceConfig extends EventEmitter {
}
set(field, value) {
return this._data.set(field, value);
const prev = this.get(field);
this._data.set(field, value);
this.emit("fieldChanged", field, value, prev);
}
}
@@ -179,5 +181,13 @@ describe("controller/src/Controller", function() {
);
});
});
describe(".instances", function() {
it("should set the dirty flag if the config is updated", function() {
controller.instances.dirty = false;
mockInstanceConfig.set("instance.assigned_host", null);
assert(controller.instances.dirty === true, "dirty flag was not set");
});
});
});
});