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 #14512

Closed
wants to merge 5 commits into from
Closed

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

wants to merge 5 commits 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

  • Add configuration for owner reference
  • Add Owner manager resource
  • Add Owner manager support to KubernetesJobManagerParameters
  • Updated Job Manager factory to process owner's reference
  • Updated Job Manager factory unit test

Verifying this change

This change added tests and can be verified as follows:

Extended InitJobManagerDecoratorTest to validate owner reference support

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

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no) yes
  • The serializers: (yes / no / don't know) no
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know) no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / no / don't know) yes
  • The S3 file system connector: (yes / no / don't know)no

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented) java doc

@flinkbot
Copy link
Collaborator

flinkbot commented Dec 29, 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 655b299 (Fri May 28 07:08:20 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 29, 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

Copy link
Contributor

@wangyang0918 wangyang0918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blublinsky I really appreciate that you update the PR based on the discussion in the previous one. I left some comments and it will be great if you could integrate them before merging.

*/
public class KubernetesOwnerReference extends KubernetesResource<OwnerReference> {

static final String API_VERSION = "apiversion";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variables could be private.

Copy link
Author

@blublinsky blublinsky Dec 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had them private initially, but decided to make them public, so that they can be used for programmatic implementation.
When I am writing code that creates owner reference, its handy to have them available.
WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, you mean to refer these variables in your own java program, not Flink source codes. Since KubernetesOwnerReference is an internal class, which should not be directly used out of Flink. So I am afraid it does not make sense to set these variables public.

public static KubernetesOwnerReference fromMap(Map<String, String> stringMap) {
final OwnerReferenceBuilder ownerReferenceBuilder = new OwnerReferenceBuilder();
stringMap.forEach((k, v) -> {
switch (k.toLowerCase()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question here. Do we have to set all the fields to build an OwnerReference?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the formal definition https://github.com/kubernetes/apimachinery/blob/21de1bffe600f61f4873ae774a60f7a7d37ac9bf/pkg/apis/meta/v1/types.go#L273-L275. According to it controller and BlockOwnerDeletion are optional. But for practical use, it is my understanding, that everything is required

@wangyang0918
Copy link
Contributor

This PR also needs to rebase the latest master branch to resolve conflicts.

Boris Lublinsky and others added 4 commits December 29, 2020 10:13
…eclient/decorators/InitJobManagerDecoratorTest.java

Co-authored-by: Yang Wang <danrtsey.wy@gmail.com>
# Conflicts:
#	flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitJobManagerDecoratorTest.java
@wangyang0918
Copy link
Contributor

@blublinsky It seems that you have introduced too many unrelated changes in this PR. Could you rebase the latest master branch? I believe the conflicts is caused by huge refactor commit.

@blublinsky
Copy link
Author

Rebased this PR, it is now #14529

@wangyang0918
Copy link
Contributor

cc @blublinsky Actually you do not have to open a new PR every time after addressing the comments.

@rmetzger
Copy link
Contributor

rmetzger commented Jan 6, 2021

The benefit of sticking to the same PR (by (force) pushing changes is that we keep track of the history of changes).

I'm closing the other PR. Please push your changes here!

@blublinsky
Copy link
Author

Sorry guys, how do I force the same PR. Unfortunately not a GIT guru

@wangyang0918
Copy link
Contributor

@blublinsky First, address the comments and update the source codes locally. Then refine the commit message via git commit --amend or git rebase -i master. Last, force push the local branch(e.g. ownerreference) to remote via git push blublinsky ownerreference. Please remember that blublinsky:ownerreference is the branch which you create the PR with.

@blublinsky
Copy link
Author

Oh, my problem is that I am working from the local fork, that I updated to get the latest version. So my previous fork is gone, thats why it created a new commit. So now from a new fork I can't push to the same PR, because it recognizes that my fork has changed

@wangyang0918
Copy link
Contributor

@blublinsky Do you mean you have delete the fork repository manually? I just want to share how I develop the PRs.

  • Fork the flink project
  • Add the forked remote repository to local, git remote add myfork https://github.com/xxxx/flink.git. Then you could have at least following two remote repositories.
myfork	https://github.com/xxxx/flink.git (fetch)
myfork	https://github.com/xxxx/flink.git (push)
upstream	https://github.com/apache/flink.git (fetch)
upstream	https://github.com/apache/flink.git (push)
  • Checkout a new branch(e.g. ownerreference) from master(upstream repository)
  • Develop the PR and push to myfork. git push myfork ownerreference
  • Create the PR in the github
  • Address the comments, update the PR and force push. git push -f myfork ownerreference
  • The PR should be updated.

@blublinsky
Copy link
Author

THanks @wangyang0918,
This is exactly what I have done.
And here https://github.com/blublinsky/flink/tree/ownerreference is my branch,
But when I am trying to create a pr - https://github.com/apache/flink/compare/master...blublinsky:ownerreference?expand=1,
it tries to create a new PR, this is what I did last time. I do not see a way to force it to the existing PR

@wangyang0918
Copy link
Contributor

I think maybe you have delete the old forked repository of this PR. Currently it is on an unknown repository. I am not sure whether you could fix it[1]. If not, let's move the discussion to another PR.

[1]. https://stackoverflow.com/questions/36071272/fix-unknown-repository-of-an-opened-pr-after-deleted-the-fork

@wangyang0918
Copy link
Contributor

Sorry for that I missed the new PR for the replacement #14591.

Let's move the review and discussion there. And then this PR could be closed.

@rmetzger rmetzger closed this Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants