Repository navigation
[AIP-3127] feat: 프로젝트 삭제 시 해당 프로젝트의 템플릿 정리 - #120
Merged
Merged
Conversation
template 의 SoT 는 DB, project 의 SoT 는 k8s 라 project CR 이 삭제돼도 그 프로젝트의
template 이 DB 에 그대로 남아 있었다. 프로젝트가 사라지는 시점에 aipub-backend 에
템플릿 삭제를 요청해 두 저장소의 생명주기를 맞춘다.
- TemplateService / TemplateServiceImpl 추가
DELETE /api/v1alpha2/templates?projectName={name}
- AipubConfiguration: v1alpha2 전용 ApiClient 를 별도로 둔다. 인증·SSL 은 기존과 같고
basePath 만 다르며, 앞으로 늘어날 v1alpha2 API 도 이 클라이언트를 재사용한다.
aipub 연동이 꺼져 있으면 기존 서비스들과 같이 no-op 으로 동작한다.
- ProjectReconciler: 네임스페이스가 정리된 뒤 finalizer 를 떼기 직전에 템플릿 삭제를
요청한다. 요청이 실패해도 예외를 전파하지 않아 프로젝트가 Terminating 에 묶이거나
나머지 reconcile 이 중단되지 않는다. 놓친 템플릿은 aipub-backend 의 고아 템플릿
정리 배치가 회수한다.
2 of 4 tasks
AIP-2317 이 aipub-backend 호출을 Basic 인증에서 mTLS 로 바꾸면서 이 브랜치가 쓰던 buildClient(Basic 인증) 방식이 사라졌다. 충돌을 mTLS 팩토리 쪽으로 해소한다. - AipubBackendClientFactory.create 에 basePath 파라미터 추가. v1alpha1/v1alpha2 두 클라이언트가 같은 mTLS 설정을 공유하고 basePath 만 달라진다 - AipubConfiguration.buildClient 는 팩토리 위임으로 축소. Basic 인증 코드 제거 - Dockerfile 정리(AIP-3158)와 형태 통일 — 인터페이스 설명·훅 주석·로그 문구· 테스트 네이밍(<상황>_<기대>)을 같은 모양으로 맞췄다
코드리뷰 지적 반영. - AipubBackendClientFactory: callTimeout 5초. OkHttp 기본값이 무제한이라 응답 없는 백엔드가 reconcile 워커(1개)를 무한정 잡을 수 있었다 - AipubBackendResponseException: content-type 헤더가 없는 non-2xx 응답에서 Map.get 의 null 을 빈 리스트로 오인해 NPE 가 났다. 정작 필요한 statusCode 가 로그에서 사라지던 문제 (기존 버그, 신규 테스트가 잡음) - TemplateServiceImplTest 신설: 경로·메서드·쿼리 파라미터명 계약을 고정한다. 호출부가 best-effort 라 계약이 어긋나도 조용히 삼켜지므로 코드로 막는다 - ProjectControllerFactory: 쓰이지 않는 @AllArgsConstructor 제거. 필드를 추가할 때마다 생성자 시그니처가 조용히 바뀌던 것을 막는다
AIP-3158(Dockerfile 정리) 머지로 같은 4개 파일이 겹쳐 재충돌. 양쪽을 모두 살린다. - ProjectReconciler / ProjectControllerFactory / ControllerConfiguration: dockerfileService · templateService 두 의존성을 나란히 받는다 - reconcileTerminatingProject: project 이름을 지역변수로 뽑아 두 정리 훅에 넘긴다 - 두 정리 테스트: 관심 밖 서비스는 목으로 채워 생성자 변경에 맞춘다
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
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
변경 내용
domain/aipubbackend — 백엔드 호출
TemplateService/TemplateServiceImpl추가.기존
ImageHubService,RepositoryService와 동일하게ApiClient.buildCall+CallHelper패턴을 따른다.configuration — v1alpha2 클라이언트 분리
AipubConfiguration이 만들던ApiClient는 basePath 가/api/v1alpha1로 고정이었다. 신규 엔드포인트가 v1alpha2 라 전용 클라이언트를 하나 더 둔다.buildClient(properties, basePath)로 묶어 중복을 없앴다app.aipub.enabled=false면 기존 서비스들과 같이 no-op 으로 동작한다 — 신규 설정값은 없다controller/cr — 삭제 훅
ProjectReconciler.reconcileTerminatingProject()에서 네임스페이스가 정리된 뒤 finalizer 를 떼기 직전에 템플릿 삭제를 요청한다.호출은 try/catch 로 감싼다. 근거:
관련 변경
AIP-3127 은 두 저장소에 걸쳐 있다.
ten1010-io/aipub-backendfeature/AIP-3127: 삭제 API 신설 + 고아 템플릿 정리 배치 (TO-BE 2)배포 순서: aipub-backend 가 먼저 떠 있어야 이 호출이 404 를 받지 않는다. 순서가 뒤집혀도 best-effort 라 장애로 번지지는 않고 배치가 회수한다.
Test plan
./gradlew clean build통과 (전 모듈)?projectName=alive-project→ 204, 대상만 삭제?projectName=no-such→ 204 (대상 없어도 성공)