-
Notifications
You must be signed in to change notification settings - Fork 372
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-27279] Extract common status interfaces #176
Conversation
I also try to make the ReconcileUtils to a new Object to handle the Please let me know if you have better suggestion cc @gyfora @wangyang0918 thanks |
@Aitozi seems like the FlinkDeploymentStatus and FlinkSessionJobStatus also have a lot in common (the only diff is that FlinkDeploymentStatus has an extra JMDeploymentStatus field) but jobStatus, error and reconciliationStatus could be completely shared This could also simplify what you have tried to do with the CommonView logic which is a little confusing right now I think |
@gyfora Thanks for your suggestion, I will try as you suggested |
1f106d6
to
b8cedd1
Compare
Due to the java type erasure, I can't not completly eliminate the |
Thank you, I will check this later today :) |
/** | ||
* Get the current reconciliation status. | ||
* | ||
* @return the current reconciliation status. | ||
*/ | ||
ReconciliationStatus<SPEC> getReconcileStatus(); | ||
|
||
/** | ||
* Let the target custom resource handle the reconciliation error. | ||
* | ||
* @param error The error to be handled. | ||
*/ | ||
void handleError(@Nullable String error); |
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 these methods should be part of the CommonStatus interface instead. Simply have the ReonciliationStatus and error fields there and use get/set
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.
That way the ReconcileTerget interface could be also removed and use CustomResource<SPEC extends SpecView, STATUS extends CommonStatus>
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.
Good suggestion, I have refactor based on your suggestion, please take a look again.
public FlinkDeploymentSpec deserializeLastReconciledSpec() { | ||
return ReconciliationUtils.deserializedSpecWithVersion( | ||
lastReconciledSpec, FlinkDeploymentSpec.class); | ||
public abstract Class<SPEC> getSpecClass(); |
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.
You could also simply add a constructor that takes the spec class (you have that when you call initStatus by calling getSpec().getClass()). Then you would not need 2 subclasses just to implement this.
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 have tried this way, But if I add a field to record the spec class in ReconciliationStatus
(making it @JsonIgnore
), It will cause the CRDGenerator stack overflow . So I kept it as it now
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.
interesting, I will take a look at this later :)
5450276
to
f62350d
Compare
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.
Added some last minor comments. Thanks @Aitozi it looks really good now.
/** Error information about the FlinkDeployment/FlinkSessionJob. */ | ||
private String error; | ||
|
||
public abstract ReconciliationStatus<SPEC> getReconciliationStatus(); |
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.
Missing javadoc comment
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.
fixed
package org.apache.flink.kubernetes.operator.crd.spec; | ||
|
||
/** The common view of the spec. */ | ||
public interface SpecView { |
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.
Could this be an abstract class instead called FlinkSpecBase
or AbstractFlinkSpec
which could contain the job field (with the lombok annotation) that both deployment and sessionjobspec would extend?
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.
Nice suggestion, It looks more naturally now :).
public FlinkDeploymentSpec deserializeLastReconciledSpec() { | ||
return ReconciliationUtils.deserializedSpecWithVersion( | ||
lastReconciledSpec, FlinkDeploymentSpec.class); | ||
public abstract Class<SPEC> getSpecClass(); |
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.
interesting, I will take a look at this later :)
### CommonStatus | ||
**Class**: org.apache.flink.kubernetes.operator.crd.status.CommonStatus | ||
|
||
**Description**: Last observed common status of the Flink deployment/Flink SessionJob. | ||
|
||
| Parameter | Type | Docs | | ||
| ----------| ---- | ---- | | ||
| jobStatus | org.apache.flink.kubernetes.operator.crd.status.JobStatus | Last observed status of the Flink job on Application/Session cluster. | | ||
| error | java.lang.String | Error information about the FlinkDeployment/FlinkSessionJob. | |
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.
The inheritence structure breaks the (not very sophisticated) doc generation logic. We should either fix it here or open a blocker jira to track this
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 also confused here, what‘s the expect content here? Do we need to display the FlinkDeploymentReconciliationStatus
fileds include (in the parent) directly and skip the abstract classes
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 open another PR after this to fix this problem soon .
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 from the users perspective it would be best to skip any abstract classes and only show the “child/leaf” classes in the hierarchy with all fields from the superclasses .
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.
Get it, I will try to make up the content in this way
This pr is meant to extract common status interfaces to simplify the ReconcileUtils
The brief change log
CommonView
andSpecView
to describe the common part between theFlinkDeployment
andFlinkSessionJob
ReconciliationStatus
for bothFlinkDeployment
andFlinkSessionJob
Verified by the current tests.