@Override public void connectionChanged( IConnection connection, String property, Object oldValue, Object newValue) { if (pod != null) { // we're done already return; } if (dcSelector == null) { if (deploymentConfig.equals(oldValue) && newValue instanceof IDeploymentConfig) { deploymentConfig = (IDeploymentConfig) newValue; dcSelector = deploymentConfig.getReplicaSelector(); } return; } // Wait for new pod once deployment is done if (newValue instanceof IPod) { IPod candidate = (IPod) newValue; String podName = candidate.getName(); if (!oldPods.contains(podName) && "Running".equals(candidate.getStatus()) && ResourceUtils.containsAll(dcSelector, candidate.getLabels())) { pod = candidate; } } }
public DeploymentConfigListenerJob(IDeploymentConfig deploymentConfig) { super("Waiting for OpenShift Pod redeployment"); this.deploymentConfig = deploymentConfig; oldPods = ResourceUtils.getPodsForDeploymentConfig(deploymentConfig) .stream() .map(p -> p.getName()) .collect(Collectors.toList()); }