-
Notifications
You must be signed in to change notification settings - Fork 453
[FLINK-33634] Add Conditions to Flink CRD's Status field #957
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
base: main
Are you sure you want to change the base?
Conversation
@lajith2006 please could you fill in a descriptive title next to the Jira number |
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.
removed comment
@lajith2006 this implementation does not match the Flip words and has not been discussed in the slack thread, please can you update the discussion thread to ensure that you get consensus, and confirm that the Flip vote still is valid after this change. |
} else if (getJobStatus() != null && getJobStatus().getState() != null) { | ||
switch (getJobStatus().getState()) { | ||
case RECONCILING: | ||
phase = "Pending"; |
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.
why is this one not RECONCILING like the pattern the others follow others? I suggest a comment, also a constant is better then a an inline literal.
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.
Right, as mentioned here , phase
which is intended to keep the current status of FlinkDeployment especially useful in Openshift environment, as Openshift UI can render the value from status.phase
and populate the current status of deployment.
As when FlinkDeployment applied in Application Mode, in the initial phase, as the JM brining up , job state would be in RECONCILING
state, so status.phase is kept as "Pending".
updateCondition( | ||
conditions, | ||
ConditionUtils.runningTrue( | ||
"JobManager is running and ready to receive REST API call", |
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.
nit: call -> calls
if (reconciliationStatus != null | ||
&& reconciliationStatus.deserializeLastReconciledSpec() != null | ||
&& reconciliationStatus.deserializeLastReconciledSpec().getJob() == null) { | ||
switch (jobManagerDeploymentStatus) { |
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.
can we have a datastructure, keyed off the jobManagerDeploymentStatus, that we interrogate to get the inserts for the updateConditions. Maybe a map with the key of the status and the value of an object RunningCondition, that has 2 fields the boolean and the description. Something like :
Map<JobManagerDeploymentStatus,String> jobmanagerDeploymentStatusMap = new HashMap<String,String>() {{
put(READY, new RunningCondition(true, "JobManager is running and ready to receive REST API calls")),
....
}};
then the code just loops through the map updating conditions using the map values. Similar for jobstatus
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.
Wondering will that add any value?. Any way to build the Map , we have to call ConditionUtils
to build the Condition, so rather than have a Prebuild Map , we can directly call ConditionUtils
to build them right. Your thoughts?.
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.
I think you have pre built the map now - with map.of - looks good - thanks.
conditions, | ||
ConditionUtils.runningFalse( | ||
JobStatus.RESTARTING.name(), | ||
"The job is currently undergoing a restarting")); |
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.
nit: "The job is currently undergoing a restarting" -> "The job is currently restarting"
private String phase; | ||
|
||
public List<Condition> getConditions() { | ||
if (reconciliationStatus != null |
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.
I am curious which parts of the code refer to application mode and which are session cluster. It would be good to have some comments to detail this and maybe use the mode name in method name or variable names to make this more intuitive to read.
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.
I will add comments in the respective code.
conditions, | ||
ConditionUtils.runningFalse( | ||
"JobManager process is starting up", | ||
"JobManager process is starting up")); |
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.
I am curious why the message and reaon is the same . I would expect them to be different. In this case I would expect the reason to be "A New JVM deployment exists and is being created" - i.e. the word on the arrow in the UML.
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.
As per description here which says Reason is intended to be a one-word, CamelCase representation of the category of cause of the current status, and Message is intended to be a human-readable phrase or sentence
, I would use the existing enum https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/status/JobManagerDeploymentStatus.java, to use as reason and respective explanation as message
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.
I see https://github.com/apache/flink-kubernetes-operator/pull/961/files, gives examples of camelcase single words reasons. We should follow that style for the cases that PR does not cover.
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.
Done a refactoring for the conditions.
@@ -448,6 +465,15 @@ public void verifyUpgradeFromSavepointLegacyMode(FlinkVersion flinkVersion) thro | |||
assertEquals( | |||
"savepoint_1", appCluster.getStatus().getJobStatus().getUpgradeSavepointPath()); | |||
|
|||
// Validate status conditions |
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.
can we use a java parameterized test (or more than one as appropriate) to cover all the permutations of the tests.
import java.util.Date; | ||
|
||
/** | ||
* Creates a condition object with the specified parameters. |
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.
nit: with the specified parameters -> whether this is running , the message and the reason.
then for return just say @return A condition
*/ | ||
public class ConditionUtils { | ||
public static Condition runningTrue(final String message, final String reason) { | ||
return crCondition("Running", "True", message, reason); |
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.
no need to pass "Running" as a parameter, we can hard code that in the method,
nit: rename crCondition -> crRunningCondition
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.
I would like to keep method name as crCondition
rather crRunningCondition
, just because , crCondition
will keep it as more generic , so that if in case, if we need to address any other condition with type
other than Running
, we just need to pass parameter to build respective condition.
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.
I suggest doing that refactor when we need to, in the spirit of keeping the code lean.
} | ||
|
||
public static Condition runningFalse(final String message, final String reason) { | ||
return crCondition("Running", "False", message, reason); |
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.
are there constants / enums for "False" and "True" we can use?
Os there an existing constant for "Running" we can use from OCP or the like. If not we should define this as a constant. We use this literal a few times in this change.
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.
I haven't see any existing enum/constants for "False" / "True , instead looks like used as string itself in wherever required in existing code.
Would it be useful also to set also observedGeneration on the conditions, I believe it is in general a good practice. |
&& existingCondition.getMessage().equals(condition.getMessage())) { | ||
return; | ||
} | ||
conditions.add(condition); |
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.
It's maybe just me, just don't get how this list is truncated eventually, in other words, how is it prevented from growing indefinitely?
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.
Thanks for review @csviri . Right now it's not preventing from growing indefinitely. As conditions reflects the different transitions state of Job/Deployment , thinking what could be the use case where can grow indefinitely?.
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.
I think there should only ever be a single condition of type Running
in the list that we return. Since we only have a single condition type right now, then the list should only have a single element. The latestTransition timestamp needs to represent when running changed from true->false or false->true. We can however keep updating the message if we want.
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.
Thanks @gyfora for review , If I read correctly , you meant that we need to have only condition in the list at right now as we have only one type Running
instead of multiple conditions of same type Running
in the list as currently this PR having. And the lastTransitionTime
in the condition must represent when the Running
type changed its status from true>false or false > true. Is that correct?.
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.
@lajith2006 you say the lastTransitionTime in the condition must represent when the Running type changed its status from true>false or false > true. Is that correct?.
So I am curious what happens in the history if we change the reason Text? Can you check that if we change the reason text and not the running flag, we see all of the entries in the history if all the historical conditions have the same lastTransitionTime with changing reasons.
&& reconciliationStatus.deserializeLastReconciledSpec().getJob() == null) { | ||
// Populate conditions for SessionMode deployment | ||
switch (jobManagerDeploymentStatus) { | ||
case READY: |
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.
instead of this switch can we just issue
updateCondition(
conditions,
ConditionUtils.crCondition(
ConditionUtils.SESSION_MODE_CONDITION.get(
jobManagerDeploymentStatus.name())));
} | ||
} else if (getJobStatus() != null && getJobStatus().getState() != null) { | ||
// Populate conditions for ApplicationMode deployment | ||
switch (getJobStatus().getState()) { |
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.
can this switch as-is be replaced with
updateCondition(
conditions,
ConditionUtils.crCondition(
ConditionUtils.APPLICATION_MODE_CONDITION.get(
getJobStatus().getState().name())));
.withType("Running") | ||
.withStatus("True") | ||
.withMessage("Ready") | ||
.withReason("JobManager is running and ready to receive REST API calls") |
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.
isn't the reason - how it got to this state, not a description of the state itself?
What is the purpose of the change
This PR address the FLIP to add conditions to flink deployment status related to issue https://issues.apache.org/jira/browse/FLINK-33634
Brief change log
FlinkDeploymentStatus
ConditionUtils
introduced as utility class to build condition.Verifying this change
Does this pull request potentially affect one of the following parts:
CustomResourceDescriptors
: yesDocumentation