You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/08/11 09:00:24 UTC
[GitHub] [flink] Grypse commented on a diff in pull request #20516: [FLINK-27856][flink-kubernetes]solve the NPE error of no spec field in taskmanager pod template.
Grypse commented on code in PR #20516:
URL: https://github.com/apache/flink/pull/20516#discussion_r943256165
##########
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/utils/KubernetesUtils.java:
##########
@@ -419,12 +420,18 @@ public static FlinkPod loadPodFromTemplateFile(
final List<Container> otherContainers = new ArrayList<>();
Container mainContainer = null;
- for (Container container : pod.getInternalResource().getSpec().getContainers()) {
- if (mainContainerName.equals(container.getName())) {
- mainContainer = container;
- } else {
- otherContainers.add(container);
+ if (null != pod.getInternalResource().getSpec()) {
+ for (Container container : pod.getInternalResource().getSpec().getContainers()) {
+ if (mainContainerName.equals(container.getName())) {
+ mainContainer = container;
+ } else {
+ otherContainers.add(container);
+ }
}
+ pod.getInternalResource().getSpec().setContainers(otherContainers);
+ } else {
+ // Set empty spec for taskmanager pod template
Review Comment:
Right, it's also called by jobmanager pod template, but when no spec field on template, otherContainers is empty, and the PodSpec containers initial is an empty `List<Containers>` ,So there is no need to set an empty otherContainers to pod Spec.
PodSpec containers property:
```
@JsonProperty("containers")
private List<Container> containers = new ArrayList();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org