Skip to content

Commit 3f5bdde

Browse files
authored
Re-watch services/TLS when closed (#52)
Also - upgraded to Spring Boot 3.0.2
1 parent 3e6dbf4 commit 3f5bdde

File tree

10 files changed

+40
-29
lines changed

10 files changed

+40
-29
lines changed

build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.7.5'
2+
id 'org.springframework.boot' version '3.0.2'
33
id 'io.spring.dependency-management' version '1.1.0'
4+
id 'io.freefair.lombok' version '6.6.2'
45
id 'java'
5-
id 'io.github.itzg.simple-boot-image' version '0.5.2'
6+
id 'io.github.itzg.simple-boot-image' version '3.0.0'
67
// https://github.com/qoomon/gradle-git-versioning-plugin
7-
id 'me.qoomon.git-versioning' version '6.4.0'
8+
id 'me.qoomon.git-versioning' version '6.4.2'
89
}
910

1011
group = 'io.github.itzg'
@@ -45,10 +46,8 @@ dependencies {
4546
implementation 'com.nimbusds:nimbus-jose-jwt:9.30.1'
4647
implementation 'org.bouncycastle:bcpkix-jdk18on:1.72'
4748

48-
compileOnly 'org.projectlombok:lombok'
4949
developmentOnly 'org.springframework.boot:spring-boot-devtools'
5050
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
51-
annotationProcessor 'org.projectlombok:lombok'
5251
testImplementation 'org.springframework.boot:spring-boot-starter-test'
5352
testImplementation 'io.projectreactor:reactor-test'
5453
}

gradle/wrapper/gradle-wrapper.jar

935 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ set -- \
205205
org.gradle.wrapper.GradleWrapperMain \
206206
"$@"
207207

208+
# Stop when "xargs" is not available.
209+
if ! command -v xargs >/dev/null 2>&1
210+
then
211+
die "xargs is not available"
212+
fi
213+
208214
# Use "xargs" to parse quoted args.
209215
#
210216
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

gradlew.bat

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,7 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
2929
set APP_BASE_NAME=%~n0
3030
set APP_HOME=%DIRNAME%
3131

@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4040

4141
set JAVA_EXE=java.exe
4242
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
43+
if %ERRORLEVEL% equ 0 goto execute
4444

4545
echo.
4646
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7575

7676
:end
7777
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
78+
if %ERRORLEVEL% equ 0 goto mainEnd
7979

8080
:fail
8181
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8282
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
83+
set EXIT_CODE=%ERRORLEVEL%
84+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
85+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86+
exit /b %EXIT_CODE%
8587

8688
:mainEnd
8789
if "%OS%"=="Windows_NT" endlocal

src/main/java/app/config/AppProperties.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package app.config;
22

3+
import jakarta.validation.Valid;
4+
import jakarta.validation.constraints.Min;
5+
import jakarta.validation.constraints.NotBlank;
6+
import jakarta.validation.constraints.NotEmpty;
7+
import jakarta.validation.constraints.NotNull;
38
import java.time.Duration;
49
import java.util.Map;
5-
import javax.validation.Valid;
6-
import javax.validation.constraints.Min;
7-
import javax.validation.constraints.NotBlank;
8-
import javax.validation.constraints.NotEmpty;
9-
import javax.validation.constraints.NotNull;
1010
import org.springframework.boot.context.properties.ConfigurationProperties;
1111
import org.springframework.boot.context.properties.bind.DefaultValue;
1212
import org.springframework.validation.annotation.Validated;

src/main/java/app/config/Issuer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package app.config;
22

3+
import jakarta.validation.constraints.AssertTrue;
4+
import jakarta.validation.constraints.NotBlank;
5+
import jakarta.validation.constraints.NotEmpty;
6+
import jakarta.validation.constraints.NotNull;
37
import java.net.URI;
48
import java.util.List;
5-
import javax.validation.constraints.AssertTrue;
6-
import javax.validation.constraints.NotBlank;
7-
import javax.validation.constraints.NotEmpty;
8-
import javax.validation.constraints.NotNull;
99

