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

Split the classes from the io.strimzi.api.kafka.model package to multiple sub-packages #9207

Merged
merged 4 commits into from Jan 8, 2024

Conversation

ShubhamRwt
Copy link
Contributor

@ShubhamRwt ShubhamRwt commented Oct 4, 2023

Type of change

Select the type of your PR

  • Refactoring

Description

This PR fixes #8628. This PR moves moves classes to their corresponding packages. This PR adds import order checkstyle rule which makes sure that the imports are ordered properly

Checklist

Please go through this checklist and make sure all applicable tasks have been done

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Check RBAC rights for Kubernetes / OpenShift roles
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md
  • Supply screenshots for visual changes, such as Grafana dashboards

@ShubhamRwt ShubhamRwt force-pushed the apiRefactor branch 2 times, most recently from 2a91372 to b8f85ef Compare October 4, 2023 19:57
@ShubhamRwt ShubhamRwt changed the title Split the classes from the io.strimzi.api.kafka.model package to multiple sub-packages [WIP]Split the classes from the io.strimzi.api.kafka.model package to multiple sub-packages Oct 4, 2023
@ShubhamRwt ShubhamRwt marked this pull request as ready for review October 5, 2023 12:25
@scholzj scholzj changed the title [WIP]Split the classes from the io.strimzi.api.kafka.model package to multiple sub-packages Split the classes from the io.strimzi.api.kafka.model package to multiple sub-packages Oct 5, 2023
Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

For lot of the files, the ordering of the imports seems to be complete mess. I wonder if we should use this as an opportunity where we already touch so many files to enforce some import ordering by checkstyle (if that is possible)

Comment on lines 26 to 46
import io.strimzi.api.kafka.model.common.CertSecretSource;
import io.strimzi.api.kafka.model.common.ClientTls;
import io.strimzi.api.kafka.model.common.JvmOptions;
import io.strimzi.api.kafka.model.bridge.KafkaBridge;
import io.strimzi.api.kafka.model.bridge.KafkaBridgeAdminClientSpec;
import io.strimzi.api.kafka.model.bridge.KafkaBridgeConsumerSpec;
import io.strimzi.api.kafka.model.bridge.KafkaBridgeHttpConfig;
import io.strimzi.api.kafka.model.bridge.KafkaBridgeProducerSpec;
import io.strimzi.api.kafka.model.bridge.KafkaBridgeResources;
import io.strimzi.api.kafka.model.bridge.KafkaBridgeSpec;
import io.strimzi.api.kafka.model.common.Rack;
import io.strimzi.api.kafka.model.common.authentication.KafkaClientAuthentication;
import io.strimzi.api.kafka.model.common.template.ContainerTemplate;
import io.strimzi.api.kafka.model.common.template.DeploymentStrategy;
import io.strimzi.api.kafka.model.common.template.DeploymentTemplate;
import io.strimzi.api.kafka.model.common.template.InternalServiceTemplate;
import io.strimzi.api.kafka.model.bridge.KafkaBridgeTemplate;
import io.strimzi.api.kafka.model.common.template.PodDisruptionBudgetTemplate;
import io.strimzi.api.kafka.model.common.template.PodTemplate;
import io.strimzi.api.kafka.model.common.template.ResourceTemplate;
import io.strimzi.api.kafka.model.common.tracing.Tracing;
Copy link
Member

Choose a reason for hiding this comment

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

Should we have some ordering of the imports? They seem to be mixing up pretty badly.

Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks.

Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

Actually, does not LGTM -> you have to fix the tests. At least some of them are IMHO failing because you have to rename some resources etc.

@scholzj scholzj self-requested a review October 11, 2023 20:15
@scholzj
Copy link
Member

scholzj commented Oct 11, 2023

But the imports and core changes itself look good to me.

@ShubhamRwt
Copy link
Contributor Author

@scholzj Is there a way to restart these tests?

@scholzj
Copy link
Member

scholzj commented Oct 19, 2023

@ShubhamRwt I restarted them.

