Defer tail declarations
declare() calls that aren't followed by commit() are applied at the end of the provision script. This change defers those until all provisions have been executed. This prevents certain cases of preset loop faults.
This commit is contained in:
1 parent
ec215ffb82
commit
1a56915d4b
5 files changed
+163
-83
No files matched your search
+74
-31
@@ -35,11 +35,14 @@ function refresh(sessionContext, provision, declarations) {
|
||||
const t = scheduling.interval(sessionContext.timestamp, every, offset);
|
||||
|
||||
for (let i = l; i < path.length; ++i) {
|
||||
declarations.push([
|
||||
path.slice(0, i),
|
||||
t,
|
||||
{ object: 1, writable: 1, value: t }
|
||||
]);
|
||||
declarations.push({
|
||||
path: path.slice(0, i),
|
||||
pathGet: t,
|
||||
pathSet: null,
|
||||
attrGet: { object: 1, writable: 1, value: t },
|
||||
attrSet: null,
|
||||
defer: true
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -47,38 +50,55 @@ function refresh(sessionContext, provision, declarations) {
|
||||
|
||||
function value(sessionContext, provision, declarations) {
|
||||
const path = common.parsePath(provision[1]);
|
||||
declarations.push([path, 1, { value: 1 }, null, { value: [provision[2]] }]);
|
||||
declarations.push({
|
||||
path: path,
|
||||
pathGet: 1,
|
||||
pathSet: null,
|
||||
attrGet: { value: 1 },
|
||||
attrSet: { value: [provision[2]] },
|
||||
defer: true
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function tag(sessionContext, provision, declarations) {
|
||||
const path = ["Tags", provision[1]];
|
||||
declarations.push([path, 1, { value: 1 }, null, { value: [provision[2]] }]);
|
||||
|
||||
declarations.push({
|
||||
path: path,
|
||||
pathGet: 1,
|
||||
pathSet: null,
|
||||
attrGet: { value: 1 },
|
||||
attrSet: { value: [provision[2]] },
|
||||
defer: true
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function reboot(sessionContext, provision, declarations) {
|
||||
declarations.push([
|
||||
["Reboot"],
|
||||
1,
|
||||
{ value: 1 },
|
||||
null,
|
||||
{ value: [sessionContext.timestamp] }
|
||||
]);
|
||||
declarations.push({
|
||||
path: ["Reboot"],
|
||||
pathGet: 1,
|
||||
pathSet: null,
|
||||
attrGet: { value: 1 },
|
||||
attrSet: { value: [sessionContext.timestamp] },
|
||||
defer: true
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset(sessionContext, provision, declarations) {
|
||||
declarations.push([
|
||||
["FactoryReset"],
|
||||
1,
|
||||
{ value: 1 },
|
||||
null,
|
||||
{ value: [sessionContext.timestamp] }
|
||||
]);
|
||||
declarations.push({
|
||||
path: ["FactoryReset"],
|
||||
pathGet: 1,
|
||||
pathSet: null,
|
||||
attrGet: { value: 1 },
|
||||
attrSet: { value: [sessionContext.timestamp] },
|
||||
defer: true
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -93,14 +113,23 @@ function download(sessionContext, provision, declarations) {
|
||||
provision[3] || ""
|
||||
];
|
||||
|
||||
declarations.push([["Downloads", alias], 1, {}, 1]);
|
||||
declarations.push([
|
||||
["Downloads", alias, "Download"],
|
||||
1,
|
||||
{ value: 1 },
|
||||
null,
|
||||
{ value: [sessionContext.timestamp] }
|
||||
]);
|
||||
declarations.push({
|
||||
path: ["Downloads", alias],
|
||||
pathGet: 1,
|
||||
pathSet: 1,
|
||||
attrGet: null,
|
||||
attrSet: null,
|
||||
defer: true
|
||||
});
|
||||
|
||||
declarations.push({
|
||||
path: ["Downloads", alias, "Download"],
|
||||
pathGet: 1,
|
||||
pathSet: null,
|
||||
attrGet: { value: 1 },
|
||||
attrSet: { value: [sessionContext.timestamp] },
|
||||
defer: true
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -119,7 +148,14 @@ function instances(
|
||||
const path = common.parsePath(provision[1]);
|
||||
|
||||
if (provision[2][0] === "+" || provision[2][0] === "-") {
|
||||
declarations.push([path, 1]);
|
||||
declarations.push({
|
||||
path: path,
|
||||
pathGet: 1,
|
||||
pathSet: null,
|
||||
attrGet: null,
|
||||
attrSet: null,
|
||||
defer: true
|
||||
});
|
||||
|
||||
if (endRevision === startRevision) return false;
|
||||
|
||||
@@ -131,7 +167,14 @@ function instances(
|
||||
count = Math.max(0, unpacked.length + count);
|
||||
}
|
||||
|
||||
declarations.push([path, 1, null, count]);
|
||||
declarations.push({
|
||||
path: path,
|
||||
pathGet: 1,
|
||||
pathSet: count,
|
||||
attrGet: null,
|
||||
attrSet: null,
|
||||
defer: true
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user