Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'io.kubernetes:client-java:21.0.1'
implementation 'io.kubernetes:client-java:24.0.0'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.postgresql:postgresql'
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/dgu/cap/ai/MetricsCollectionScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ public class MetricsCollectionScheduler {

@Scheduled(fixedDelay = 60000)
public void collectAndSendMetrics() {
List<PodInfo> pods = kubernetesService.getAllPods();
for (PodInfo pod : pods) {
try {
sendMetrics(pod);
} catch (Exception e) {
log.warn("메트릭 수집/전송 실패 - pod: {}, error: {}", pod.getPodName(), e.getMessage());
try {
List<PodInfo> pods = kubernetesService.getAllPods();
for (PodInfo pod : pods) {
try {
sendMetrics(pod);
} catch (Exception e) {
log.warn("메트릭 수집/전송 실패 - pod: {}, error: {}", pod.getPodName(), e.getMessage());
}
}
} catch (Exception e) {
log.error("메트릭 수집 스케줄러 전체 실패: {}", e.getMessage());
}
}

Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/dgu/cap/anomaly/AnomalyDetectionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ public class AnomalyDetectionService {

@Scheduled(fixedDelay = 30000)
public void detectAnomalies() {
List<PodInfo> pods = kubernetesService.getAllPods();
for (PodInfo pod : pods) {
try {
checkPod(pod);
} catch (Exception e) {
log.warn("Pod 이상 탐지 중 오류 - pod: {}, error: {}", pod.getPodName(), e.getMessage());
try {
List<PodInfo> pods = kubernetesService.getAllPods();
for (PodInfo pod : pods) {
try {
checkPod(pod);
} catch (Exception e) {
log.warn("Pod 이상 탐지 중 오류 - pod: {}, error: {}", pod.getPodName(), e.getMessage());
}
}
} catch (Exception e) {
log.error("이상 탐지 스케줄러 전체 실패: {}", e.getMessage());
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/dgu/cap/kubernetes/KubernetesService.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public List<PodInfo> getPods(String namespace) {
return podList.getItems().stream()
.map(this::toPodInfo)
.collect(Collectors.toList());
} catch (ApiException e) {
} catch (Exception e) {
log.warn("Pod 목록 조회 실패 - namespace: {}, error: {}", namespace, e.getMessage());
return Collections.emptyList();
}
Expand All @@ -61,7 +61,7 @@ public List<PodInfo> getAllPods() {
return podList.getItems().stream()
.map(this::toPodInfo)
.collect(Collectors.toList());
} catch (ApiException e) {
} catch (Exception e) {
log.warn("전체 Pod 목록 조회 실패: {}", e.getMessage());
return Collections.emptyList();
}
Expand All @@ -77,7 +77,7 @@ public List<PodEvent> getPodEvents(String podName, String namespace) {
return eventList.getItems().stream()
.map(this::toPodEvent)
.collect(Collectors.toList());
} catch (ApiException e) {
} catch (Exception e) {
log.warn("Pod 이벤트 조회 실패 - pod: {}, error: {}", podName, e.getMessage());
return Collections.emptyList();
}
Expand Down
Loading