-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-28829][k8s] Support prepreparing K8S resources before JM creation #20498
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,10 +30,15 @@ public class KubernetesJobManagerSpecification { | |||||
|
||||||
private List<HasMetadata> accompanyingResources; | ||||||
|
||||||
private List<HasMetadata> prePreparedResources; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, how about just follow the style of |
||||||
|
||||||
public KubernetesJobManagerSpecification( | ||||||
Deployment deployment, List<HasMetadata> accompanyingResources) { | ||||||
Deployment deployment, | ||||||
List<HasMetadata> accompanyingResources, | ||||||
List<HasMetadata> prePreparedResources) { | ||||||
this.deployment = deployment; | ||||||
this.accompanyingResources = accompanyingResources; | ||||||
this.prePreparedResources = prePreparedResources; | ||||||
} | ||||||
|
||||||
public Deployment getDeployment() { | ||||||
|
@@ -43,4 +48,8 @@ public Deployment getDeployment() { | |||||
public List<HasMetadata> getAccompanyingResources() { | ||||||
return accompanyingResources; | ||||||
} | ||||||
|
||||||
public List<HasMetadata> getPrePreparedResources() { | ||||||
return prePreparedResources; | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -630,4 +630,37 @@ private KubernetesConfigMap buildTestingConfigMap() { | |
.withData(data) | ||
.build()); | ||
} | ||
|
||
@Test | ||
void testMockPrePreparedResources() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
// regenerate a test JM spec | ||
Deployment testDeployment = kubernetesJobManagerSpecification.getDeployment(); | ||
List<HasMetadata> testAccompanyingResources = | ||
kubernetesJobManagerSpecification.getAccompanyingResources(); | ||
List<HasMetadata> mockPrePreparedResources = new ArrayList<>(); | ||
for (int i = 0; i < 3; i++) { | ||
Pod mockPod = | ||
new PodBuilder() | ||
.editOrNewMetadata() | ||
.withName("mock-pod-preprepared-resource-" + i) | ||
.endMetadata() | ||
.editOrNewSpec() | ||
.endSpec() | ||
.build(); | ||
mockPrePreparedResources.add(mockPod); | ||
} | ||
KubernetesJobManagerSpecification testKubernetesJobManagerSpecification = | ||
new KubernetesJobManagerSpecification( | ||
testDeployment, testAccompanyingResources, mockPrePreparedResources); | ||
flinkKubeClient.createJobManagerComponent(testKubernetesJobManagerSpecification); | ||
|
||
// check the preprepared resources had been created. | ||
final List<Pod> resultPods = kubeClient.pods().inNamespace(NAMESPACE).list().getItems(); | ||
assertThat(resultPods).hasSize(3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be at least 4 pods ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is UT, it won't create any real Pods, just a k8s models objects. Actually, JM will be created by K8S deployment, In the real env, that's true it should be 4 pods. |
||
|
||
final List<Deployment> resultedDeployments = | ||
kubeClient.apps().deployments().inNamespace(NAMESPACE).list().getItems(); | ||
// check resource owner reference had been refreshed. | ||
testOwnerReferenceSetting(resultedDeployments.get(0), resultPods); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have resources leak here if the flink client crashed exactly after the pre-prepared resources created.