siderolabs / extensions

Talos Linux System Extensions
Mozilla Public License 2.0
104 stars 105 forks source link

How to configure mdadm.conf? #429

Open thoro opened 1 month ago

thoro commented 1 month ago

Hello,

I do not want mdadm to auto assemble arrays for me, how can I add:

AUTO -all

to the mdadm.conf file?

frezbo commented 1 month ago

this is not possible at the moment, but this can be made configurable via ExtensionServiceConfig

thoro commented 1 month ago

Do you have an example how this could be integrated into an extension? I maybe would be willing to create a PR for the mdadm extension then.

frezbo commented 1 month ago

you can take a look at nut-client extension, the mdadm extension probably needs a flag to point to a config file

thoro commented 1 month ago

mdadm implicitly reads the config file, because it's called via udevd (rules defined in the extension)

the usual place is /etc/mdadm.conf, can you also set it at this location via the ExtensionServiceConfig?

frezbo commented 1 month ago

mdadm implicitly reads the config file, because it's called via udevd (rules defined in the extension)

the usual place is /etc/mdadm.conf, can you also set it at this location via the ExtensionServiceConfig?

we might have to compile mdadm to use a custom path then, extensions only allow /usr/local

thoro commented 1 month ago

I tried to just apply an ExtensionServiceConfig now, but talosctl ls /usr/local/etc/mdadm.conf reports non-existing.

apiVersion: v1alpha1
kind: ExtensionServiceConfig
name: mdadm
configFiles:
  - content: |-
        AUTO -all
    mountPath: /usr/local/etc/mdadm.conf

When are those configs applied? Do you need to run a container in the extension? Are the names supposed to be the same as the extension?

frezbo commented 1 month ago

I tried to just apply an ExtensionServiceConfig now, but talosctl ls /usr/local/etc/mdadm.conf reports non-existing.

apiVersion: v1alpha1
kind: ExtensionServiceConfig
name: mdadm
configFiles:
  - content: |-
        AUTO -all
    mountPath: /usr/local/etc/mdadm.conf

When are those configs applied? Do you need to run a container in the extension? Are the names supposed to be the same as the extension?

yes, it only gets in effect when there is an extension with the same name

thoro commented 1 month ago

I checked the executable, and looks like the path is sadly not compiled in correctly.

 salt/talos  (k8s: admin@dc-at-prod-02) $ talosctl --talosconfig=.talosconfig  -n dc-at-prod-02-h01 get extensions 2
NODE                NAMESPACE   TYPE              ID   VERSION   NAME    VERSION
dc-at-prod-02-h01   runtime     ExtensionStatus   2    1         mdadm   v4.2
 salt/talos  (k8s: admin@dc-at-prod-02) $ talosctl --talosconfig=.talosconfig  -n dc-at-prod-02-h01 get extensionserviceconfig mdadm
NODE                NAMESPACE   TYPE                     ID      VERSION
dc-at-prod-02-h01   runtime     ExtensionServiceConfig   mdadm   1
 salt/talos  (k8s: admin@dc-at-prod-02) $ talosctl --talosconfig=.talosconfig  -n dc-at-prod-02-h01 get extensionserviceconfig mdadm -o yaml;
node: dc-at-prod-02-h01
metadata:
    namespace: runtime
    type: ExtensionServiceConfigs.runtime.talos.dev
    id: mdadm
    version: 1
    owner: runtime.ExtensionServiceConfigController
    phase: running
    created: 2024-07-18T12:05:45Z
    updated: 2024-07-18T12:05:45Z
spec:
    files:
        - content: AUTO -all
          mountPath: /usr/local/etc/mdadm.conf
 salt/talos  (k8s: admin@dc-at-prod-02) $ talosctl --talosconfig=.talosconfig  -n dc-at-prod-02-h01 ls /usr/local/etc/mdadm.conf
NODE   NAME
1 error occurred:
 rpc error: code = Unknown desc = lstat /usr/local/etc/mdadm.conf: no such file or directory

I have readded the mdadm extension to my cluster, but the ExtensionServiceConfig is still not applied as expected - ideas?

thoro commented 1 month ago

@frezbo Can you check this one here: https://github.com/siderolabs/extensions/pull/430 ?

frezbo commented 1 month ago

ahh ExtensionServiceConfig is currently only for extension services, not plain extensions

Also can we specify the config file here: https://github.com/siderolabs/extensions/blob/main/storage/mdadm/files/udev-md-raid-arrays.rules#L20?

thoro commented 1 month ago

~sadly not, it's hardcoded in the source via define, there's no option to pass config file via cli args~

Edit: Sorry, I was wrong .. seems to be a -c option!

thoro commented 1 month ago

~is there a build services to get a test image out of the PR - I can't build it on my M2 mac~ Edit: solved it, I added by mistake a space into the pkg.yaml, that removed an important build env var.

thoro commented 1 month ago

@frezbo I added the the -c option to specify the config file in the udev rules. What I do not understand yet, is how to get a config file into that folder anyways 😃

Edit: I think the config file is rather well stored under /var/lib/mdadm/mdadm.conf but please let me know what's the correct destination, and how to actually edit that file then.

frezbo commented 1 month ago

@frezbo I added the the -c option to specify the config file in the udev rules. What I do not understand yet, is how to get a config file into that folder anyways 😃

Edit: I think the config file is rather well stored under /var/lib/mdadm/mdadm.conf but please let me know what's the correct destination, and how to actually edit that file then.

we don't have a good way in talos now to get a config file or have a default one so that the it doesn't break existing config, let's keep a hold on to this until we have a better solution from talos/extensions side