1010
public record Issuer(
1111
@NotNull
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package app.config;
22

3-
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
43
import io.fabric8.kubernetes.client.KubernetesClient;
4+
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
55
import org.springframework.context.annotation.Bean;
66
import org.springframework.context.annotation.Configuration;
77

@@ -10,6 +10,6 @@ public class KubeConfig {
1010

1111
@Bean
1212
public KubernetesClient kubernetesClient() {
13-
return new DefaultKubernetesClient();
13+
return new KubernetesClientBuilder().build();
1414
}
1515
}

src/main/java/app/services/AcmeBaseRequestService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.nimbusds.jose.jwk.RSAKey;
66
import java.net.URI;
77
import lombok.extern.slf4j.Slf4j;
8-
import org.springframework.http.HttpStatus;
8+
import org.springframework.http.HttpStatusCode;
99
import org.springframework.http.ResponseEntity;
1010
import org.springframework.lang.NonNull;
1111
import org.springframework.lang.Nullable;
@@ -61,7 +61,7 @@ private ResponseSpec preEntityRequest(String issuerId, RSAKey jwk, String kid, U
6161
), SignableValue.class
6262
)
6363
.retrieve()
64-
.onStatus(HttpStatus::isError, clientResponse ->
64+
.onStatus(HttpStatusCode::isError, clientResponse ->
6565
clientResponse.bodyToMono(Problem.class)
6666
.flatMap(problem -> clientResponse.createException()
6767
.map(e -> new AcmeProblemException(problem, e))

src/main/java/app/services/ApplicationIngressesService.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public class ApplicationIngressesService implements Closeable {
4545
private final TaskScheduler taskScheduler;
4646
private final CertificateProcessingService certificateProcessingService;
4747
private final AppProperties appProperties;
48-
private final Watch ingressWatches;
49-
private final Watch tlsSecretWatches;
5048
private final Set<String/*ingress name*/> activeIngressReconciles = Collections.synchronizedSet(new HashSet<>());
5149
private final Map<String/*secretName*/, ScheduledFuture<?>> scheduledRenewals = new ConcurrentHashMap<>();
50+
private Watch ingressWatches;
51+
private Watch tlsSecretWatches;
5252

5353
public ApplicationIngressesService(KubernetesClient k8s,
5454
TaskScheduler taskScheduler,
@@ -65,6 +65,7 @@ public ApplicationIngressesService(KubernetesClient k8s,
6565
}
6666

6767
private Watch setupIngressWatch() {
68+
log.debug("Setting up ingress watch");
6869
return k8s.network().v1().ingresses()
6970
.withLabel(Metadata.ISSUER_LABEL)
7071
// ...but not solver ingress that we created temporarily
@@ -87,12 +88,14 @@ public void eventReceived(Action action, Ingress ingress) {
8788

8889
@Override
8990
public void onClose(WatcherException cause) {
90-
log.warn("Ingress watch has closed", cause);
91+
log.debug("Ingress watch has closed", cause);
92+
ingressWatches = setupIngressWatch();
9193
}
9294
});
9395
}
9496

9597
private Watch setupTlsSecretWatch() {
98+
log.debug("Setting up TLS secret watch");
9699
return k8s.secrets()
97100
.withLabel(Metadata.ISSUER_LABEL)
98101
.watch(new Watcher<>() {
@@ -123,7 +126,8 @@ public void eventReceived(Action action, Secret resource) {
123126

124127
@Override
125128
public void onClose(WatcherException cause) {
126-
log.warn("TLS secrets watch closed", cause);
129+
log.debug("TLS secrets watch closed", cause);
130+
tlsSecretWatches = setupTlsSecretWatch();
127131
}
128132
});
129133
}

0 commit comments

Comments
 (0)