-
Notifications
You must be signed in to change notification settings - Fork 53
pickle error: #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
pickle error: #422
Changes from all commits
2622fd2
a00cf91
e7f4022
9613534
8817993
f8d2cac
d661e51
6a23f2d
0c0024f
1903ec8
d247dd6
eab817f
3511a77
98c4b4b
246754b
bc86f05
2111b33
6b7a25f
deb892b
db3f0fd
b6d69d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -659,42 +659,49 @@ void DobbyConfig::addPluginLauncherHooks(std::shared_ptr<rt_dobby_schema> cfg, c | |||||||
| cfg->hooks = (rt_dobby_schema_hooks*)calloc(1, sizeof(rt_dobby_schema_hooks)); | ||||||||
| } | ||||||||
|
|
||||||||
| // createRuntime, createContainer, poststart and poststop hook paths must | ||||||||
| // resolve in the runtime namespace - config is in bundle | ||||||||
| std::string configPath = bundlePath + "/config.json"; | ||||||||
| // createRuntime and poststop hook paths must resolve in the runtime namespace | ||||||||
| // and execute in runtime namespace, so they can use the bundle path directly | ||||||||
| std::string runtimeConfigPath = bundlePath + "/config.json"; | ||||||||
|
|
||||||||
| // createContainer hook runs in container namespace, so it needs to use | ||||||||
| // the fixed path where we mounted the config.json | ||||||||
| std::string containerConfigPath = "/tmp/dobby_config.json"; | ||||||||
|
|
||||||||
| // populate createRuntime hook with DobbyPluginLauncher args | ||||||||
| rt_defs_hook *createRuntimeEntry = (rt_defs_hook*)calloc(1, sizeof(rt_defs_hook)); | ||||||||
| setPluginHookEntry(createRuntimeEntry, "createRuntime", configPath); | ||||||||
| setPluginHookEntry(createRuntimeEntry, "createRuntime", runtimeConfigPath); | ||||||||
| cfg->hooks->create_runtime = (rt_defs_hook**)realloc(cfg->hooks->create_runtime, sizeof(rt_defs_hook*) * ++cfg->hooks->create_runtime_len); | ||||||||
| cfg->hooks->create_runtime[cfg->hooks->create_runtime_len-1] = createRuntimeEntry; | ||||||||
|
|
||||||||
| // populate createContainer hook with DobbyPluginLauncher args | ||||||||
| // Uses container namespace path since hook executes in container namespace | ||||||||
| rt_defs_hook *createContainerEntry = (rt_defs_hook*)calloc(1, sizeof(rt_defs_hook)); | ||||||||
| setPluginHookEntry(createContainerEntry, "createContainer", configPath); | ||||||||
| setPluginHookEntry(createContainerEntry, "createContainer", containerConfigPath); | ||||||||
| cfg->hooks->create_container = (rt_defs_hook**)realloc(cfg->hooks->create_container, sizeof(rt_defs_hook*) * ++cfg->hooks->create_container_len); | ||||||||
| cfg->hooks->create_container[cfg->hooks->create_container_len-1] = createContainerEntry; | ||||||||
|
|
||||||||
| // populate poststart hook with DobbyPluginLauncher args | ||||||||
| // poststart runs in runtime namespace, so use runtime path | ||||||||
| rt_defs_hook *poststartEntry = (rt_defs_hook*)calloc(1, sizeof(rt_defs_hook)); | ||||||||
| setPluginHookEntry(poststartEntry, "poststart", configPath); | ||||||||
| setPluginHookEntry(poststartEntry, "poststart", runtimeConfigPath); | ||||||||
| cfg->hooks->poststart = (rt_defs_hook**)realloc(cfg->hooks->poststart, sizeof(rt_defs_hook*) * ++cfg->hooks->poststart_len); | ||||||||
| cfg->hooks->poststart[cfg->hooks->poststart_len-1] = poststartEntry; | ||||||||
|
|
||||||||
| // populate poststop hook with DobbyPluginLauncher args | ||||||||
| // poststop runs in runtime namespace, so use runtime path | ||||||||
| rt_defs_hook *poststopEntry = (rt_defs_hook*)calloc(1, sizeof(rt_defs_hook)); | ||||||||
| setPluginHookEntry(poststopEntry, "poststop", configPath); | ||||||||
| setPluginHookEntry(poststopEntry, "poststop", runtimeConfigPath); | ||||||||
| cfg->hooks->poststop = (rt_defs_hook**)realloc(cfg->hooks->poststop, sizeof(rt_defs_hook*) * ++cfg->hooks->poststop_len); | ||||||||
| cfg->hooks->poststop[cfg->hooks->poststop_len-1] = poststopEntry; | ||||||||
|
|
||||||||
| #ifdef USE_STARTCONTAINER_HOOK | ||||||||
| // startContainer hook paths must resolve in the container namespace, | ||||||||
| // config is in container rootdir | ||||||||
| configPath = "/tmp/config.json"; | ||||||||
| // startContainer hook runs in container namespace after pivot_root, | ||||||||
| // use the same path where config was mounted for createContainer | ||||||||
| std::string startContainerConfigPath = "/tmp/dobby_config.json"; | ||||||||
|
|
||||||||
| // populate startContainer hook with DobbyPluginLauncher args | ||||||||
| rt_defs_hook *startContainerEntry = (rt_defs_hook*)calloc(1, sizeof(rt_defs_hook)); | ||||||||
| setPluginHookEntry(startContainerEntry, "startContainer", configPath); | ||||||||
| setPluginHookEntry(startContainerEntry, "startContainer", startContainerConfigPath); | ||||||||
| cfg->hooks->start_container = (rt_defs_hook**)realloc(cfg->hooks->start_container, sizeof(rt_defs_hook*) * ++cfg->hooks->start_container_len); | ||||||||
| cfg->hooks->start_container[cfg->hooks->start_container_len-1] = startContainerEntry; | ||||||||
| #endif | ||||||||
|
|
@@ -748,16 +755,19 @@ bool DobbyConfig::updateBundleConfig(const ContainerId& id, std::shared_ptr<rt_d | |||||||
| // if there are any rdk plugins, set up DobbyPluginLauncher in config | ||||||||
| if (cfg->rdk_plugins && cfg->rdk_plugins->plugins_count) | ||||||||
| { | ||||||||
| #ifdef USE_STARTCONTAINER_HOOK | ||||||||
| // bindmount DobbyPluginLauncher to container | ||||||||
| if(!addMount(PLUGINLAUNCHER_PATH, PLUGINLAUNCHER_PATH, "bind", 0, | ||||||||
| // Bind mount the config.json file to a fixed path inside the container. | ||||||||
| // This is needed because createContainer hooks run in the container's mount | ||||||||
| // namespace but need to access the config.json file which exists on the host. | ||||||||
| // We use /tmp/dobby_config.json as a well-known location that exists in all containers. | ||||||||
| if(!addMount(bundlePath + "/config.json", "/tmp/dobby_config.json", "bind", 0, | ||||||||
| { "bind", "ro", "nosuid", "nodev" })) | ||||||||
| { | ||||||||
| return false; | ||||||||
| AI_LOG_WARN("Failed to add config mount for hooks, createContainer may fail"); | ||||||||
|
||||||||
| AI_LOG_WARN("Failed to add config mount for hooks, createContainer may fail"); | |
| AI_LOG_ERROR("Failed to add config mount for hooks, aborting bundle config update"); | |
| return false; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -467,16 +467,25 @@ void DobbyTemplate::setTemplateCpuRtSched() | |
|
|
||
| long cpuRtRuntime = 0; | ||
| long cpuRtPeriod = 0; | ||
| bool isCgroupV2 = false; | ||
| while ((mnt = getmntent_r(procMounts, &mntBuf, buf, sizeof(buf))) != nullptr) | ||
| { | ||
| // skip entries that don't have a mount point, type or options | ||
| if (!mnt->mnt_type || !mnt->mnt_dir || !mnt->mnt_opts) | ||
| continue; | ||
|
|
||
| // skip non-cgroup mounts | ||
| if (strcmp(mnt->mnt_type, "cgroup") != 0) | ||
| // skip non-cgroup mounts (check for both cgroup v1 and v2) | ||
| if (strcmp(mnt->mnt_type, "cgroup") != 0 && strcmp(mnt->mnt_type, "cgroup2") != 0) | ||
| continue; | ||
|
|
||
| // cgroupv2 doesn't support cpu.rt_runtime_us in the same way | ||
| if (strcmp(mnt->mnt_type, "cgroup2") == 0) | ||
| { | ||
| AI_LOG_INFO("cgroup v2 detected, CPU RT runtime defaults to disabled"); | ||
| isCgroupV2 = true; | ||
| break; | ||
| } | ||
|
Comment on lines
+470
to
+487
|
||
|
|
||
| // check if a cpu cgroup mount | ||
| char* mntopt = hasmntopt(mnt, "cpu"); | ||
| if (!mntopt || (strncmp(mntopt, "cpu", 3) != 0)) | ||
|
|
@@ -700,3 +709,4 @@ bool DobbyTemplate::applyAt(int dirFd, const std::string& fileName, | |
| { | ||
| return instance()->_applyAt(dirFd, fileName, dictionary, prettyPrint); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,31 +166,54 @@ std::map<IDobbyEnv::Cgroup, std::string> DobbyEnv::getCgroupMountPoints() | |
| struct mntent* mnt; | ||
| char buf[PATH_MAX + 256]; | ||
|
|
||
| // Check for cgroupv2 unified hierarchy first | ||
| bool isCgroupV2 = false; | ||
| while ((mnt = getmntent_r(procMounts, &mntBuf, buf, sizeof(buf))) != nullptr) | ||
| { | ||
| // skip entries that don't have a mountpount, type or options | ||
| if (!mnt->mnt_type || !mnt->mnt_dir || !mnt->mnt_opts) | ||
| continue; | ||
|
|
||
| // skip non-cgroup mounts | ||
| if (strcmp(mnt->mnt_type, "cgroup") != 0) | ||
| continue; | ||
|
|
||
| // check for the cgroup type | ||
| for (const std::pair<const std::string, IDobbyEnv::Cgroup> cgroup : cgroupNames) | ||
| if (mnt->mnt_type && strcmp(mnt->mnt_type, "cgroup2") == 0) | ||
| { | ||
| char* mntopt = hasmntopt(mnt, cgroup.first.c_str()); | ||
| if (!mntopt) | ||
| isCgroupV2 = true; | ||
| AI_LOG_INFO("detected cgroup v2 unified hierarchy @ '%s'", mnt->mnt_dir); | ||
| // For cgroupv2, all controllers are at the same mount point | ||
| std::string cgroupPath = mnt->mnt_dir; | ||
| for (const auto& cgroup : cgroupNames) | ||
| { | ||
| mounts[cgroup.second] = cgroupPath; | ||
| } | ||
| break; | ||
|
Comment on lines
+169
to
+183
|
||
| } | ||
| } | ||
|
|
||
| // Reset to scan for cgroupv1 if not v2 | ||
| if (!isCgroupV2) | ||
| { | ||
| rewind(procMounts); | ||
| while ((mnt = getmntent_r(procMounts, &mntBuf, buf, sizeof(buf))) != nullptr) | ||
| { | ||
| // skip entries that don't have a mountpount, type or options | ||
| if (!mnt->mnt_type || !mnt->mnt_dir || !mnt->mnt_opts) | ||
| continue; | ||
|
|
||
| if (strcmp(mntopt, cgroup.first.c_str()) != 0) | ||
| // skip non-cgroup mounts | ||
| if (strcmp(mnt->mnt_type, "cgroup") != 0) | ||
| continue; | ||
|
|
||
| AI_LOG_INFO("found cgroup '%s' mounted @ '%s'", | ||
| cgroup.first.c_str(), mnt->mnt_dir); | ||
| // check for the cgroup type | ||
| for (const std::pair<const std::string, IDobbyEnv::Cgroup> cgroup : cgroupNames) | ||
| { | ||
| char* mntopt = hasmntopt(mnt, cgroup.first.c_str()); | ||
| if (!mntopt) | ||
| continue; | ||
|
|
||
| mounts[cgroup.second] = mnt->mnt_dir; | ||
| break; | ||
| if (strcmp(mntopt, cgroup.first.c_str()) != 0) | ||
| continue; | ||
|
|
||
| AI_LOG_INFO("found cgroup '%s' mounted @ '%s'", | ||
| cgroup.first.c_str(), mnt->mnt_dir); | ||
|
|
||
| mounts[cgroup.second] = mnt->mnt_dir; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -200,3 +223,4 @@ std::map<IDobbyEnv::Cgroup, std::string> DobbyEnv::getCgroupMountPoints() | |
| return mounts; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addPluginLauncherHooksconfigures thestartContainerhook to use/tmp/config.json, but inupdateBundleConfigthe bind-mount ofbundlePath + "/config.json"to/tmp/config.jsonappears to have been removed. Unless/tmp/config.jsonis created elsewhere, thestartContainerhook will fail to resolve the config path. Either reinstate the/tmp/config.jsonmount underUSE_STARTCONTAINER_HOOKor update the hook’s-cpath to match the newly mounted/tmp/dobby_config.json(or another guaranteed path).