Skip to content

Introduce JAILED_DATASET option to poudriere.conf#1197

Open
arrowd wants to merge 1 commit intofreebsd:masterfrom
arrowd:master
Open

Introduce JAILED_DATASET option to poudriere.conf#1197
arrowd wants to merge 1 commit intofreebsd:masterfrom
arrowd:master

Conversation

@arrowd
Copy link
Copy Markdown
Contributor

@arrowd arrowd commented Jan 2, 2025

Rationale for the change:

We at $WORK are using Poudriere as a part of the CI process. For a selected set of ports we define WITH_TESTING_PORTS, which makes the test target a part of the pipeline. It works quite well for many of ports we're using.

However, one of the projects we've developed requires creating a ZFS dataset as part of its tests. The #1175 PR made it possible for zfs command to run, but no datasets or pools are visible from within the jail. This follow-up change passes through a throw-away ZFS dataset into the jail and gives full access to it.

I understand that the feature is quite niche, but it doesn't add much complexity to the code, so I hope it will be accepted.

@bdrewery
Copy link
Copy Markdown
Member

bdrewery commented Feb 8, 2025

Could we add some hooks, or use existing hooks, to achieve this?

@arrowd
Copy link
Copy Markdown
Contributor Author

arrowd commented Feb 9, 2025

I agree, the hooks feels like a more proper place for this feature, but from what I gather, even the "jail start" hook is ran after the jail is actually created, so there is no way for it to pass allow.mount=1 allow.mount.zfs=1 enforce_statfs=1.

@arrowd
Copy link
Copy Markdown
Contributor Author

arrowd commented Mar 3, 2025

How do we move this forward?

@bdrewery bdrewery self-assigned this Apr 18, 2025
@bdrewery bdrewery added this to the 3.5.0 milestone Apr 18, 2025
@arrowd
Copy link
Copy Markdown
Contributor Author

arrowd commented Sep 28, 2025

Bump. Can we get this in?

This option allows passing a temporary ZFS dataset into the jail along with
full control over it from within the jail.

Sponsored by:	Future Crew, LLC
@bdrewery
Copy link
Copy Markdown
Member

The problem is that you want it in so it can be maintained upstream. But without tests it will quickly break and rot and I can't promise it will work tomorrow. It is very niche and I don't see the use case outside of your special port. I think we need to add more hooks to let you have your code run exactly where and how needed.

I agree, the hooks feels like a more proper place for this feature, but from what I gather, even the "jail start" hook is ran after the jail is actually created, so there is no way for it to pass allow.mount=1 allow.mount.zfs=1 enforce_statfs=1.

allow_mount_args="allow.mount=1 allow.mount.zfs=1 enforce_statfs=1"

This could be set in poudriere.conf JAIL_PARAMS.

I'll comment in the code where I think to try hooks.

case "${JAILED_DATASET}" in
"") ;;
*)
allow_mount_args="allow.mount=1 allow.mount.zfs=1 enforce_statfs=1"
Copy link
Copy Markdown
Member

@bdrewery bdrewery Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poudriere.conf JAIL_PARAMS="allow.mount=1 allow.mount.zfs=1 enforce_statfs=1"

Comment on lines +1002 to +1008
if [ "${JAILED_DATASET}" ]; then
local jailed_dataset_name=${ZPOOL}${ZROOTFS}${JAILED_DATASET}_${name:?}
zfs destroy -Rf ${jailed_dataset_name} 2>/dev/null || :
zfs create -o jailed=on ${jailed_dataset_name}
zfs jail ${name:?} ${jailed_dataset_name}
zfs jail ${name:?}-n ${jailed_dataset_name}
fi
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run_hook jstart post "${name}"

Comment on lines +1053 to +1056

if [ "${JAILED_DATASET}" ]; then
zfs destroy -Rf ${ZPOOL}${ZROOTFS}${JAILED_DATASET}_${name:?} 2>/dev/null || :
fi
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run_hook jstop post "${name}"

@bdrewery
Copy link
Copy Markdown
Member

bdrewery commented Nov 13, 2025

If the hooks work for you let me know and I can add them in or you can PR it. If you need an ability for a hook to return something we can discuss that too.

@arrowd
Copy link
Copy Markdown
Contributor Author

arrowd commented Nov 13, 2025

Thank you. I only rebased this PR to catch up with upstream changes and solve conflicts. This is now a very low priority for me, so maybe you should remove this PR from the 3.5.0 milestone.

@bdrewery bdrewery removed this from the 3.5.0 milestone Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants