RestartPolicyRewriter implements ConfigurationProvisioner { @Override @Traced public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException { TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId); for (PodData podConfig : k8sEnv.getPodsData().values()) { final String podName = podConfig.getMetadata().getName(); final PodSpec podSpec = podConfig.getSpec(); rewriteRestartPolicy(podSpec, podName, k8sEnv); } }  @Override @Traced void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity);  }
@Test public void rewritesRestartPolicyWhenItsDifferentWithDefaultOne() throws Exception { Pod pod = newPod(TEST_POD_NAME, ALWAYS_RESTART_POLICY); PodData podData = new PodData(pod.getSpec(), pod.getMetadata()); when(k8sEnv.getPodsData()).thenReturn(singletonMap(TEST_POD_NAME, podData)); restartPolicyRewriter.provision(k8sEnv, runtimeIdentity); assertEquals(pod.getSpec().getRestartPolicy(), DEFAULT_RESTART_POLICY); verifyWarnings( new WarningImpl( RESTART_POLICY_SET_TO_NEVER_WARNING_CODE, format( "Restart policy '%s' for pod '%s' is rewritten with %s", ALWAYS_RESTART_POLICY, TEST_POD_NAME, DEFAULT_RESTART_POLICY))); }