Skip to content
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 @@ -311,6 +311,7 @@ protected Container setupMainContainer(
// remove probes
mainContainer.setReadinessProbe(null);
mainContainer.setLivenessProbe(null);
mainContainer.setStartupProbe(null);

setupPorts(mainContainer);
addEnvironmentVariables(mainContainer, context, taskContents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,56 @@ void testEphemeralStorageIsRespected() throws IOException
Assertions.assertEquals(expected, actual);
}

@Test
void testProbesRemoved() throws IOException
{
TestKubernetesClient testClient = new TestKubernetesClient(client);
Pod pod = K8sTestUtils.fileToResource("probesPodSpec.yaml", Pod.class);
KubernetesTaskRunnerConfig config = KubernetesTaskRunnerConfig.builder()
.withNamespace("test")
.build();

SingleContainerTaskAdapter adapter = new SingleContainerTaskAdapter(
testClient,
config,
taskConfig,
startupLoggingConfig,
node,
jsonMapper,
taskLogs
);
NoopTask task = K8sTestUtils.createTask("id", 1);
Job actual = adapter.createJobFromPodSpec(
pod.getSpec(),
task,
new PeonCommandContext(
Collections.singletonList("foo && bar"),
new ArrayList<>(),
new File("/tmp"),
config.getCpuCoreInMicro()
)
);
Job expected = K8sTestUtils.fileToResource("expectedProbesRemovedOutput.yaml", Job.class);
// something is up with jdk 17, where if you compress with jdk < 17 and try and decompress you get different results,
// this would never happen in real life, but for the jdk 17 tests this is a problem
// could be related to: https://bugs.openjdk.org/browse/JDK-8081450
actual.getSpec()
.getTemplate()
.getSpec()
.getContainers()
.get(0)
.getEnv()
.removeIf(x -> x.getName().equals("TASK_JSON"));
expected.getSpec()
.getTemplate()
.getSpec()
.getContainers()
.get(0)
.getEnv()
.removeIf(x -> x.getName().equals("TASK_JSON"));
Assertions.assertEquals(expected, actual);
}

@Test
void testCPUResourceIsRespected() throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: "batch/v1"
kind: "Job"
metadata:
annotations:
task.id: "id"
tls.enabled: "false"
labels:
druid.k8s.peons: "true"
name: "id-3e70afe5cd823dfc7dd308eea616426b"
spec:
activeDeadlineSeconds: 14400
backoffLimit: 0
template:
metadata:
annotations:
task.id: "id"
tls.enabled: "false"
labels:
druid.k8s.peons: "true"
spec:
containers:
- args:
- "foo && bar"
command:
- "sh"
- "-c"
env:
- name: "druid_monitoring_monitors"
value: "[\"org.apache.druid.java.util.metrics.JvmMonitor\", \"org.apache.druid.server.metrics.TaskCountStatsMonitor\"\
]"
- name: "TASK_DIR"
value: "/tmp"
- name: "TASK_JSON"
value: "H4sIAAAAAAAAAEVOOw7CMAy9i+cOBYmlK0KItWVhNI0BSyEOToKoqt4doxZYLPv9/EbIQyRoIIhEqICd7TYquKqUePidDjN2UrSfxYEM0xKOfDdgvalr86aW0A0z9L9bSsVnc512nZkurHSTZJJQvK+gl5DpZfwIUVmU8wDNarJ0Ssu/EfCJ7PHM3tj9p9i3ltKjWKDbYsR+sU5vP86oMNUAAAA="
- name: "JAVA_OPTS"
value: ""
- name: "druid_host"
valueFrom:
fieldRef:
fieldPath: "status.podIP"
- name: "HOSTNAME"
valueFrom:
fieldRef:
fieldPath: "metadata.name"
image: "one"
name: "main"
ports:
- containerPort: 8091
name: "druid-tls-port"
protocol: "TCP"
- containerPort: 8100
name: "druid-port"
protocol: "TCP"
resources:
limits:
cpu: "1000m"
memory: "2400000000"
requests:
cpu: "1000m"
memory: "2400000000"
hostname: "id-3e70afe5cd823dfc7dd308eea616426b"
restartPolicy: "Never"
ttlSecondsAfterFinished: 172800
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
containers:
- command:
- sleep
- "3600"
image: one
name: primary
startupProbe:
httpGet:
port: 8100
path: /status/health
livenessProbe:
httpGet:
port: 8100
path: /status/health
readinessProbe:
httpGet:
port: 8100
path: /status/health
env:
- name: "druid_monitoring_monitors"
value: '["org.apache.druid.java.util.metrics.JvmMonitor", "org.apache.druid.server.metrics.TaskCountStatsMonitor"]'