CHANGELOG.md Outdated
@@ -43,6 +43,7 @@
config.providers.env.class: org.apache.kafka.common.config.provider.EnvVarConfigProvider
# ...
```
* The `api` module was refactored and classes were moved to new packages
Copy link
Member

Choose a reason for hiding this comment

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

You have to move this to 0.39.0.

@scholzj
Copy link
Member

scholzj commented Oct 21, 2023

/azp run regression

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@ppatierno ppatierno left a comment

Choose a reason for hiding this comment

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

I left one question but no need to change ... but my biggest doubt is ...
should we really have io.strimzi.api.kafka.model and not just io.strimzi.api.model?
I mean, we have a package like io.strimzi.api.kafka.model.kafka.* so kafka is twice in the hierarchy.

@@ -2,7 +2,7 @@
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.api.kafka.model;
package io.strimzi.api.kafka.model.acl;
Copy link
Member

Choose a reason for hiding this comment

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

just an idea, doesn't it make more sense having under user package so ... io.strimzi.api.kafka.model.user.acl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that was what we thought at start. But if you go through this sheet -> https://docs.google.com/document/d/1uZwYGZFo9FIR-95q2PV5Npl6IN1KfWSr12cRp21VMpM/edit, I made this change based on Tom's comment

Copy link
Member

Choose a reason for hiding this comment

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

@ppatierno WDYT about this? Do you want @ShubhamRwt to change or or are you fine with it?

Copy link
Member

Choose a reason for hiding this comment

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

Tbh I didn't get what @tombentley meant with that comment :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tombentley Hi, should we have the acl's under user package?

@ShubhamRwt
Copy link
Contributor Author

ShubhamRwt commented Nov 2, 2023

Update for community call: I was waiting for reviews regarding the new structure so that I can push those changes and rebase this PR together since the merge conflicts keeps happening when other PRs are merged due to dependency import changes

Copy link
Member

@tombentley tombentley left a comment

Choose a reason for hiding this comment

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

@ShubhamRwt thanks for this! Sorry for not having taken a look sooner. There are some build conflicts (which are probably my fault for not having reviewed sooner) which will need to be fixed.

We should consider adding to the rules in .checkstyle/import-control.xml, which currently only really enforces a few things in the operator, not anything in the api module. For example (these are off the top of my head, so might not actually be correct; treat them as illustrative):
* each of the CRD-specific packages in the model module is allowed import the common one, but not vice versa.
* the certificate-manager shouldn't be allowed to import any other Strimzi code

api/pom.xml Outdated
<argument>io.strimzi.api.kafka.model.bridge.KafkaBridge=${project.basedir}${file.separator}..${file.separator}packaging${file.separator}install${file.separator}cluster-operator${file.separator}046-Crd-kafkabridge.yaml</argument>
<argument>io.strimzi.api.kafka.model.connector.KafkaConnector=${project.basedir}${file.separator}..${file.separator}packaging${file.separator}install${file.separator}cluster-operator${file.separator}047-Crd-kafkaconnector.yaml</argument>
<argument>io.strimzi.api.kafka.model.mirrormaker2.KafkaMirrorMaker2=${project.basedir}${file.separator}..${file.separator}packaging${file.separator}install${file.separator}cluster-operator${file.separator}048-Crd-kafkamirrormaker2.yaml</argument>
<argument>io.strimzi.api.kafka.model.balancing.KafkaRebalance=${project.basedir}${file.separator}..${file.separator}packaging${file.separator}install${file.separator}cluster-operator${file.separator}049-Crd-kafkarebalance.yaml</argument>
Copy link
Member

Choose a reason for hiding this comment

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

This stands out as the only package name that's a gerund. We don't have connecting, bridging or mirrormaking. Perhaps this should be rebalance instead?

@scholzj
Copy link
Member

scholzj commented Nov 30, 2023

@ShubhamRwt @tombentley Where do we stand on with this PR?

@ShubhamRwt
Copy link
Contributor Author

@scholzj @tombentley What do you suggest, should I make io.strimzi.api.kafka.model to just io.strimzi.api.model as suggested by Paolo?

@scholzj
Copy link
Member

scholzj commented Dec 11, 2023

I would not go for such a major change given this is essentially a part of an public API.

Copy link
Member

@tombentley tombentley left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @ShubhamRwt

@ppatierno
Copy link
Member

@ShubhamRwt I could have another pass on this but I think you should first resolve all the conflicts.

Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
@ShubhamRwt
Copy link
Contributor Author

ShubhamRwt commented Jan 8, 2024

@ppatierno Hi, I have rebased it now

@scholzj scholzj merged commit 5b7a7d7 into strimzi:main Jan 8, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split the classes from the io.strimzi.api.kafka.model package to multiple sub-packages
4 participants