Skip to content

Comments

feat: [AAP-64171] Backport project sync feature branch to main#1482

Open
hsong-rh wants to merge 4 commits intoansible:mainfrom
hsong-rh:aap-64171
Open

feat: [AAP-64171] Backport project sync feature branch to main#1482
hsong-rh wants to merge 4 commits intoansible:mainfrom
hsong-rh:aap-64171

Conversation

@hsong-rh
Copy link
Contributor

https://issues.redhat.com/browse/AAP-64171

Summary

Backport the project-sync feature branch into main. This PR includes three features and a rebase conflict resolution commit:

  • Project auto-sync configuration — Adds update_revision_on_launch and scm_update_cache_timeout fields to the Project model, enabling automatic project synchronization before activation launch (migration 0068)
  • Activation auto-restart on project sync (AAP-64077) — Adds SHA256 hash fields and awaiting_project_sync flag. When a project sync changes rulebook content, enabled activations with restart_on_project_update=True are automatically restarted (migration 0069)
  • Computed warnings for stale event stream mappings (AAP-65811) — Skips auto-restart for activations with source_mappings and surfaces a computed warnings field on the activation detail API when rulebook content has drifted
  • Rebase conflict resolution — Resolves rename conflicts (check_project_queue_healthcheck_default_worker_health) and adds check_dispatcherd_workers_health mocks to sync dependency tests

Test plan

  • 202 tests pass across test_projects.py, test_activation.py, test_project.py
  • Lint passes (black, isort, ruff, flake8)
  • Pre-commit hooks pass
  • CI pipeline passes
  • eda-qa e2e tests pass without errors

🤖 Generated with Claude Code

hsong-rh and others added 4 commits February 17, 2026 15:37
…ible#1471)

https://issues.redhat.com/browse/AAP-64075
https://issues.redhat.com/browse/AAP-64076

- Add project auto-sync configuration fields
(`update_revision_on_launch`, `scm_update_cache_timeout`,
`last_synced_at`) with `needs_update_on_launch` property and grace
period protection against infinite restart loops
- Enhance project sync task management to add comprehensive exception
handling with `_get_project_safely()`,
`_handle_project_error_recovery()`, and enhanced monitoring for stuck
projects
- Replace broad exception catching with specific `ObjectDoesNotExist`
and `DatabaseError` handling
…e#1473)

https://issues.redhat.com/browse/AAP-64077

Replace the proposed ActivationSyncDependency table with a simple
`awaiting_project_sync` boolean flag on the Activation model. Add SHA256
hash fields for efficient rulebook content change detection.

- **Boolean flag**: awaiting_project_sync on Activation replaces the
dependency table
- **SHA256 hashing**: rulesets_sha256 on Rulebook,
rulebook_rulesets_sha256 on Activation
- **Sync-before-launch**: Enable/restart checks
needs_project_update_on_launch, sets flag, triggers sync, returns 202
- **Auto-restart**: After sync, activations with
restart_on_project_update=True and changed content are restarted
- **Error handling**: sync_project() failure resets flag; sync failure
sets waiting activations to ERROR
- **Safety nets**: disable()/destroy() clear the flag; monitor recovers
orphaned flags
- **No double-restart**: Auto-restart query excludes
awaiting_project_sync=True activations
- **Migration 0069**: Adds all new fields + RunPython to backfill SHA256
hashes

- [x] Enable returns 202 when project needs sync
- [x] Enable skips sync_project when project already syncing
- [x] Enable proceeds normally (204) when no sync needed
- [x] Restart returns 202 when project needs sync
- [x] sync_project() failure resets flag and returns error
- [x] Disable clears awaiting_project_sync flag
- [x] Destroy clears awaiting_project_sync flag
- [x] Auto-restart triggers on content change (SHA256 mismatch)
- [x] Auto-restart skips unchanged content
- [x] Auto-restart skips awaiting-sync activations (no double restart)
- [x] Hash-only change updates metadata without restart
- [x] Resume enables disabled waiting activations
- [x] Resume restarts enabled waiting activations
- [x] Resume handles multiple activations per project
- [x] Resume failure sets activation to ERROR
- [x] Sync failure sets ERROR on waiting activations
- [x] Sync failure ignores non-waiting activations
- [x] Deleted project cleans up waiting activations
- [x] Monitor recovers orphaned awaiting activations (completed project)
- [x] Monitor recovers orphaned awaiting activations (failed project)
- [x] Monitor skips actively syncing projects
- [x] Migration populates SHA256 for existing rulebooks
- [x] Migration populates SHA256 for existing activations
- [x] Migration handles empty rulesets
…gs (ansible#1480)

https://issues.redhat.com/browse/AAP-65811

Skip auto-restart for activations with source_mappings when rulebook
content changes during project sync, freezing their cached content so
the stale state is preserved for warning detection. Add a computed
`warnings` list field to the activation detail API endpoint that
surfaces when the activation's rulebook SHA256 differs from the current
upstream rulebook, or when the linked rulebook has been deleted.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace check_project_queue_health with check_default_worker_health
  (renamed on main)
- Add check_dispatcherd_workers_health mocks to sync dependency tests
  (new health check added on main)
- Remove stale check_project_queue_health import from test_projects.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hsong-rh hsong-rh requested a review from a team as a code owner February 17, 2026 20:55
@hsong-rh hsong-rh marked this pull request as draft February 17, 2026 20:58
@sonarqubecloud
Copy link

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 97.29730% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.74%. Comparing base (1d7e5b2) to head (cf19b8b).

Files with missing lines Patch % Lines
src/aap_eda/tasks/project.py 97.77% 5 Missing ⚠️
src/aap_eda/core/models/project.py 85.18% 4 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1482      +/-   ##
==========================================
+ Coverage   91.44%   91.74%   +0.30%     
==========================================
  Files         235      237       +2     
  Lines       10135    10444     +309     
==========================================
+ Hits         9268     9582     +314     
+ Misses        867      862       -5     
Flag Coverage Δ
unit-int-tests-3.11 91.74% <97.29%> (+0.30%) ⬆️
unit-int-tests-3.12 91.74% <97.29%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/aap_eda/analytics/analytics_collectors.py 98.38% <100.00%> (ø)
src/aap_eda/api/serializers/activation.py 95.87% <100.00%> (+0.08%) ⬆️
src/aap_eda/api/serializers/project.py 93.45% <100.00%> (+0.25%) ⬆️
src/aap_eda/api/views/activation.py 97.54% <100.00%> (+0.33%) ⬆️
...da/core/migrations/0068_add_project_sync_fields.py 100.00% <100.00%> (ø)
...rations/0069_activation_restart_and_sync_fields.py 100.00% <100.00%> (ø)
src/aap_eda/core/models/activation.py 100.00% <100.00%> (ø)
src/aap_eda/core/models/rulebook.py 96.77% <100.00%> (+0.05%) ⬆️
src/aap_eda/core/utils/rulebook.py 97.10% <100.00%> (-0.16%) ⬇️
src/aap_eda/services/project/imports.py 88.12% <100.00%> (+0.22%) ⬆️
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hsong-rh hsong-rh marked this pull request as ready for review February 17, 2026 21:33
@hsong-rh hsong-rh added run-e2e and removed run-e2e labels Feb 17, 2026
@hsong-rh
Copy link
Contributor Author

/run-e2e

@hsong-rh
Copy link
Contributor Author

The e2e test is passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants