Skip to content

Commit

Permalink
Log warning when no ingresses using secret (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg authored Nov 26, 2024
1 parent 1792242 commit 8a5d8fc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/main/java/app/services/ApplicationIngressesService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemReader;
import org.springframework.lang.NonNull;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.IOException;
Expand All @@ -19,23 +28,10 @@
import java.security.cert.X509Certificate;
import java.time.Duration;
import java.time.Instant;
import java.util.Base64;
import java.util.*;
import java.util.Base64.Decoder;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemReader;
import org.springframework.lang.NonNull;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Service
@Slf4j
Expand Down Expand Up @@ -142,9 +138,16 @@ public void checkCertRenewalsForSecret(@NonNull String secretName) {
.anyMatch(ingressTLS -> Objects.equals(ingressTLS.getSecretName(), secretName)))
)
.flatMap(this::reconcileIngress)
.switchIfEmpty(Mono.error(MissingResourceException::new))
.subscribe(secret -> {
}, throwable ->
log.error("Failed to process cert renewals for secret={}", secretName, throwable)
}, throwable -> {
if (throwable instanceof MissingResourceException) {
log.warn("No ingress(es) found using secret: {}", secretName);
}
else {
log.error("Failed to process cert renewals for secret={}", secretName, throwable);
}
}
);

}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/app/services/MissingResourceException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package app.services;

public class MissingResourceException extends RuntimeException {
public MissingResourceException() {
super();
}

}

0 comments on commit 8a5d8fc

Please sign in to comment.