Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Add systemd validation check to ValidateInstanceImage

Summary

This PR adds a new validation check to ensure systemd is running on instances, addressing a requirement to validate that systemd is accessible via the systemctl command. The implementation includes:

  • New systemd validation: Added Check 4 to ValidateInstanceImage that runs systemctl is-system-running and accepts both "running" and "degraded" states as valid
  • Function refactoring: Extracted validation logic into smaller helper functions (connectToInstance, validateArchitecture, validateOSVersion, validateHomeDirectory, validateSystemd) to fix lint issues with function length
  • Documentation updates: Updated docs/SECURITY.md and README.md to document the new systemd requirement

The systemd check follows the same error handling pattern as existing validation checks and integrates seamlessly with the current validation pipeline.

Review & Testing Checklist for Human

  • Verify systemd state logic: Test that accepting "degraded" systemd state is appropriate for the use case (degraded means some services failed but systemd is still functional)
  • Test refactored validation logic: Ensure the helper function extraction didn't introduce bugs in error handling or validation flow
  • Test systemd check on target systems: Verify systemctl is-system-running behaves correctly on Ubuntu 20.04/22.04 instances
  • Review documentation completeness: Check if other documentation locations should mention the systemd requirement
  • End-to-end validation testing: Run the full validation pipeline on real instances to ensure all checks work together correctly

Diagram

%%{ init : { "theme" : "default" }}%%
flowchart TD
    subgraph "pkg/v1/image.go"
        A["ValidateInstanceImage()"]:::major-edit
        B["connectToInstance()"]:::major-edit
        C["validateArchitecture()"]:::major-edit
        D["validateOSVersion()"]:::major-edit
        E["validateHomeDirectory()"]:::major-edit
        F["validateSystemd()"]:::major-edit
    end
    
    subgraph "Documentation"
        G["docs/SECURITY.md"]:::minor-edit
        H["README.md"]:::minor-edit
    end
    
    subgraph "Testing Integration"
        I["internal/validation/suite.go"]:::context
    end
    
    A --> B
    A --> C
    A --> D
    A --> E
    A --> F
    I --> A
    
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit
        L3["Context/No Edit"]:::context
    end
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#ADD8E6
    classDef context fill:#FFFFFF
Loading

Notes

  • The systemd validation uses systemctl is-system-running which can return various states; this implementation accepts "running" and "degraded" as valid
  • The refactoring was necessary to fix lint error about function length (45 > 40 statements)
  • Validation tests in internal/validation/suite.go will automatically include the new systemd check since they call ValidateInstanceImage directly
  • All changes follow existing patterns in the codebase for error handling and validation logic

Session Details:

- Add Check 4 to verify systemd is running or degraded
- Update SECURITY.md to document systemd requirement
- Update README.md Platform Support section
- Refactor ValidateInstanceImage into smaller helper functions to fix lint
- Validation tests automatically include new check

Co-Authored-By: Alec Fong <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- systemctl is-system-running returns exit code 1 for degraded state
- Check stdout content before treating command error as failure
- Accept both running and degraded as valid systemd states

Co-Authored-By: Alec Fong <[email protected]>
@theFong theFong merged commit 8a168fa into main Aug 10, 2025
5 checks 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