보안 인벤토리를 위한 백그라운드 작업
보안 인벤토리를 위한 백그라운드 작업에 대해 설명합니다.
이 문서는 보안 인벤토리에서 장기 실행 대량 작업을 추적하는 백그라운드 작업 시스템에 대해 설명합니다. 목적 # 백그라운드 작업을 통해 사용자는 여러 프로젝트에서 비동기적으로 대량 작업을 수행할 수 있습니다. 이 시스템은 오류 추적과 실패 시 이메일 알림을 제공합니다. 아키텍처 # 흐름 # Mermaid 다이어그램 (8줄) 소스 코드 보기 flowchart LR A[BulkUpdateService] --> B[BulkUpdateSchedulerWorker] B --> C[BackgroundOperationBulkUpdateWorker] C --> D{Failures?} D -->|Yes| E[Email Notification] D -->|No| F[Cleanup] B --> G[Create Redis Operation] C --> H[Update Counters] 시작 : 사용자가 BulkUpdateService 를 통해 대량 작업 트리거 예약 : BulkUpdateSchedulerWorker 가 프로젝트를 수집하고 Redis 작업 생성 처리 : BackgroundOperationBulkUpdateWorker 가 배치로 프로젝트 처리 완료 : 마지막 배치가 완료를 감지하고 실패가 발생한 경우 이메일 전송 정리 : 알림 후 Redis 엔티티 삭제 구성 요소 # 구성 요소 목적 Security::Attributes::BulkUpdateSchedulerWorker 배치 예약 조율, Redis 작업 생성 Security::Attributes::BackgroundOperationBulkUpdateWorker 추적과 함께 프로젝트 처리 Gitlab::BackgroundOperations::RedisStore Redis 상태 관리 Security::BackgroundOperationMailer 실패 알림 이메일 Redis 데이터 구조 # 작업 엔티티 # Key: background_operation:{operation_id} Type: Hash Fields: - id: 작업 ID - operation_type: 작업 유형(예: 'attribute_update') - user_id: 시작한 사용자 - parameters: 작업별 매개변수가 있는 JSON - status: 'pending' | 'running' - total_items: 처리할 총 프로젝트 수 - successful_items: 성공한 프로젝트 수 - failed_items: 실패한 프로젝트 수 - created_at: 타임스탬프 TTL: 72시간 실패한 항목 목록 # Key: background_operation:{operation_id}:failed_items Type: List Items: 다음이 포함된 JSON 객체: - entity_id: 실패한 엔티티의 ID(프로젝트 또는 그룹) - entity_type: 'Project' 또는 'Group' - entity_name: 엔티티 이름 - entity_full_path: 링크를 위한 전체 경로
