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

Fix Topic Operator's reconciliationIntervalMs type #10158

Merged
merged 2 commits into from
May 28, 2024

Conversation

fvaleri
Copy link
Contributor

@fvaleri fvaleri commented May 26, 2024

The reconciliationIntervalMs should be of type long, as it is dealing with milliseconds, and it is also defined as long in the User Operator model class.

@fvaleri fvaleri requested review from scholzj and ppatierno May 26, 2024 05:47
@fvaleri fvaleri added this to the 0.42.0 milestone May 26, 2024
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.

Why should it be long?

@fvaleri
Copy link
Contributor Author

fvaleri commented May 27, 2024

I started from the model, where we have the reconciliationTimeMs and long is more appropriate for this time resolution. During a test, I set a value of ms in reconciliationIntervalSeconds by mistake and the operator failed with a not so great message (no indication of the offending configuration):

Exception in thread "main" io.strimzi.operator.common.InvalidConfigurationException: Failed to parse. Negative value is not supported for this configuration

If you prefer, we can use int for the spec, but then I would do the same for the User Operator, and possibly improve the configuration error message in a different PR.

@fvaleri fvaleri force-pushed the to-recon-interval-type branch from 5db06a3 to d8644f9 Compare May 27, 2024 06:58
@ppatierno
Copy link
Member

I am fine to align them because the meaning of the variable is the same. So long for both should work.

@scholzj
Copy link
Member

scholzj commented May 27, 2024

To be honest, I do not think this is a good enough reason to change it from int to long. int seems fully sufficient for this field. The field is also very clear that it is in seconds. I think it should be kept as it is (it would be great if we could change the UO field to int as well, but that might break compatibility, so I guess we have to leave that as long).

@fvaleri
Copy link
Contributor Author

fvaleri commented May 27, 2024

I do not think this is a good enough reason to change it from int to long

When you use the env var STRIMZI_FULL_RECONCILIATION_INTERVAL_MS you have ms, then you remember that there is a spec option for that, so you just copy and paste that value, but no, that's in seconds. This is how I did that mistake.

Don't you think that consistency is important here? Why the TO and UO should behave differently? See also my proposal in the next comment.

it would be great if we could change the UO field to int as well, but that might break compatibility, so I guess we have to leave that as long

Yeah, that's not an option now. We may get this change and log an improvement for v1, where we can break compatibility. In that case, we could move both to int, or keep long to align with the env var, maybe renaming to reconciliationTimeMs. I'm fine with both.

@scholzj
Copy link
Member

scholzj commented May 27, 2024

When you use the env var STRIMZI_FULL_RECONCILIATION_INTERVAL_MS you have ms, then you remember that there is a spec option for that, so you just copy and paste that value, but no, that's in seconds. This is how I did that mistake.

Is it confusing to use milliseconds in one place (although slightly hidden from the user) and seconds in another one? Likely yes, but we cannot change the API easily. Feel free to open an issue and we can try to improve it in the v1 API if you think this is important enough.

But changing an int to long as you do here does not fix this problem. And it is probably better if you get an error here than if it happily accepts your millisecond value as seconds value.

Don't you think that consistency is important here? Why the TO and UO should behave differently? See also my proposal in the next comment.

It is important to use consistently the correct things. Not be consistent in doing the wrong thing.

Also, as a sidenote ... there is not much consistency between the TO and the other operators. In the PR next to this one, you seem to be happy to continue and extend the inconsistencies there (for exaample by using the var fields instead of using proper types). Yet here you are somehow pretending that consistency is the most important thing you cannot live without?

@fvaleri
Copy link
Contributor Author

fvaleri commented May 27, 2024

It is important to use consistently the correct things. Not be consistent in doing the wrong thing.

Fair enough. I'll remove the TO spec change from this PR and log an issue.

consistency is the most important thing you cannot live without?

Never said that. I was talking about behavior consistency, which is a different thing. If you think there is some issue with using var, please comment on the specific context and I'll be happy to discuss and make improvements.

@scholzj
Copy link
Member

scholzj commented May 27, 2024

Never said that. I was talking about behavior consistency, which is a different thing. If you think there is some issue with using var, please comment on the specific context and I'll be happy to discuss and make improvements.

I do not see any inconsistent behavior here in this case. There is inconsistent use of int and long, but no inconsistent behavior.

As for var, I think this was already discussed at least once in the past. It is only very rarely used in our code outside of the Topic Operator. As I said, I do not have a major problem with it as I accepted that the TO is special and different for one reason or another. I'm just pointing out that you seem happy with inconsistencies in one place and very strict about them in another.

@fvaleri
Copy link
Contributor Author

fvaleri commented May 27, 2024

There is inconsistent use of int and long, but no inconsistent behavior.

If you insert a value that overflows int, then you have a different behavior. The UO will take it, while the TO will fail (which is better, as you say).

@fvaleri
Copy link
Contributor Author

fvaleri commented May 27, 2024

@scholzj spec changes are reverted now.

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.

The code LGTM. Please update the PR description.

@scholzj
Copy link
Member

scholzj commented May 27, 2024

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

fvaleri added 2 commits May 27, 2024 17:16
The reconciliationIntervalMs should be of type long, as it is dealing with milliseconds, and it is also defined as long in the User Operator model class.

Signed-off-by: Federico Valeri <[email protected]>
Signed-off-by: Federico Valeri <[email protected]>
@fvaleri fvaleri force-pushed the to-recon-interval-type branch from c149f39 to 36efdf4 Compare May 27, 2024 15:17
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.

LGTM

@ppatierno
Copy link
Member

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scholzj scholzj merged commit b004068 into strimzi:main May 28, 2024
21 checks passed
@fvaleri fvaleri deleted the to-recon-interval-type branch May 29, 2024 06:02
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.

3 participants