Skip to content

bind mounts, rpc_pipefs, file install from datastore key seeded from source with optional templating#1037

Merged
cgalibern merged 17 commits into
opensvc:mainfrom
cvaroqui:main
May 29, 2026
Merged

bind mounts, rpc_pipefs, file install from datastore key seeded from source with optional templating#1037
cgalibern merged 17 commits into
opensvc:mainfrom
cvaroqui:main

Conversation

@cvaroqui
Copy link
Copy Markdown
Member

@cvaroqui cvaroqui commented May 28, 2026

Description

This pull request introduces multiple updates to the fs.host driver and other related components:

  • Added support for bind mounts:

    • Enables mounting regular files as devices, along with utility functions for validation and ensuring mount integrity.
    • Mangles mount commands to accommodate the specialized handling of bind mounts.
    • Skips filesystem checks (fsck) for bind-mounted devices already mounted elsewhere.
  • Enhanced tmpfs validation:

    • Ensures proper filesystem verification on daemon certificate directories.
  • Removed redundant imports and streamlined permissions logic:

    • Adjusted permissions based on default RootDirPerm or a fallback value in resfshost and resfszfs.
  • Improved app resource handling:

    • Refactored and centralized resource-handling logic to remove duplication and improve handling for stopped resources.
  • Introduced Go templating for installable files:

    • Added support for advanced templating mechanisms to simplify configuration management across services.
  • Updated keywords and defaults:

    • New app.desc keyword for labeling app resources more intuitively.
    • Default value for fs.host dev set to "none" for easier virtual filesystem configuration.
    • Support for rpc_pipefs filesystem.
  • Enhanced datastore seeding:

    • Automatically creates and seeds datastores with installation sources during instance startup.
    • Added support for URI-based source syntax in install keywords for remote configuration management.
  • Minor UI/UX improvement:

    • Removed icons from the "config validate" table cells for clarity.

cvaroqui added 11 commits May 28, 2026 18:41
- Add Source field to KeyMeta struct in core/datarecv/keymeta.go
- Add Source field to KVInstall struct in core/object/datastore_key_install.go
- Update ParseKeyMetaRel to parse source <uri> syntax
- Update parseFile in getInstallMetadata to parse source <uri>
- Implement seedKeyFromSource function to fetch data from URI and seed datastore key
- Add seeding logic in install() and InstallFromDatastore() functions
- Update keyword example and documentation to include source syntax

The source URI is used to seed datastore key data only during the provision
action if the key doesn't already exist. This allows for automatic fetching
and seeding of configuration scripts/templates from remote sources.
On instance start, if a install source key must be seeded in a
datastore in the same namespace as the service, create the
datastore.

Example:

	$ om testnfs instance start
	12:14:26.020 INF testnfs: >>> do start [bin/om testnfs instance start] (origin user, sid 22c28c14-9afd-4978-bfb1-5d4bca0154de)
	12:14:26.057 INF testnfs: ip#1: 10.29.0.21 is already up on br-prd
	12:14:26.063 INF testnfs: fs#1: /dev/mapper/36001405ded28414e2ea4c248008e6af1 already mounted on /srv/testnfs.root.svc.reliable-leopard
	12:14:26.064 INF testnfs: fs#1: created datastore cfg/testnfs for seeding
	12:14:26.064 INF testnfs: fs#1: seeding key init/nfs from source https://raw.githubusercontent.com/opensvc/opensvc_templates/refs/heads/main/nfs/script
	12:14:26.204 INF cfg/testnfs: set key init/nfs
	12:14:26.386 INF testnfs: fs#1: seeded key init/nfs from source https://raw.githubusercontent.com/opensvc/opensvc_templates/refs/heads/main/nfs/script
This "none" value permits simpler definitions for virtual
filesystems.

e.g

	[fs#1]
	type = tmpfs
	mnt = /srv/{fqdn}/tmp
Previously the label was stuttering the driver id.
This feature allows this kind of setup in a `svc1` service deployed in
a cluster named `cluster1`:

	[fs#1]
	install = /init/nfsd from ./cfg/{name} source {env.templates}/nfs/init.nfsd template mode 755
	...

	[env]
	a = {fqdn}
	b = c

In this case, if the source contains:

	#!/usr/bin/bash
	echo {{.a}}
	echo {{.b}}

The seeded `./cfg/{name}` key `init/nfsd` will contain:

	#!/usr/bin/bash
	echo svc1.root.svc.cluster1
	echo c

The implicit key name support highlighted in this example is also
added by this patch:

	/init/nfsd path => init/nfsd key name
* Move ResourceHandlingFile and ResourceHandlingDevice to the
  actor type and expose via the Actor interface.

* Replace the duplicate implementation in container.kvm,
  container.vbox and container.lxc drivers

* Use ResourceHandlingFile in resapp CommonStop to skip the
  stopper exec if the resouce where the stopper script is stored
  is not up.
Use the datarecv.T embed directly.

And apply to the mountpoint the datarecv default RootDirPerm()
if available, or default to 0755 as it was the permission
hardcoded previously.
Previously we only verified any kind of virtual fs was mounted
in /var/lib/opensvc/certs.
* When dev is a regular file, create the parent mnt file dir and touch the mnt file before mount
* Fix a panic in `device.T.Slaves()` caused by file bind mounts.
* Also fix `device.T.Holders()` preventively.
* Add a specific `isBindMounted()` for bind mounts
* Add the `file.VerifySameMajorMinorAndInode(p1, p2 string) error` util func to back the fs.host driver's `isBindMounted()`
* Mangle the mount command for bind mounts (no `-t <type>`, add `-o bind`)
* Add a `findmnt.HasMnt(ctx, mntpt) (bool, error)` helper for the fs.host driver's `isBindMounted`
* Add a `findmnt.HasDev(ctx, dev) (bool, error)` helper for the fs.host driver's fsck codepath.
* Adapt the `findmnt.List` for the case the device is a regular file (same format as directories)
* Skip fs.host fsck if the device is already mounted somewhere, because fsck would fail and the fact that the device is already mounted once proves it is mountable.
* Stricter rules on driver groups
* Forbid install from local source to non-root
* Forbid run_args to non-root
* Forbid pre_monitor_action to non-root
* Forbid monitor_action values expect "switch", "freezestop", "none"
* Apply rbac to POST PUT object config file (only PATCH was done)
* Fix the trigger deny rbac (trigger kws don't end with "_triggger")
* Fix scoping circumventing the rbac rules
cvaroqui added 3 commits May 29, 2026 15:55
* allow fs.flag
* allow ip.cni
* env section
* log rbac errors from the api handler
* do the obj config rbac validation in volatile mode
Instead of just the changed parts.

So if a root user injected a svc in a namespace, the admins of
this namespace are not allowed to modify it if it contains any
root-only settings.
@cgalibern cgalibern merged commit 3d90798 into opensvc:main May 29, 2026
1 check passed
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