forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add annotation for pod template (apache#16772)
* Add annotation for pod template * pr comments * add test cases * add tests
- Loading branch information
1 parent
11bb409
commit a64e9a1
Showing
15 changed files
with
291 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...tensions/src/main/java/org/apache/druid/k8s/overlord/taskadapter/PodTemplateWithName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.k8s.overlord.taskadapter; | ||
|
||
import io.fabric8.kubernetes.api.model.PodTemplate; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Objects; | ||
|
||
public class PodTemplateWithName | ||
{ | ||
private final String name; | ||
private final PodTemplate podTemplate; | ||
|
||
public PodTemplateWithName(String name, PodTemplate podTemplate) | ||
{ | ||
this.name = name; | ||
this.podTemplate = podTemplate; | ||
} | ||
|
||
@Nonnull | ||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
@Nonnull | ||
public PodTemplate getPodTemplate() | ||
{ | ||
return podTemplate; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
PodTemplateWithName that = (PodTemplateWithName) o; | ||
return Objects.equals(name, that.name) && | ||
Objects.equals(podTemplate, that.podTemplate); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash(name, podTemplate); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return "PodTemplateWithName{" + | ||
"name='" + name + '\'' + | ||
", podTemplate=" + podTemplate + | ||
'}'; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...xtensions/src/test/java/org/apache/druid/k8s/overlord/common/PodTemplateWithNameTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.k8s.overlord.common; | ||
|
||
import io.fabric8.kubernetes.api.model.PodTemplate; | ||
import io.fabric8.kubernetes.api.model.PodTemplateBuilder; | ||
import org.apache.druid.k8s.overlord.taskadapter.PodTemplateWithName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
public class PodTemplateWithNameTest | ||
{ | ||
@Test | ||
void testEqualityToMakeCoverageHappy() | ||
{ | ||
PodTemplateWithName podTemplateWithName = new PodTemplateWithName( | ||
"name", | ||
new PodTemplateBuilder().build() | ||
); | ||
PodTemplateWithName podTemplateWithName2 = podTemplateWithName; | ||
|
||
assertEquals(podTemplateWithName, podTemplateWithName2); | ||
assertNotEquals(podTemplateWithName, null); | ||
assertNotEquals(podTemplateWithName, "string"); | ||
assertEquals(podTemplateWithName.hashCode(), podTemplateWithName2.hashCode()); | ||
} | ||
|
||
@Test | ||
void testGettersToMakeCoverageHappy() | ||
{ | ||
String name = "name"; | ||
PodTemplate podTemplate = new PodTemplateBuilder().build(); | ||
PodTemplateWithName podTemplateWithName = new PodTemplateWithName( | ||
name, | ||
podTemplate | ||
); | ||
|
||
assertEquals(name, podTemplateWithName.getName()); | ||
assertEquals(podTemplate, podTemplateWithName.getPodTemplate()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...nsions-contrib/kubernetes-overlord-extensions/src/test/resources/expectedNoopJobBase.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: "id-3e70afe5cd823dfc7dd308eea616426b" | ||
labels: | ||
druid.k8s.peons: "true" | ||
druid.task.id: "id" | ||
druid.task.type: "noop" | ||
druid.task.group.id: "id" | ||
druid.task.datasource: "datasource" | ||
|
||
annotations: | ||
task.id: "id" | ||
task.type: "noop" | ||
task.group.id: "id" | ||
task.datasource: "datasource" | ||
task.jobTemplate: base | ||
spec: | ||
activeDeadlineSeconds: 14400 | ||
backoffLimit: 0 | ||
ttlSecondsAfterFinished: 172800 | ||
template: | ||
metadata: | ||
labels: | ||
druid.k8s.peons: "true" | ||
druid.task.id: "id" | ||
druid.task.type: "noop" | ||
druid.task.group.id: "id" | ||
druid.task.datasource: "datasource" | ||
annotations: | ||
task: "H4sIAAAAAAAAAD2MvQ4CIRCE32VqijsTG1qLi7W+wArEbHICrmC8EN7dJf40k/lmJtNQthxgEVPKMGCvXsXgKqnm4x89FTqlKm6MBzw+YCA1nvmm8W4/TQYuxRJeBbZ17cJ3ZhvoSbzShVcu2zLOf9cS7pUl+ANlclrCzr2/AQUK0FqZAAAA" | ||
tls.enabled: "false" | ||
task.id: "id" | ||
task.type: "noop" | ||
task.group.id: "id" | ||
task.datasource: "datasource" | ||
task.jobTemplate: base | ||
spec: | ||
containers: | ||
- command: | ||
- sleep | ||
- "3600" | ||
env: | ||
- name: "TASK_DIR" | ||
value: "/tmp" | ||
- name: "TASK_ID" | ||
value: "id" | ||
- name: "LOAD_BROADCAST_SEGMENTS" | ||
value: "false" | ||
- name: "TASK_JSON" | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: "metadata.annotations['task']" | ||
image: one | ||
name: primary |
Oops, something went wrong.