fix: ConfigService now reads subsystems from database

Critical regression fix - subsystems were hardcoded instead of reading user settings.
Added CreateDefaultSubsystems to queries/subsystems.go.
ConfigService now queries agent_subsystems table for actual user configuration.
AgentLifecycleService creates default subsystems when creating new agents.
Respects user-configured enabled/auto_run settings from UI.
This commit is contained in:
Fimeg
2025-11-10 22:32:22 -05:00
parent e1173c9f3b
commit 455bc75044
3 changed files with 74 additions and 25 deletions

View File

@@ -280,6 +280,23 @@ func (q *SubsystemQueries) DeleteSubsystem(agentID uuid.UUID, subsystem string)
return nil
}
// CreateDefaultSubsystems creates default subsystems for a new agent
func (q *SubsystemQueries) CreateDefaultSubsystems(agentID uuid.UUID) error {
defaults := []models.AgentSubsystem{
{AgentID: agentID, Subsystem: "updates", Enabled: true, AutoRun: true, IntervalMinutes: 60},
{AgentID: agentID, Subsystem: "storage", Enabled: true, AutoRun: true, IntervalMinutes: 5},
{AgentID: agentID, Subsystem: "system", Enabled: true, AutoRun: true, IntervalMinutes: 5},
{AgentID: agentID, Subsystem: "docker", Enabled: true, AutoRun: true, IntervalMinutes: 15},
}
for _, sub := range defaults {
if err := q.CreateSubsystem(&sub); err != nil {
return fmt.Errorf("failed to create subsystem %s: %w", sub.Subsystem, err)
}
}
return nil
}
// Helper function to join update statements
func joinUpdates(updates []string) string {
result := ""