- Add docs/README.md with project overview and current status - Add docs/architecture.md with detailed architecture documentation - Add docs/development.md with development guide for contributors - Update .notes/todo.md to reflect architecture fix completion - Update .notes/plan.md with completed phases and next priorities Architecture fixes (daemon and dbus), bubblewrap integration are now complete. Ready for OCI integration phase.
6 KiB
6 KiB
apt-ostree Architecture Fix Summary
🚨 CRITICAL ISSUE IDENTIFIED
You're absolutely right! We have a major architectural mismatch where apt-ostree commands are implemented as client-only when they should be daemon-based according to rpm-ostree's architecture.
Current Problem (WRONG Architecture)
What We Have:
// src/main.rs - ALL commands are client-only
Commands::Install { packages, dry_run, yes } => {
let system = AptOstreeSystem::new("debian/stable/x86_64").await?;
system.install_packages(&packages, yes).await?; // Direct call, no daemon!
}
What rpm-ostree Does (CORRECT):
// rpm-ostree - Commands communicate with daemon via D-Bus
rpmostree_os_call_install_sync(os_proxy, packages, options, &transaction_address, cancellable, error);
The Fix: Convert to Daemon-Based Architecture
Phase 1: Create Daemon Client Library
// src/daemon_client.rs
pub struct DaemonClient {
connection: Connection,
proxy: Proxy<'static>,
}
impl DaemonClient {
pub async fn install_packages(&self, packages: Vec<String>, yes: bool, dry_run: bool) -> Result<String, Box<dyn Error>> {
let reply: String = self.proxy.call("install_packages", &(packages, yes, dry_run)).await?;
Ok(reply)
}
}
Phase 2: Update Command Implementation
// src/main.rs - Convert to daemon-based
Commands::Install { packages, dry_run, yes } => {
let result = call_daemon_with_fallback(
|client| Box::pin(client.install_packages(packages.clone(), yes, dry_run)),
|| Box::pin(async {
// Fallback to client-only if daemon unavailable
let system = AptOstreeSystem::new("debian/stable/x86_64").await?;
system.install_packages(&packages, yes).await?;
Ok("Packages installed successfully".to_string())
})
).await?;
println!("{}", result);
}
Commands That Need Conversion
High Priority (Core Commands)
- ✅
install- Package installation - ✅
remove- Package removal - ✅
upgrade- System upgrade - ✅
rollback- System rollback - ✅
status- System status - ✅
search- Package search - ✅
list- Package listing
Medium Priority (Advanced Commands)
- ✅
deploy- Deployment management - ✅
checkout- Branch switching - ✅
prune- Deployment cleanup - ✅
apply-live- Live changes - ✅
cancel- Transaction cancellation - ✅
cleanup- System cleanup
Low Priority (Specialized Commands)
- ✅
kargs- Kernel arguments - ✅
initramfs- Initramfs management - ✅
override- Package overrides - ✅
rebase- Tree switching - ✅
reset- State reset - ✅
refresh-md- Metadata refresh - ✅
reload- Configuration reload
Client-Only Commands (Correct)
- ✅
compose- Tree composition (client-only in rpm-ostree) - ✅
db- Database queries (client-only in rpm-ostree) - ✅
usroverlay- Transient overlay (client-only in rpm-ostree)
Benefits of the Fix
1. Proper Architecture
- Follows rpm-ostree's proven daemon-client model
- Maintains architectural consistency
2. Transaction Management
- Daemon handles atomic operations
- Proper rollback support
- Transaction serialization
3. Security
- Privileged operations isolated in daemon
- Proper authentication and authorization
- Secure credential handling
4. Reliability
- Fallback to client-only if daemon unavailable
- Better error handling and recovery
- Robust state management
5. Scalability
- Multiple clients can use daemon simultaneously
- Resource sharing and optimization
- Concurrent operation support
Implementation Plan
Step 1: Create Daemon Client Library
# Create daemon_client.rs with D-Bus communication
touch src/daemon_client.rs
Step 2: Update Command Implementation
# Convert each command to use daemon with fallback
# Update src/main.rs command handlers
Step 3: Test Daemon Communication
# Test daemon is working
sudo apt-ostree daemon-ping
# Test command fallback
apt-ostree status # Should work without daemon
Step 4: Verify Architecture
# Test full workflow
sudo apt-ostree install package-name # Should use daemon
Files to Modify
New Files:
src/daemon_client.rs- Daemon client libraryARCHITECTURE-FIX-SUMMARY.md- This documentation
Modified Files:
src/main.rs- Convert command handlers to daemon-basedsrc/lib.rs- Add daemon_client modulesrc/bin/apt-ostreed.rs- Enhance daemon methods
Testing Strategy
1. Daemon Communication Test
sudo apt-ostree daemon-ping
sudo apt-ostree daemon-status
2. Command Fallback Test
# Stop daemon
sudo systemctl stop apt-ostreed
# Test commands work without daemon
apt-ostree status
apt-ostree search package-name
3. Full Workflow Test
# Start daemon
sudo systemctl start apt-ostreed
# Test privileged operations
sudo apt-ostree install package-name
sudo apt-ostree upgrade
sudo apt-ostree rollback
Success Criteria
✅ Architecture Correctness
- Commands use daemon when available
- Fallback to client-only when daemon unavailable
- Proper D-Bus communication
✅ Functionality Preservation
- All existing commands work
- No regression in functionality
- Backward compatibility maintained
✅ Performance
- No significant performance degradation
- Efficient daemon communication
- Proper resource management
✅ Security
- Privileged operations in daemon
- Proper authentication
- Secure credential handling
Conclusion
This architectural fix is critical for apt-ostree to properly mirror rpm-ostree's design. The current client-only implementation bypasses the daemon entirely, which is incorrect and prevents proper transaction management, security, and scalability.
The fix converts apt-ostree to follow the correct daemon-based architecture while maintaining backward compatibility through fallback mechanisms.