Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #24 from ThalesGroup/develop
Browse files Browse the repository at this point in the history
K8S module compatibility with API v1.23
  • Loading branch information
luborpetr authored May 18, 2022
2 parents a35dd33 + 68978d5 commit 8b0690d
Show file tree
Hide file tree
Showing 31 changed files with 195 additions and 192 deletions.
18 changes: 0 additions & 18 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ Chaos Engine is being actively developed, but we welcome public participation. P

## Demo Video

[![Chaos Engine Introduction](https://img.youtube.com/vi/IX-gNYBLyDM/0.jpg)](https://www.youtube.com/watch?v=IX-gNYBLyDM)
[![Chaos Engine Introduction](https://img.youtube.com/vi/IX-gNYBLyDM/0.jpg)](https://www.youtube.com/watch?v=IX-gNYBLyDM)

## Contact

You can [e-mail us], or find us on [Slack].

[Principles of Chaos]: http://principlesofchaos.org/

[documentation]: https://thalesgroup.github.io/chaos-engine/

[experiment modules documentation]: https://thalesgroup.github.io/chaos-engine/Experiment_Modules

[E-mail us]: mailto:dl_chaos_engine@gemalto.com
[Slack]: https://join.slack.com/t/thaleschaosengine/shared_invite/enQtODY1MDk1OTY4OTgyLTZjOGI5NzM1YTA2OWE5MjgzMWYxMzkwZjIwYTE3NjBlNDM4ZTkzNzc5YmMyMTU2Zjc5ODhlMTVkZDJhMmEzMzc

[Slack]: https://thalescploss.slack.com/
2 changes: 1 addition & 1 deletion chaosengine-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>chaosengine</artifactId>
<groupId>com.thales.chaos</groupId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Description: Fork Bomb experiment to consume CPU
# Dependencies: sleep

# This extra wait time is added in order to synchronize startup of parralel experiments
# This extra wait time is added in order to synchronize startup of parallel experiments
sleep 5

bomb() { bomb | bomb & }; bomb;
2 changes: 1 addition & 1 deletion chaosengine-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>chaosengine</artifactId>
<groupId>com.thales.chaos</groupId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion chaosengine-experiments/chaosengine-aws-ec2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>chaosengine-experiments</artifactId>
<groupId>com.thales.chaos</groupId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion chaosengine-experiments/chaosengine-aws-rds/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>chaosengine-experiments</artifactId>
<groupId>com.thales.chaos</groupId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions chaosengine-experiments/chaosengine-gcp-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<artifactId>chaosengine-experiments</artifactId>
<groupId>com.thales.chaos</groupId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>chaosengine-gcp-common</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>

<dependencies>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions chaosengine-experiments/chaosengine-gcp-compute/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>com.thales.chaos</groupId>
<artifactId>chaosengine-experiments</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>chaosengine-gcp-compute</artifactId>
Expand All @@ -33,7 +33,7 @@
<dependency>
<groupId>com.thales.chaos</groupId>
<artifactId>chaosengine-gcp-common</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
6 changes: 3 additions & 3 deletions chaosengine-experiments/chaosengine-gcp-memorystore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
<parent>
<artifactId>chaosengine-experiments</artifactId>
<groupId>com.thales.chaos</groupId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>chaosengine-gcp-memorystore</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>com.thales.chaos</groupId>
<artifactId>chaosengine-gcp-common</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
Expand Down
5 changes: 2 additions & 3 deletions chaosengine-experiments/chaosengine-kubernetes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>chaosengine-experiments</artifactId>
<groupId>com.thales.chaos</groupId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,12 +15,11 @@
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>10.0.0</version>
<version>15.0.1</version>
<scope>compile</scope>
</dependency>
<!-- Kubernetes Dependencies -->


</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 - 2020, Thales DIS CPL Canada, Inc
* Copyright (c) 2018 - 2022, Thales DIS CPL Canada, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,13 +37,15 @@
import io.kubernetes.client.openapi.apis.CoreApi;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -130,7 +132,7 @@ CoreV1Api getCoreV1Api () {

private V1PodList listAllPodsInNamespace (String namespace) {
try {
return getCoreV1Api().listNamespacedPod(namespace, "true", false, "", "", "", 0, "", 0, false);
return getCoreV1Api().listNamespacedPod(namespace, "true", false, "", "", "", 0, "", "", 0, false);
} catch (ApiException e) {
log.error("Cannot list pods in namespace {}: {} ", namespace, e.getMessage(), e);
return new V1PodList();
Expand Down Expand Up @@ -177,7 +179,7 @@ public PlatformLevel getPlatformLevel () {

private boolean canListPodsInNamespace (String namespace) {
try {
getCoreV1Api().listNamespacedPod(namespace, "true", false, "", "", "", 0, "", 0, false);
getCoreV1Api().listNamespacedPod(namespace, "true", false, "", "", "", 0, "", "", 0, false);
} catch (Exception e) {
log.error("Cannot list pods in namespace {}: {} ", namespace, e.getMessage(), e);
return false;
Expand Down Expand Up @@ -272,7 +274,8 @@ private boolean isContainerRestarted (KubernetesPodContainer container, String s
v("v1ContainerStateRunning", v1ContainerStateRunning)))
.map(V1ContainerStateRunning::getStartedAt)
.filter(Objects::nonNull)
.anyMatch(dateTime -> dateTime.isAfter(container.getExperimentStartTime().toEpochMilli()));
.anyMatch(dateTime -> dateTime.isAfter(OffsetDateTime.ofInstant(container.getExperimentStartTime(),
ZoneId.systemDefault())));
}

public ContainerHealth replicaSetRecovered (KubernetesPodContainer kubernetesPodContainer) {
Expand Down Expand Up @@ -357,7 +360,8 @@ public void recycleContainer (KubernetesPodContainer container) {
public boolean deletePod (KubernetesPodContainer instance) {
log.debug("Deleting pod {}", v(DATADOG_CONTAINER_KEY, instance));
try {
V1DeleteOptions deleteOptions = new V1DeleteOptionsBuilder().withGracePeriodSeconds(0L).build();
V1DeleteOptions deleteOptions = new V1DeleteOptions();
deleteOptions.setGracePeriodSeconds(0L);
getCoreV1Api().deleteNamespacedPod(instance.getPodName(),
instance.getNamespace(),
"false",
Expand Down
Loading

0 comments on commit 8b0690d

Please sign in to comment.