-
Notifications
You must be signed in to change notification settings - Fork 6
feat: StatefulSet reconciliation improvements and status monitoring (#43) #51
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
Merged
bestgopher
merged 10 commits into
rustfs:main
from
shahab96:feat/statefulset-reconciliation-#43
Dec 9, 2025
Merged
feat: StatefulSet reconciliation improvements and status monitoring (#43) #51
bestgopher
merged 10 commits into
rustfs:main
from
shahab96:feat/statefulset-reconciliation-#43
Dec 9, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement intelligent StatefulSet update detection and immutable field validation to improve reconciliation efficiency and safety. Changes: - Add statefulset_needs_update() method for semantic diff detection - Add validate_statefulset_update() method for immutable field checks - Refactor reconciliation loop to check/validate before updating - Add new error types: InternalError, ImmutableFieldModified, SerdeJson - Extend error policy with 60s requeue for immutable field errors - Add 9 comprehensive unit tests (35 tests total, all passing) - Update CHANGELOG.md with detailed changes Benefits: - Reduces unnecessary API calls and reconciliation overhead - Prevents invalid updates that would cause API rejections - Provides clear error messages for users - Foundation for rollout monitoring in Phase 2 Related: rustfs#43
Extend status structures and add StatefulSet status helper methods for rollout monitoring support. Changes: - Add Condition struct for Kubernetes standard conditions (Ready, Progressing, Degraded) - Extend Status struct with observed_generation and conditions fields - Extend Pool status with replica tracking and revision fields - Add new PoolState variants: Updating, RolloutComplete, RolloutFailed, Degraded - Add context methods: - get_statefulset_status() - Fetch StatefulSet status - is_rollout_complete() - Check if rollout is complete - get_statefulset_revisions() - Get current and update revisions Benefits: - Foundation for comprehensive rollout monitoring - Kubernetes-standard status conditions - Per-pool rollout status tracking - All existing tests continue to pass Related: rustfs#43
The tracing subscriber was not respecting the RUST_LOG environment variable, making it impossible to see debug logs from the operator. Changes: - Enable 'env-filter' feature for tracing-subscriber in Cargo.toml - Add .with_env_filter() to tracing subscriber initialization - Allows operators to see debug logs with: RUST_LOG=operator=debug This fixes the "no logs" issue reported when running the operator. Testing: - Verified operator runs successfully with RUST_LOG=info - Verified debug logs appear with RUST_LOG=operator=debug - Confirmed diff detection and validation logs are visible Related: rustfs#43
) Changing a pool name creates a new StatefulSet but leaves the old one orphaned. This is invalid because pool names are part of the StatefulSet selector (immutable field). Changes: - Add validation before StatefulSet reconciliation loop - List all StatefulSets owned by the Tenant - Check for StatefulSets whose pool names don't match current spec - Return ImmutableFieldModified error with clear guidance Error message guides users to delete and recreate Tenant if rename needed. Testing: - All 35 tests passing - Operator detects orphaned StatefulSets and returns error - 60-second requeue for user to fix Related: rustfs#43
Implement comprehensive status updates and rollout monitoring to track StatefulSet reconciliation progress in real-time. Changes: - Add build_pool_status() helper method to Tenant to extract status from StatefulSets - Collect pool statuses during StatefulSet reconciliation loop - Aggregate pool statuses into overall Tenant conditions (Ready, Progressing, Degraded) - Update Tenant status with replica counts, pool states, and conditions - Requeue faster (10s) when pools are updating for responsive monitoring - Refactor Context.update_status() to accept full Status struct - Add chrono dependency for timestamp generation Status Updates: - Pool status includes: replicas, ready_replicas, current_replicas, updated_replicas, current_revision, update_revision, last_update_time, and state - Pool states: NotCreated, Initialized, Updating, RolloutComplete, RolloutFailed, Degraded - Tenant conditions: Ready (True/False), Progressing (True during rollout), Degraded (True when degraded) - Tenant overall state: Ready, NotReady, Updating, Degraded Rollout Monitoring: - Tracks individual pool rollout status based on StatefulSet replicas and revisions - Sets Progressing condition during rollouts - Sets Ready condition when all replicas are ready and updated - Sets Degraded condition when pools are unhealthy - Requeues every 10 seconds during active rollouts for responsive updates This completes Phase 3 of issue rustfs#43. Status information is now properly populated and visible in kubectl/k9s.
The replace_status API requires a complete Kubernetes object with apiVersion, kind, metadata, spec, and status - not just the status field. Changes: - Clone the Tenant resource and set its status field - Serialize the complete Tenant object - Fixes 'Object Kind is missing' error during status updates This fixes the status update errors seen in the operator logs.
The Health column was referencing a non-existent .status.healthStatus field. Removed it since STATE column already shows the current state.
…s#43) Changed from replace_status with raw bytes to patch_status with JSON merge patch, which is the proper kube-rs API for updating status subresources. This fixes the 'Object Kind is missing' error.
- Use chained if-let conditions to collapse nested if statements - Use as_deref() instead of as_ref().map(|s| s.as_str()) - Allow unwrap/expect in test modules (acceptable in tests) All clippy checks now pass with -D warnings.
Replace unwrap() and expect() calls with explicit pattern matching in RBAC test code to satisfy clippy lints without using allow annotations. All test behavior is preserved with explicit panic messages on None values.
bestgopher
approved these changes
Dec 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements comprehensive StatefulSet reconciliation improvements with intelligent diff detection, immutable field validation, and real-time status monitoring. This PR addresses issue #43 by adding the infrastructure needed to properly track and manage StatefulSet rollouts.
Changes
Phase 1: StatefulSet Diff Detection and Validation
statefulset_needs_update()method to detect semantic changes across 15+ fieldsvalidate_statefulset_update()to prevent invalid updates to immutable fieldserror_policy()with intelligent retry intervals based on error typePhase 2: Status Types and Helpers
observed_generation- tracks which spec generation was observedconditions- Kubernetes standard conditions (Ready, Progressing, Degraded)replicas,ready_replicas,current_replicas,updated_replicascurrent_revision,update_revision- StatefulSet controller revisionslast_update_time- timestamp of last status updateUpdating,RolloutComplete,RolloutFailed,DegradedPhase 3: Status Updates and Rollout Monitoring
build_pool_status()helper to extract status from StatefulSetsContext.update_status()to use JSON merge patch (proper kube-rs API)Bug Fixes
env-filterfeature)patch_statuswith JSON merge patchDependencies
chronofor RFC3339 timestamp generationStatus Output
The operator now provides comprehensive status information:
kubectl output:
Test Results
Test Plan
kubectl apply -f deploy/rustfs-operator/crds/tenant.yamlkubectl get tenant <name> -o yamlkubectl get tenant -wkubectl describe tenant <name>Related Issues
Closes #43
Breaking Changes
None - all changes are additive and backward compatible.
Rollout Strategy