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

control-service: remove unneeded methods #2260

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import com.vmware.taurus.datajobs.it.common.DataJobDeploymentExtension;
import com.vmware.taurus.datajobs.it.common.DockerConfigJsonUtils;
import com.vmware.taurus.datajobs.it.common.JobExecutionUtil;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1SecretBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
Expand All @@ -40,12 +43,16 @@ public class PrivateBuilderDockerRepoIT extends BaseIT {
@Value("${datajobs.builder.image}")
private String builderImage;

@Autowired
@Qualifier("controlApiClient")
private ApiClient client;

@RegisterExtension
static DataJobDeploymentExtension dataJobDeploymentExtension = new DataJobDeploymentExtension();

private void createBuilderImagePullSecret(String namespaceName) throws Exception {
try {
new CoreV1Api(controlKubernetesService.getClient())
new CoreV1Api(client)
.createNamespacedSecret(
namespaceName,
new V1SecretBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package com.vmware.taurus.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Charsets;
import com.google.common.collect.Iterables;
import com.google.gson.JsonSyntaxException;
Expand Down Expand Up @@ -46,7 +45,6 @@
import java.io.*;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
Expand All @@ -56,7 +54,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.function.Predicate.not;

/**
* A facade over Kubernetes (https://en.wikipedia.org/wiki/Facade_pattern) (not complete see
Expand Down Expand Up @@ -325,23 +322,6 @@ private V1CronJob loadV1CronjobTemplate(File datajobTemplateFile) throws Excepti
return cronjobTemplate;
}

private String getCurrentNamespace() {
return getNamespaceFileContents().stream()
.filter(not(String::isBlank))
.findFirst()
.map(String::strip)
.orElse(null);
}

private List<String> getNamespaceFileContents() {
try {
String namespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace";
return Files.readAllLines(Paths.get(namespaceFile));
} catch (IOException e) {
return Collections.emptyList();
}
}

public Pair<Boolean, String> health() {
try {
var info = new VersionApi(client).getCode();
Expand Down Expand Up @@ -2310,9 +2290,4 @@ static int convertMemoryToMBs(Quantity quantity) {
}
return quantity.getNumber().toBigInteger().divide(divider.multiply(divider)).intValue();
}

@VisibleForTesting
public ApiClient getClient() {
return client;
}
}