Do not print error message if pod not found when getting task location (#13971)

Do not print error message if pod not found when getting task location
This commit is contained in:
Nicholas Lippis 2023-03-29 03:57:06 -04:00 committed by GitHub
parent 2219e68fa3
commit 488f1d8363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -50,6 +50,7 @@ import org.apache.druid.k8s.overlord.common.DruidK8sConstants;
import org.apache.druid.k8s.overlord.common.JobResponse;
import org.apache.druid.k8s.overlord.common.K8sTaskId;
import org.apache.druid.k8s.overlord.common.KubernetesPeonClient;
import org.apache.druid.k8s.overlord.common.KubernetesResourceNotFoundException;
import org.apache.druid.k8s.overlord.common.PeonPhase;
import org.apache.druid.k8s.overlord.common.TaskAdapter;
import org.apache.druid.tasklogs.TaskLogPusher;
@ -469,6 +470,10 @@ public class KubernetesTaskRunner implements TaskLogStreamer, TaskRunner
tlsEnabled
);
}
catch (KubernetesResourceNotFoundException e) {
log.debug(e, "Error getting task location for task %s", taskId);
return TaskLocation.unknown();
}
catch (Exception e) {
log.error(e, "Error getting task location for task %s", taskId);
return TaskLocation.unknown();

View File

@ -52,6 +52,7 @@ import org.apache.druid.k8s.overlord.common.JobResponse;
import org.apache.druid.k8s.overlord.common.K8sTaskAdapter;
import org.apache.druid.k8s.overlord.common.K8sTaskId;
import org.apache.druid.k8s.overlord.common.KubernetesPeonClient;
import org.apache.druid.k8s.overlord.common.KubernetesResourceNotFoundException;
import org.apache.druid.k8s.overlord.common.PeonPhase;
import org.apache.druid.server.DruidNode;
import org.apache.druid.server.log.StartupLoggingConfig;
@ -427,6 +428,20 @@ public class KubernetesTaskRunnerTest
assertEquals(TaskLocation.create("tweak", DruidK8sConstants.PORT, DruidK8sConstants.TLS_PORT, false), realLocation);
}
@Test
public void testWorkItemGetLocation_withKubernetesResourceNotFoundException_returnsUnknownLocation()
{
KubernetesPeonClient client = mock(KubernetesPeonClient.class);
when(client.getMainJobPod(any())).thenThrow(KubernetesResourceNotFoundException.class);
Task task = mock(Task.class);
when(task.getId()).thenReturn("id");
KubernetesTaskRunner.K8sWorkItem k8sWorkItem = new KubernetesTaskRunner.K8sWorkItem(client, task, null);
TaskLocation location = k8sWorkItem.getLocation();
assertEquals(TaskLocation.unknown(), location);
}
private Task makeTask()
{
return new TestableNoopTask(