@Test public void testRetrieveOperationProgressError() { doThrow(new RuntimeException()).when(mockPodFollower).getPodAnnotations(); Assert.assertNull(executor.retrieveOperationProgress()); }
@Override public OperationProgress retrieveOperationProgress() { try { logger.debug("[{}] Getting Pod annotations", executionConfig.getName()); Map<String,String> podAnnotations = follower.getPodAnnotations(); String progressJson = podAnnotations.getOrDefault(KubernetesReporter.REPORT_PROGRESS_ANNOTATION, null); String resultPayload = podAnnotations.get(KubernetesReporter.REPORT_PAYLOAD_ANNOTATION); logger.debug("progressJson [" + progressJson + "], resultPayload [" + resultPayload + ']'); if(progressJson == null) { return defaultFailedOperationProgress; } logger.debug("[{}] Getting operationProgress", executionConfig.getName()); OperationProgress operationProgress = jsonHelper.getObjectFromString(progressJson, OperationProgress.class); logger.debug("[{}] OperationProgress processingState={} processingStateMessage={} percentComplete={}", executionConfig.getName(), operationProgress.getProcessingState(), operationProgress.getProcessingStateMessage(), operationProgress.getPercentComplete()); operationProgress.setOperation(operation.getName()); operationProgress.setResultPayload(resultPayload); if(operationProgress.getProcessingState() == ProcessingState.COMPLETE) isCompleteOperationProgressRetrieved.set(true); return operationProgress; } catch(JsonHelperException je) { logger.error("[{}] {} - Unable to convert progress string to OperationProgress", executionConfig.getName(), operation.getName()); } catch(Exception e) { logger.error("[{}] {} - Unable to pull pod annotation: {}", executionConfig.getName(), operation.getName(), KubernetesReporter.REPORT_PROGRESS_ANNOTATION); } return null; }
KubernetesOperationExecutor extends BaseOperationExecutor { @Override public OperationProgress retrieveOperationProgress() { try { logger.debug("[{}] Getting Pod annotations", executionConfig.getName()); Map<String,String> podAnnotations = follower.getPodAnnotations(); String progressJson = podAnnotations.getOrDefault(KubernetesReporter.REPORT_PROGRESS_ANNOTATION, null); String resultPayload = podAnnotations.get(KubernetesReporter.REPORT_PAYLOAD_ANNOTATION); logger.debug("progressJson [" + progressJson + "], resultPayload [" + resultPayload + ']'); if(progressJson == null) { return defaultFailedOperationProgress; } logger.debug("[{}] Getting operationProgress", executionConfig.getName()); OperationProgress operationProgress = jsonHelper.getObjectFromString(progressJson, OperationProgress.class); logger.debug("[{}] OperationProgress processingState={} processingStateMessage={} percentComplete={}", executionConfig.getName(), operationProgress.getProcessingState(), operationProgress.getProcessingStateMessage(), operationProgress.getPercentComplete()); operationProgress.setOperation(operation.getName()); operationProgress.setResultPayload(resultPayload); if(operationProgress.getProcessingState() == ProcessingState.COMPLETE) isCompleteOperationProgressRetrieved.set(true); return operationProgress; } catch(JsonHelperException je) { logger.error("[{}] {} - Unable to convert progress string to OperationProgress", executionConfig.getName(), operation.getName()); } catch(Exception e) { logger.error("[{}] {} - Unable to pull pod annotation: {}", executionConfig.getName(), operation.getName(), KubernetesReporter.REPORT_PROGRESS_ANNOTATION); } return null; } }
KubernetesOperationExecutor extends BaseOperationExecutor { @Override public OperationProgress retrieveOperationProgress() { try { logger.debug("[{}] Getting Pod annotations", executionConfig.getName()); Map<String,String> podAnnotations = follower.getPodAnnotations(); String progressJson = podAnnotations.getOrDefault(KubernetesReporter.REPORT_PROGRESS_ANNOTATION, null); String resultPayload = podAnnotations.get(KubernetesReporter.REPORT_PAYLOAD_ANNOTATION); logger.debug("progressJson [" + progressJson + "], resultPayload [" + resultPayload + ']'); if(progressJson == null) { return defaultFailedOperationProgress; } logger.debug("[{}] Getting operationProgress", executionConfig.getName()); OperationProgress operationProgress = jsonHelper.getObjectFromString(progressJson, OperationProgress.class); logger.debug("[{}] OperationProgress processingState={} processingStateMessage={} percentComplete={}", executionConfig.getName(), operationProgress.getProcessingState(), operationProgress.getProcessingStateMessage(), operationProgress.getPercentComplete()); operationProgress.setOperation(operation.getName()); operationProgress.setResultPayload(resultPayload); if(operationProgress.getProcessingState() == ProcessingState.COMPLETE) isCompleteOperationProgressRetrieved.set(true); return operationProgress; } catch(JsonHelperException je) { logger.error("[{}] {} - Unable to convert progress string to OperationProgress", executionConfig.getName(), operation.getName()); } catch(Exception e) { logger.error("[{}] {} - Unable to pull pod annotation: {}", executionConfig.getName(), operation.getName(), KubernetesReporter.REPORT_PROGRESS_ANNOTATION); } return null; } KubernetesOperationExecutor(PodFollower<PodPushClient> follower, Operation operation, KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig, ExecutorContext executorContext); }
KubernetesOperationExecutor extends BaseOperationExecutor { @Override public OperationProgress retrieveOperationProgress() { try { logger.debug("[{}] Getting Pod annotations", executionConfig.getName()); Map<String,String> podAnnotations = follower.getPodAnnotations(); String progressJson = podAnnotations.getOrDefault(KubernetesReporter.REPORT_PROGRESS_ANNOTATION, null); String resultPayload = podAnnotations.get(KubernetesReporter.REPORT_PAYLOAD_ANNOTATION); logger.debug("progressJson [" + progressJson + "], resultPayload [" + resultPayload + ']'); if(progressJson == null) { return defaultFailedOperationProgress; } logger.debug("[{}] Getting operationProgress", executionConfig.getName()); OperationProgress operationProgress = jsonHelper.getObjectFromString(progressJson, OperationProgress.class); logger.debug("[{}] OperationProgress processingState={} processingStateMessage={} percentComplete={}", executionConfig.getName(), operationProgress.getProcessingState(), operationProgress.getProcessingStateMessage(), operationProgress.getPercentComplete()); operationProgress.setOperation(operation.getName()); operationProgress.setResultPayload(resultPayload); if(operationProgress.getProcessingState() == ProcessingState.COMPLETE) isCompleteOperationProgressRetrieved.set(true); return operationProgress; } catch(JsonHelperException je) { logger.error("[{}] {} - Unable to convert progress string to OperationProgress", executionConfig.getName(), operation.getName()); } catch(Exception e) { logger.error("[{}] {} - Unable to pull pod annotation: {}", executionConfig.getName(), operation.getName(), KubernetesReporter.REPORT_PROGRESS_ANNOTATION); } return null; } KubernetesOperationExecutor(PodFollower<PodPushClient> follower, Operation operation, KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig, ExecutorContext executorContext); void setFollower(PodFollower<PodPushClient> follower); void setKubeConfig(KubeConfig kubeConfig); void setPodConfig(PodConfig podConfig); void setExecutionConfig(ExecutionConfig executionConfig); @Override OperationProgress retrieveOperationProgress(); @Override String execute(String payload); KubeConfig getKubeConfig(); PodConfig getPodConfig(); ExecutionConfig getExecutionConfig(); }
KubernetesOperationExecutor extends BaseOperationExecutor { @Override public OperationProgress retrieveOperationProgress() { try { logger.debug("[{}] Getting Pod annotations", executionConfig.getName()); Map<String,String> podAnnotations = follower.getPodAnnotations(); String progressJson = podAnnotations.getOrDefault(KubernetesReporter.REPORT_PROGRESS_ANNOTATION, null); String resultPayload = podAnnotations.get(KubernetesReporter.REPORT_PAYLOAD_ANNOTATION); logger.debug("progressJson [" + progressJson + "], resultPayload [" + resultPayload + ']'); if(progressJson == null) { return defaultFailedOperationProgress; } logger.debug("[{}] Getting operationProgress", executionConfig.getName()); OperationProgress operationProgress = jsonHelper.getObjectFromString(progressJson, OperationProgress.class); logger.debug("[{}] OperationProgress processingState={} processingStateMessage={} percentComplete={}", executionConfig.getName(), operationProgress.getProcessingState(), operationProgress.getProcessingStateMessage(), operationProgress.getPercentComplete()); operationProgress.setOperation(operation.getName()); operationProgress.setResultPayload(resultPayload); if(operationProgress.getProcessingState() == ProcessingState.COMPLETE) isCompleteOperationProgressRetrieved.set(true); return operationProgress; } catch(JsonHelperException je) { logger.error("[{}] {} - Unable to convert progress string to OperationProgress", executionConfig.getName(), operation.getName()); } catch(Exception e) { logger.error("[{}] {} - Unable to pull pod annotation: {}", executionConfig.getName(), operation.getName(), KubernetesReporter.REPORT_PROGRESS_ANNOTATION); } return null; } KubernetesOperationExecutor(PodFollower<PodPushClient> follower, Operation operation, KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig, ExecutorContext executorContext); void setFollower(PodFollower<PodPushClient> follower); void setKubeConfig(KubeConfig kubeConfig); void setPodConfig(PodConfig podConfig); void setExecutionConfig(ExecutionConfig executionConfig); @Override OperationProgress retrieveOperationProgress(); @Override String execute(String payload); KubeConfig getKubeConfig(); PodConfig getPodConfig(); ExecutionConfig getExecutionConfig(); static final int MAX_POD_LOG_LINES; static final int DEFAULT_FAIL_DIAGNOSTIC_LINE_LIMIT; }