@Test(dataProvider = "logTimeoutProvider") public void testCheckLogTimeout(Long lastMessageTimestamp, Long timeout, boolean expectedResult) { doReturn(mockClients).when(mockPodPushClient).getKubernetesHttpClients(); doReturn(mockPodPushClient).when(mockPushPodClientFactory).getClient(any()); podFollower = new PodFollowerImpl(kubeConfig, podConfig, executionConfig, mockPushPodClientFactory); when(mockClients.getRequestClient().getLastLogLineTimestamp(any(), any())).thenReturn(lastMessageTimestamp); Assert.assertEquals(podFollower.checkLogTimeout(timeout, NAMESPACE, POD_NAME), expectedResult); }
protected boolean checkLogTimeout(Long timeout, String namespace, String podName) { if(timeout == null) return false; Long tailTimestamp = podPushClient.getKubernetesHttpClients().getRequestClient().getLastLogLineTimestamp(namespace, podName); Long now = Instant.now().toEpochMilli(); if(tailTimestamp != null) { if (timeout < now - tailTimestamp) { logger.error("[{}]Pod has timed out. tailTimestamp/Now: {}/{}", podName, tailTimestamp, now); return true; } else { logger.error("[{}]No log activity on pod detected. Will timeout after approximately: {}ms", podName, timeout - (now - tailTimestamp)); } } return false; }
PodFollowerImpl implements PodFollower<C> { protected boolean checkLogTimeout(Long timeout, String namespace, String podName) { if(timeout == null) return false; Long tailTimestamp = podPushClient.getKubernetesHttpClients().getRequestClient().getLastLogLineTimestamp(namespace, podName); Long now = Instant.now().toEpochMilli(); if(tailTimestamp != null) { if (timeout < now - tailTimestamp) { logger.error("[{}]Pod has timed out. tailTimestamp/Now: {}/{}", podName, tailTimestamp, now); return true; } else { logger.error("[{}]No log activity on pod detected. Will timeout after approximately: {}ms", podName, timeout - (now - tailTimestamp)); } } return false; } }
PodFollowerImpl implements PodFollower<C> { protected boolean checkLogTimeout(Long timeout, String namespace, String podName) { if(timeout == null) return false; Long tailTimestamp = podPushClient.getKubernetesHttpClients().getRequestClient().getLastLogLineTimestamp(namespace, podName); Long now = Instant.now().toEpochMilli(); if(tailTimestamp != null) { if (timeout < now - tailTimestamp) { logger.error("[{}]Pod has timed out. tailTimestamp/Now: {}/{}", podName, tailTimestamp, now); return true; } else { logger.error("[{}]No log activity on pod detected. Will timeout after approximately: {}ms", podName, timeout - (now - tailTimestamp)); } } return false; } PodFollowerImpl(KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig);  PodFollowerImpl(KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig, PodPushClientFactoryImpl podPushClientFactory); }
PodFollowerImpl implements PodFollower<C> { protected boolean checkLogTimeout(Long timeout, String namespace, String podName) { if(timeout == null) return false; Long tailTimestamp = podPushClient.getKubernetesHttpClients().getRequestClient().getLastLogLineTimestamp(namespace, podName); Long now = Instant.now().toEpochMilli(); if(tailTimestamp != null) { if (timeout < now - tailTimestamp) { logger.error("[{}]Pod has timed out. tailTimestamp/Now: {}/{}", podName, tailTimestamp, now); return true; } else { logger.error("[{}]No log activity on pod detected. Will timeout after approximately: {}ms", podName, timeout - (now - tailTimestamp)); } } return false; } PodFollowerImpl(KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig);  PodFollowerImpl(KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig, PodPushClientFactoryImpl podPushClientFactory); PodFollowerImpl addEventListener(PodEventListener listener); @Override FinalPodPhaseInfo startAndFollowPod(LogLineObserver logLineObserver); @Override LogLineObserver getDefaultLogLineObserver(ExecutionConfig imageExecutionDetails); PodPushClient getPodPushClient(); Map<String, String> getPodAnnotations(); }
PodFollowerImpl implements PodFollower<C> { protected boolean checkLogTimeout(Long timeout, String namespace, String podName) { if(timeout == null) return false; Long tailTimestamp = podPushClient.getKubernetesHttpClients().getRequestClient().getLastLogLineTimestamp(namespace, podName); Long now = Instant.now().toEpochMilli(); if(tailTimestamp != null) { if (timeout < now - tailTimestamp) { logger.error("[{}]Pod has timed out. tailTimestamp/Now: {}/{}", podName, tailTimestamp, now); return true; } else { logger.error("[{}]No log activity on pod detected. Will timeout after approximately: {}ms", podName, timeout - (now - tailTimestamp)); } } return false; } PodFollowerImpl(KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig);  PodFollowerImpl(KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig, PodPushClientFactoryImpl podPushClientFactory); PodFollowerImpl addEventListener(PodEventListener listener); @Override FinalPodPhaseInfo startAndFollowPod(LogLineObserver logLineObserver); @Override LogLineObserver getDefaultLogLineObserver(ExecutionConfig imageExecutionDetails); PodPushClient getPodPushClient(); Map<String, String> getPodAnnotations(); static final int LATCH_TIMEOUT; static final int MAX_INACTIVITY_BEFORE_LOG_RESET; }