Skip to content

Commit

Permalink
shell: Fix cockpit.Machines.Update() error handling
Browse files Browse the repository at this point in the history
Stringify the error object, so that we don't just get an empty value in
our test logs.

This call requires superuser privileges to write into /etc/cockpit/, so
declare that and avoid making console noise if the session is
unprivileged. That way, we only see unexpected failures.
  • Loading branch information
martinpitt authored and jelly committed Oct 19, 2023
1 parent 4937113 commit 52ac7fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions pkg/shell/machines/machines.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ function Machines() {
}

// FIXME: investigate re-using the proxy from Loader (runs in different frame/scope)
const bridge = cockpit.dbus(null, { bus: "internal", superuser: "try" });
const bridge = cockpit.dbus(null, { bus: "internal", superuser: "require" });
const mod =
bridge.call("/machines", "cockpit.Machines", "Update", ["99-webui.json", host, values_variant])
.catch(function(error) {
console.error("failed to call cockpit.Machines.Update(): ", error);
.catch(error => {
// avoid make noise when we are not superuser
if (error.problem !== "access-denied")
console.error("failed to call cockpit.Machines.Update(): ", JSON.stringify(error));
})
.then(() => {
self.overlay(host, values);
});
.then(() => self.overlay(host, values));

return mod;
}
Expand Down
1 change: 0 additions & 1 deletion test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,6 @@ def login_and_go(self, path: Optional[str] = None, user: Optional[str] = None, h
"aria-label",
# messages from our own pages
"CPU temperature metric closed.*",
"failed to call cockpit.Machines.Update().*",
"Getting properties for problem.*",
"Channel for reportd D-Bus client closed.*",
]
Expand Down

0 comments on commit 52ac7fa

Please sign in to comment.