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

refactor(kubernetes): refactor and upgrade kubernetes java client apis and its relevant dependency during upgrade to spring boot 2.6.x #6133

Merged
merged 2 commits into from
Jan 10, 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
1 change: 1 addition & 0 deletions clouddriver-kubernetes/clouddriver-kubernetes.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ dependencies {
implementation "io.spinnaker.kork:kork-secrets"
implementation "io.spinnaker.kork:kork-security"
implementation "io.kubernetes:client-java"
implementation "io.kubernetes:client-java-api-fluent:13.0.2"
implementation "org.apache.commons:commons-lang3"
implementation "org.springframework.boot:spring-boot-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public KubernetesJobStatus(V1Job job, String account) {
this.account = account;
this.name = job.getMetadata().getName();
this.location = job.getMetadata().getNamespace();
this.createdTime = job.getMetadata().getCreationTimestamp().getMillis();
this.createdTime = job.getMetadata().getCreationTimestamp().toInstant().toEpochMilli();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import com.netflix.spinnaker.clouddriver.security.AccountCredentialsProvider;
import io.kubernetes.client.openapi.models.V1Job;
import io.kubernetes.client.openapi.models.V1Pod;
import java.time.OffsetDateTime;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.Getter;
import org.apache.commons.lang3.NotImplementedException;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -82,12 +82,12 @@ public KubernetesJobStatus collectJob(String account, String location, String id
.map(m -> KubernetesCacheDataConverter.getResource(m, V1Pod.class))
.sorted(
(p1, p2) -> {
DateTime dtDefault = new DateTime(0);
DateTime time1 =
OffsetDateTime dtDefault = OffsetDateTime.now();
OffsetDateTime time1 =
p1.getStatus() != null
? Optional.ofNullable(p1.getStatus().getStartTime()).orElse(dtDefault)
: dtDefault;
DateTime time2 =
OffsetDateTime time2 =
p2.getStatus() != null
? Optional.ofNullable(p2.getStatus().getStartTime()).orElse(dtDefault)
: dtDefault;
Expand Down
2 changes: 1 addition & 1 deletion clouddriver-web/clouddriver-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
testImplementation "io.spinnaker.kork:kork-test"
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation "org.spockframework:spock-core"
testImplementation "io.kubernetes:client-java"
testImplementation "io.kubernetes:client-java-api-fluent:13.0.2"
testImplementation "org.codehaus.groovy:groovy-json"

// Add each included cloud provider project as a runtime dependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.V1PodCondition;
import io.kubernetes.client.openapi.models.V1PodStatus;
import java.time.OffsetDateTime;
import java.util.List;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -53,14 +53,14 @@ public class ObjectMapperTest {
public void testJodaTimeSerializationForKubernetesJob() {
V1Job job = new V1Job();
V1ObjectMeta metadata = new V1ObjectMeta();
metadata.setCreationTimestamp(DateTime.now());
metadata.setCreationTimestamp(OffsetDateTime.now());
job.setMetadata(metadata);
KubernetesJobStatus kubernetesJobStatus = new KubernetesJobStatus(job, "kubernetesAccount");

V1Pod pod = new V1Pod();
V1PodStatus status = new V1PodStatus();
V1PodCondition condition = new V1PodCondition();
condition.setLastTransitionTime(DateTime.now());
condition.setLastTransitionTime(OffsetDateTime.now());
status.setConditions(List.of(condition));
pod.setStatus(status);
V1ObjectMeta metadataPod = new V1ObjectMeta();
Expand Down