Skip to content

resources: add support for setting custom samba configuration #357

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

FTS152
Copy link

@FTS152 FTS152 commented Apr 21, 2025

Add new fields to handle custom Samba configurations.

For [global] section, a new field customGlobalConfig is added under smbCommonConfig to handle custom settings. For individual share configurations, modifications can be made in customShareConfig field under smbShare. This design is chosen because, in group mode, a single server may correspond to several grouped shares.

For example, we can set customGlobalConfig in smbCommonConfig like:

apiVersion: samba-operator.samba.org/v1alpha1
kind: SmbCommonConfig
metadata:
  name: samba-service-mypublished
  namespace: samba-operator-system
spec:
  customGlobalConfig:
    configs:
      aio write size: "1"
      strict rename: "Yes"
  network:
    publish: external

During Update() process for configuration, the applyCustomGlobal() function is used to apply the keys and values from smbCommonConfig.spec.customGlobalConfig.configs into smb.conf, which will take effect on the deployed server. However, this method currently has some limitations. When samba server is already running, it is not possible to update smb.conf by modifying smbCommonconfig without interrupting the service. This is mainly due to the following constraints:

  1. Updates to the ConfigMap are not immediately reflected inside the pod’s volume (e.g., /etc/container-config/config.json)
  2. After modifying smbCommonConfig, you also need to import the changed config json to smbd manually (by execute samba-container import in the pod).
  3. The apply function currently only supports adding or modifying existing fields; it does not yet support field deletion.

These limitations are not insurmountable. The ideal solution would be to implement a mechanism that watches for changes to the config.json inside the pod, automatically imports the new configuration into smbd when changes are detected, and we should also improves the logic of the apply function. For now, this commit only provide the ability for modifying samba configurations when deploying a samba server.

Refs #281

Add new fields to handle custom Samba configurations.
For [global] section, a new field customGlobalConfig is added
under smbCommonConfig to handle custom settings. For individual
share configurations, modifications can be made in customShareConfig
field under smbShare. This design is chosen because, in group mode,
a single server may correspond to several grouped shares.

Signed-off-by: FTS152 <[email protected]>
@phlogistonjohn
Copy link
Collaborator

Thanks for the PR. FWIW this is what we implemented in ceph for something similar:
https://docs.ceph.com/en/latest/mgr/smb/ (search for custom_smb_global_options and/or custom_smb_share_options). It's similar but since the custom options really can break the automation I require a special key to check / hint that the user read the docs and understands the risks of setting a custom config option.

@FTS152
Copy link
Author

FTS152 commented Apr 22, 2025

OK, I will add a key to check if the user already read docs and know the risks that custom configs may lead to unexpected behaviors. Custom settings are ignored if acknowledgement flags are not set:

apiVersion: samba-operator.samba.org/v1alpha1
kind: SmbCommonConfig
metadata:
  name: samba-service-mypublished
  namespace: samba-operator-system
spec:
  customGlobalConfig:
    useUnsafeCustomConfig: true    <-- add this explicitly
    configs:
      aio write size: "1"
      strict rename: "Yes"
  network:
    publish: external

Add a key to check if the user already read docs and know the
risks that custom configs may lead to unexpected behaviors.
Custom settings are ignored if acknowledgement flags are not set
if useUnsafeCustomConfig not set to true explicitly.

Signed-off-by: FTS152 <[email protected]>
@phlogistonjohn phlogistonjohn added the enhancement New feature or request label Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants