Skip to content

Commit

Permalink
agent-operator: update kubernetes-client to 7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ibodrov committed Dec 23, 2024
1 parent cb75ca2 commit 8b36038
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 85 deletions.
4 changes: 0 additions & 4 deletions agent-operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-apiextensions</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,15 @@
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.dsl.ExecListener;
import io.fabric8.kubernetes.client.dsl.ExecWatch;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayOutputStream;
import java.util.Map;
import java.util.concurrent.CountDownLatch;

public final class PodUtils {

private static final Logger log = LoggerFactory.getLogger(PodUtils.class);

public static Output exec(KubernetesClient client, String podName, String containerName, String... cmd) {
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();

Listener l = new Listener();
try (ExecWatch w = client.pods().withName(podName)
.inContainer(containerName)
.writingOutput(stdout)
.writingError(stderr)
.usingListener(l)
.exec(cmd)) {

l.await();
} catch (Exception e) {
log.error("exec ['{}', '{}'] -> error while executing '{}': {}", podName, containerName, cmd, e.getMessage());
throw e;
}

return new Output(stdout.toString(), stderr.toString());
}

public static void applyTag(KubernetesClient client, String podName, String tagName, String tagValue) {
Pod pod = client.pods().withName(podName).get();
if (pod == null) {
Expand All @@ -81,52 +55,6 @@ public static void applyTag(KubernetesClient client, String podName, String tagN
}
}

public static class Output {

private final String stdout;
private final String stderr;

private Output(String stdout, String stderr) {
this.stdout = stdout;
this.stderr = stderr;
}

public String getStdout() {
return stdout;
}

public String getStderr() {
return stderr;
}
}

private static class Listener implements ExecListener {

private final CountDownLatch latch = new CountDownLatch(1);

@Override
public void onOpen(Response response) {
}

@Override
public void onFailure(Throwable t, Response response) {
latch.countDown();
}

@Override
public void onClose(int code, String reason) {
latch.countDown();
}

public void await() {
try {
latch.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}

private PodUtils() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* =====
*/

import io.fabric8.kubernetes.client.CustomResourceList;
import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList;

public class AgentPoolList extends CustomResourceList<AgentPool> {
public class AgentPoolList extends DefaultKubernetesResourceList<AgentPool> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public DeleteConfigMapChange(String configMapName) {

@Override
public void apply(KubernetesClient client) {
if (client.configMaps().withName(configMapName).delete()) {
var result = client.configMaps().withName(configMapName).delete();
if (!result.isEmpty()) {
// wait till it's actually removed
while (client.configMaps().withName(configMapName).get() != null) {
try {
Expand Down
7 changes: 1 addition & 6 deletions targetplatform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<junit.version>5.9.1</junit.version>
<kafka.client.version>2.4.0</kafka.client.version>
<kerby.version>2.0.1</kerby.version>
<kubernetes.client.version>5.7.0</kubernetes.client.version>
<kubernetes.client.version>7.0.1</kubernetes.client.version>
<launcher.version>0.128</launcher.version>
<liquibase.version>4.29.2</liquibase.version>
<logback.version>1.4.14</logback.version>
Expand Down Expand Up @@ -1101,11 +1101,6 @@
<artifactId>commons-collections</artifactId>
<version>${commons.collections.version}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-common</artifactId>
Expand Down

0 comments on commit 8b36038

Please sign in to comment.