Skip to content

Commit e3894e8

Browse files
committed
Fix NPE during create agent requests (#131) (#132)
1 parent 3143db6 commit e3894e8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/cd/go/contrib/elasticagent/KubernetesAgentInstances.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ public void refreshAll(PluginSettings properties) {
162162
}
163163
}
164164

165+
if (list == null) {
166+
LOG.info("Did not find any running kubernetes pods.");
167+
return;
168+
}
169+
165170
instances.clear();
166171
for (Pod pod : list.getItems()) {
167172
Map<String, String> podLabels = pod.getMetadata().getLabels();

src/main/java/cd/go/contrib/elasticagent/KubernetesPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ private void refreshInstancesForAllClusters(List<ClusterProfileProperties> listO
126126
private AgentInstances<KubernetesInstance> getAgentInstancesFor(ClusterProfileProperties clusterProfileProperties) throws Exception {
127127
KubernetesAgentInstances agentInstances = clusterSpecificAgentInstances.get(clusterProfileProperties.uuid());
128128

129-
//initalize agent instances if those are null
129+
//initialize agent instances if those are null
130130
if (agentInstances == null) {
131131
refreshInstancesForCluster(clusterProfileProperties);
132+
agentInstances = clusterSpecificAgentInstances.get(clusterProfileProperties.uuid());
132133
}
133134

134135
return agentInstances;

0 commit comments

Comments
 (0)