Skip to content
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-20359 Added Owner Reference to Job Manager in native kubernetes setup #14281

Closed
wants to merge 1 commit into from
Closed

FLINK-20359 Added Owner Reference to Job Manager in native kubernetes setup #14281

wants to merge 1 commit into from

Conversation

blublinsky
Copy link

What is the purpose of the change

Flink implementation is often a part of the larger application. As a result a synchronized management - clean up of Flink resources, when a main application is deleted is important. In Kubernetes, a common approach for such clean up is usage of the owner's reference (https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/)

This PR allows adding owner reference support to Flink Job manager

Brief change log

(for example:)

  • Add configuration for owner reference
  • Updated Job Manager factory to process owner's reference
  • Updated Job Manager factory unit test

Verifying this change

(Please pick either of the following options)

This change added tests and can be verified as follows:

  • Extended Job Manager factory unit test to validate change

Does this pull request potentially affect one of the following parts:

  • The public API, i.e., is any changed class annotated with @Public(Evolving): yes

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? JavaDocs

@flinkbot
Copy link
Collaborator

flinkbot commented Dec 1, 2020

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 6a43ad7 (Fri May 28 07:13:02 UTC 2021)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Dec 1, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

@wangyang0918
Copy link
Contributor

wangyang0918 commented Dec 25, 2020

@blublinsky Generally, this PR could work. But I think we could make the implementation more gracefully.

  • We could introduce a new Kubernetes resource in Flink KubernetesOwnerReference, similar to KubernetesToleration.
  • KubernetesOwnerReference could be built from a map, which is configured via kubernetes.jobmanager.ownerref. It is a config option with map .mapType(), similar to kubernetes.jobmanager.tolerations.
  • KubernetesOwnerReference could be tested separately.

@blublinsky
Copy link
Author

We could, which creates a lot of code, which not really add clarity or simplicity. Right now it is just 9 lines of code. What is the point of creation additional class, that is doing exactly the same?

@wangyang0918
Copy link
Contributor

@blublinsky Thanks for your comments.

First, I believe parsing the KubernetesOwnerReference is not the ability of KubernetesJobManagerFactory. Moving the parsing logics out could make it more testable and reusable[1]. Second, we already have the mechanism to parse the structured string to a map. It will help a lot to convert them to a KubernetesOwnerReference. Benefit from the map, we do not require the users to always set all the fields(e.g. apiVersion, blockOwnerDeletion, controller, kind, name, uid) in specific order. It will be easier to use. Last, I do not think it will introduce two much codes except for the tests.

[1]. https://flink.apache.org/contributing/code-style-and-quality-common.html#design-for-testability

@blublinsky
Copy link
Author

blublinsky commented Dec 28, 2020

@wangyang0918, thanks for the comment
"parsing the KubernetesOwnerReference is not the ability of KubernetesJobManagerFactory". I agree with this and can move this to KubernetesJobManagerParameters. this will clean up the code.
"Second, we already have the mechanism to parse the structured string to a map" - but unlike environment, owner reference is not really a map - its a list of parameters - does it make sense to convert this to the map, or positional list is good enough?

@blublinsky
Copy link
Author

@wangyang0918
Redid the implementation based on your request. Had to move it #14512.

@xintongsong
Copy link
Contributor

Closing this PR, with #14591 as the replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants