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-21255] Add WaitingForResources state for DeclarativeScheduler #14852

Closed

Conversation

rmetzger
Copy link
Contributor

@rmetzger rmetzger commented Feb 3, 2021

What is the purpose of the change

Declarative Scheduler consists of a number of internal states. This PR is adding the first state of the new scheduler to Flink.

Note that this change is currently not usable as-is, as the other parts of declarative scheduler are not merged yet (See for the prototype this PR is based on: https://github.com/tillrohrmann/flink/tree/declarative-scheduler)

Verifying this change

  • The change is adding unit tests.
  • Note that integration tests for the declarative scheduler will cover additional functionality.

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)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

Will be handled in a separate PR.

@rmetzger rmetzger force-pushed the FLINK-21255-waiting-for-resources branch from d4d6eae to 93b24f6 Compare February 3, 2021 15:11
@rmetzger
Copy link
Contributor Author

rmetzger commented Feb 3, 2021

@tillrohrmann I split this change into two commits to attribute the scheduler changes to you. Please let me know if you disagree with this.

@flinkbot
Copy link
Collaborator

flinkbot commented Feb 3, 2021

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 b8452a6 (Fri May 28 08:17:51 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 Feb 3, 2021

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

@rmetzger rmetzger force-pushed the FLINK-21255-waiting-for-resources branch from 93b24f6 to d319b86 Compare February 4, 2021 09:55
*
* @param newState newState is the state into which the scheduler transitions
*/
default void onLeave(State newState) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we no longer need this?

* State abstraction of the {@link DeclarativeScheduler}. This interface contains all methods every
* state implementation must support.
*/
interface State {
Copy link
Contributor

Choose a reason for hiding this comment

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

note: Had shared classes such as this been added first in a separate PR we could review all states in isolation without having to be based on one another.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good feedback, I didn't consider this. I didn't expect that much review on classes outside the test + I have never migrated a prototype to Flink, thus I need feedback like this (and I need to think harder beforehand myself ;) )


private final Context context;

private final Logger logger;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private final Logger logger;
private final Logger log;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this your personal taste, or is there consensus on the name? (I have the feeling Till prefers logger, you prefer log)

From this anecdotal evidence, there seems to be no clear winner:

≻ git grep "final Logger log;" | wc -l
11
≻ git grep "final Logger logger;" | wc -l
9

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will change it anyways, because you are reviewing this ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

$ git grep "final Logger log =" | wc -l
30
$ git grep "final Logger logger =" | wc -l
9

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let the grep-games begin ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not fight about stuff like this. At the end of the day time spent for these kind of discussions is wasted.


context.goToExecuting(executionGraph);
} catch (Exception exception) {
logger.error("handling initialization failure", exception);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should clean this up a bit. I only added it back then because it seems like this transition was never logged, but ideally the context logs all state transitions with appropriate the exception.


@Override
public void onEnter() {
context.runIfState(this, this::resourceTimeout, Duration.ofSeconds(10L));
Copy link
Contributor

Choose a reason for hiding this comment

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

If we merge this as is please file a ticket for making the timeout configurable and increasing the default to a higher value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make it configurable right away? I think this would be good because it is also described like this in the latest state of the FLIP.

Comment on lines 102 to 103
ctx.setExpectExecuting(assertNonNull());
ctx.setHasEnoughResources(() -> true); // make resources available
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ctx.setExpectExecuting(assertNonNull());
ctx.setHasEnoughResources(() -> true); // make resources available
ctx.setHasEnoughResources(() -> true); // make resources available
ctx.setExpectExecuting(assertNonNull());

Comment on lines 114 to 115
ctx.setExpectExecuting(assertNonNull());
wfr.onEnter();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ctx.setExpectExecuting(assertNonNull());
wfr.onEnter();
wfr.onEnter();
ctx.setExpectExecuting(assertNonNull());

Comment on lines 134 to 144
ctx.setExpectFinished(
archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.FAILED));
assertThat(archivedExecutionGraph.getFailureInfo(), notNullValue());
assertTrue(
archivedExecutionGraph
.getFailureInfo()
.getExceptionAsString()
.contains(testExceptionString));
});
wfr.onEnter();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ctx.setExpectFinished(
archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.FAILED));
assertThat(archivedExecutionGraph.getFailureInfo(), notNullValue());
assertTrue(
archivedExecutionGraph
.getFailureInfo()
.getExceptionAsString()
.contains(testExceptionString));
});
wfr.onEnter();
wfr.onEnter();
ctx.setExpectFinished(
archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.FAILED));
assertThat(archivedExecutionGraph.getFailureInfo(), notNullValue());
assertTrue(
archivedExecutionGraph
.getFailureInfo()
.getExceptionAsString()
.contains(testExceptionString));
});

Comment on lines 156 to 160
ctx.setExpectFinished(
(archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.CANCELED));
}));
wfr.onEnter();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ctx.setExpectFinished(
(archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.CANCELED));
}));
wfr.onEnter();
wfr.onEnter();
ctx.setExpectFinished(
(archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.CANCELED));
}));

Comment on lines 171 to 177
ctx.setExpectFinished(
(archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.SUSPENDED));
assertThat(archivedExecutionGraph.getFailureInfo(), notNullValue());
}));
wfr.onEnter();
wfr.suspend(new RuntimeException("suspend"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ctx.setExpectFinished(
(archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.SUSPENDED));
assertThat(archivedExecutionGraph.getFailureInfo(), notNullValue());
}));
wfr.onEnter();
wfr.suspend(new RuntimeException("suspend"));
wfr.onEnter();
ctx.setExpectFinished(
(archivedExecutionGraph -> {
assertThat(archivedExecutionGraph.getState(), is(JobStatus.SUSPENDED));
assertThat(archivedExecutionGraph.getFailureInfo(), notNullValue());
}));
wfr.suspend(new RuntimeException("suspend"));

@rmetzger
Copy link
Contributor Author

rmetzger commented Feb 4, 2021

Thanks a lot for your review. I addressed all comments!

Copy link
Contributor

@zentol zentol left a comment

Choose a reason for hiding this comment

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

+1

@rmetzger
Copy link
Contributor Author

rmetzger commented Feb 4, 2021

Thanks for your review. Will merge now!

@rmetzger rmetzger closed this in 2a1c7cb Feb 4, 2021
rmetzger added a commit to rmetzger/flink that referenced this pull request Feb 4, 2021
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.

4 participants