4.8 KiB
4.8 KiB
Service Daemon Integration
Overview
AtlasOS integrates with system storage daemons (Samba, NFS, iSCSI) to automatically apply configuration changes. When storage services are created, updated, or deleted via the API, the system daemons are automatically reconfigured.
Architecture
The service integration layer (internal/services/) provides:
- Configuration Generation: Converts API models to daemon-specific configuration formats
- Atomic Updates: Writes to temporary files, then atomically replaces configuration
- Safe Reloads: Reloads services without interrupting active connections
- Error Recovery: Automatically restores backups on configuration failures
SMB/Samba Integration
Configuration
- Config File:
/etc/samba/smb.conf - Service:
smbd(Samba daemon) - Reload Method:
smbcontrol all reload-configorsystemctl reload smbd
Features
- Generates Samba configuration from SMB share definitions
- Supports read-only, guest access, and user restrictions
- Automatically reloads Samba after configuration changes
- Validates configuration syntax using
testparm
Example
When an SMB share is created via API:
- Share is stored in the store
- All shares are retrieved
- Samba configuration is generated
- Configuration is written to
/etc/samba/smb.conf - Samba service is reloaded
NFS Integration
Configuration
- Config File:
/etc/exports - Service:
nfs-server - Reload Method:
exportfs -ra
Features
- Generates
/etc/exportsformat from NFS export definitions - Supports read-only, client restrictions, and root squash
- Automatically reloads NFS exports after configuration changes
- Handles multiple clients per export
Example
When an NFS export is created via API:
- Export is stored in the store
- All exports are retrieved
/etc/exportsis generated- Exports file is written atomically
- NFS exports are reloaded using
exportfs -ra
iSCSI Integration
Configuration
- Tool:
targetcli(LIO target framework) - Service:
target(systemd service) - Method: Direct targetcli commands
Features
- Creates iSCSI targets with IQN
- Configures initiator ACLs
- Maps ZVOLs as LUNs
- Manages target enable/disable state
Example
When an iSCSI target is created via API:
- Target is stored in the store
- All targets are retrieved
- For each target:
- Target is created via
targetcli - Initiator ACLs are configured
- LUNs are mapped to ZVOLs
- Target is created via
- Configuration is applied atomically
Safety Features
Atomic Configuration Updates
- Write configuration to temporary file (
*.atlas.tmp) - Backup existing configuration (
.backup) - Atomically replace configuration file
- Reload service
- On failure, restore backup
Error Handling
- Configuration errors are logged but don't fail API requests
- Service reload failures trigger automatic backup restoration
- Validation is performed before applying changes (where supported)
Service Status
Each service provides a GetStatus() method to check if the daemon is running:
// Check Samba status
running, err := smbService.GetStatus()
// Check NFS status
running, err := nfsService.GetStatus()
// Check iSCSI status
running, err := iscsiService.GetStatus()
Requirements
Samba
sambapackage installedsmbcontrolcommand available- Write access to
/etc/samba/smb.conf - Root/sudo privileges for service reload
NFS
nfs-kernel-serverpackage installedexportfscommand available- Write access to
/etc/exports - Root/sudo privileges for export reload
iSCSI
targetclipackage installed- LIO target framework enabled
- Root/sudo privileges for targetcli operations
- ZVOL backend support
Configuration Flow
API Request → Store Update → Service Integration → Daemon Configuration
↓ ↓ ↓ ↓
Create/ Store in Generate Config Write & Reload
Update/ Memory/DB from Models Service
Delete
Future Enhancements
- Async Configuration: Queue configuration changes for background processing
- Validation API: Pre-validate configurations before applying
- Rollback Support: Automatic rollback on service failures
- Status Monitoring: Real-time service health monitoring
- Configuration Diff: Show what will change before applying
Troubleshooting
Samba Configuration Not Applied
- Check Samba service status:
systemctl status smbd - Validate configuration:
testparm -s - Check logs:
journalctl -u smbd
NFS Exports Not Working
- Check NFS service status:
systemctl status nfs-server - Verify exports:
exportfs -v - Check permissions on exported paths
iSCSI Targets Not Created
- Verify targetcli is installed:
which targetcli - Check LIO service:
systemctl status target - Review targetcli output for errors