Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log warning when no ingresses using secret #145

Merged
merged 1 commit into from
Nov 26, 2024
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
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();
}

}