Skip to content

Commit

Permalink
Wait for node to be ready
Browse files Browse the repository at this point in the history
  • Loading branch information
sschnabe committed Jul 31, 2023
1 parent 9ce2570 commit dddeaba
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# k3s Maven Plugin

[![License](https://img.shields.io/github/license/kokuwaio/k3s-maven-plugin.svg?label=License)](https://github.com/kokuwaio/k3s-maven-plugin/blob/main/LICENSE)
[![Maven Central](https://img.shields.io/maven-central/v/io.kokuwa.maven/k3s-maven-plugin.svg?label=Maven%20Central)](https://central.sonatype.com/namespace/io.kokuwa.maven)
[![Build](https://img.shields.io/github/actions/workflow/status/kokuwaio/k3s-maven-plugin/build.yaml?branch=main&label=1.x)](https://github.com/kokuwaio/k3s-maven-plugin/actions/workflows/build.yaml?query=branch%3Amain)
[![Build](https://img.shields.io/github/actions/workflow/status/kokuwaio/k3s-maven-plugin/build.yaml?branch=0.x&label=0.x)](https://github.com/kokuwaio/k3s-maven-plugin/actions/workflows/build.yaml?query=branch%3A0.x)
[![Apache License 2.0](https://img.shields.io/github/license/kokuwaio/helm-maven-plugin)](https://spdx.org/licenses/MIT.html)
[![Maven Central](https://img.shields.io/maven-central/v/io.kokuwa.maven/k3s-maven-plugin)](https://central.sonatype.com/namespace/io.kokuwa.maven)
[![Build](https://img.shields.io/github/actions/workflow/status/kokuwaio/k3s-maven-plugin/build.yaml?branch=main)](https://github.com/kokuwaio/k3s-maven-plugin/actions/workflows/build.yaml?query=branch%3Amain)

This is a plugin to manage k3s for integration tests.

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/kokuwa/maven/k3s/mojo/ApplyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public void execute() throws MojoExecutionException {
.exec("kubectl", "get", "sa", "default", "--ignore-not-found", "--output=name")
.isEmpty());

// wait for node getting ready

getDocker().exec("kubectl", "wait", "--for=condition=Ready", "node", "k3s");

// execute command

var result = apply();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/kokuwa/maven/k3s/mojo/RunMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ public void execute() throws MojoExecutionException {

// get image name

if (imageTag.equals("latest")) {
if ("latest".equals(imageTag)) {
getLog().warn("Using image tag 'latest' is unstable.");
}
var image = (imageRegistry == null ? "" : imageRegistry + "/") + imageRepository + ":" + imageTag;

// k3s command

var command = new ArrayList<>(List.of("server", "--https-listen-port=" + portKubeApi));
var command = new ArrayList<>(List.of("server", "--node-name=k3s", "--https-listen-port=" + portKubeApi));
if (disableCloudController) {
command.add("--disable-cloud-controller");
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/kokuwa/maven/k3s/util/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public Task verify() throws MojoExecutionException {
if (exitCode != 0) {
log.error(">>> " + this);
output.forEach(line -> log.error("<<< " + line));
throw new MojoExecutionException("Command failed wit exit code " + exitCode + ": " + this);
System.out.println(">>> " + this);
output.forEach(line -> System.out.println("<<< " + line));
throw new MojoExecutionException("Command failed with exit code " + exitCode + ": " + this);
}
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/kokuwa/maven/k3s/test/AbstractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class AbstractTest {
@BeforeEach
@AfterEach
void reset(TestInfo test, Log log, Docker newDocker) throws MojoExecutionException {
log.info("Reset test: " + test.getTestClass() + "#" + test.getTestMethod());
log.info("Reset test: " + test.getTestMethod().orElse(null));
this.docker = newDocker;
this.docker.removeContainer();
this.docker.removeVolume();
Expand Down

0 comments on commit dddeaba

Please sign in to comment.