Skip to content

Commit

Permalink
[device manager] Add args to customize commit_device_access_changes b…
Browse files Browse the repository at this point in the history
…ehavior.

Currently, commit_device_access_changes always checkpoints the
device manager state **and** configures the bpf programs for the cgroup
based on its device access state.

We add an argument to commit_device_access_changes for the caller to
determine whether they want the state to be checkpointed along with
attaching the ebpf program.

Review: https://reviews.apache.org/r/75148/
  • Loading branch information
ZhouJas authored and bmahler committed Aug 8, 2024
1 parent b6e2e0b commit 0d484a2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/slave/containerizer/device_manager/device_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,20 @@ class DeviceManagerProcess : public process::Process<DeviceManagerProcess>
return Nothing();
}

Try<Nothing> commit_device_access_changes(const string& cgroup) const
Try<Nothing> commit_device_access_changes(
const string& cgroup,
bool write_checkpoint = true) const
{
Try<Nothing> status = checkpoint();
if (write_checkpoint) {
Try<Nothing> status = checkpoint();

if (status.isError()) {
return Error("Failed to checkpoint device access state: "
+ status.error());
if (status.isError()) {
return Error("Failed to checkpoint device access state: "
+ status.error());
}
}

status = cgroups2::devices::configure(
Try<Nothing> status = cgroups2::devices::configure(
cgroup,
device_access_per_cgroup.at(cgroup).allow_list,
device_access_per_cgroup.at(cgroup).deny_list);
Expand Down

0 comments on commit 0d484a2

Please sign in to comment.