-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Create version-specific helper for poison pills #101767
Conversation
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'd be inclined to put this in its own class. It's not really an assertion, there's no need to even call it, it's just a symbol to reference in all the places that need cleaning up. In particular it's useful sometimes just to mention it in Javadocs.
I also don't think it needs a String reason
argument. In most cases it'll be obvious from the context why it's there, and if not then that's something that deserves some more extensive commentary than we'd normally put into a string literal.
No problem here. But based on the team comments, I am inclined to keep the "assert" in the name at least, so the behaviour is clear (will only have effects when running with assertions on, will throw an AssertionException, ...)
That's why I was leaning towards an annotation, to make it more visible and visible "earlier" (even in precommit, for example). Calling it (vs just mentioning it in Javadoc) will enforce that we address it before releasing, it can have some value.
What about using a |
BTW, any suggestion on were to place it? Since we are moving it from |
|
But it doesn't have any effects, it's an
I'd be happy with an annotation. You can mention annotations in Javadocs easily enough. Possibly as well as just a plain symbol.
I'm still leaning towards YAGNI here. I think folks are good enough at writing comments as needed in these cases, possibly linking to issues from the comment if a link is needed, but often it won't be and that's fine. Let's try without and if we see that it causes problems in practice then we can rethink. |
I also suggest you adjust some of the existing poison pills to use this new functionality in this very PR so we can get a better sense of how it works in practice. |
I think an annotation would work a lot better here - its a declarative statement about code, not part of any functionality. You can even declare the annotation as source-file only, so it doesnt even appear in compiled class files. |
I thought we were, so we are sure we got all of them. But yeah, if we remove it entirely we won't compile, so no point. |
I'll give annotations a go then :) |
Based on our conversations, I did not add an annotation processor, just the annotation |
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 like it :)
@@ -73,6 +73,7 @@ public class DiskThresholdDecider extends AllocationDecider { | |||
|
|||
public static final String NAME = "disk_threshold"; | |||
|
|||
@RemoveBeforeV9 |
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.
We should make this setting DeprecatedCritical
if it's going away.
To make this a bit more general, how about |
I was also thinking that "Remove" is not always precise. |
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Hi @ldematte, I've created a changelog YAML for you. |
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.
While the annotation seems mostly ok, I think we are losing some things by this not being an actual check.
- Currently with the existing assertions, when we bump the next major, we must address all of these poison pills. While a lot of these are cleanup, I thought I've seen them before where they address behavior (eg code assumes something that no longer holds true). I can't find any right now, but if that is a valid use case for these pills then not having a check means when we bump we could merge to main, and thus push code violating those assumptions to serverless. With an assertion we ensure these must be addressed in a feature branch before merging to main.
- Can the annotation be placed on any line of code? I don't think it can, I think it must be attached to something. So we lose the flexibility to keep note that something needs to be changed next to the thing that actually needs changing. As an example, look at the poison pills in ReplicationTracker or TransportStats.
Addressing this one:
You are right, it's the first thing I noticed when I switched to annotations and tried to address a few like David suggested. You have to refactor the code a bit to isolate the lines you want to flag for removal/change in a method or class. I don't think this is bad though - it can make clearer which bit of code you need to work on, and make life easier when time for change/removal comes. That said, I'm not strongly towards static functions or annotations, neither I am strongly pro using them just as a placeholder symbol or actually have additional logic (assert false). |
I would expect it almost always to be the other way around: the code is there to handle something that we can (in the future version) assume not to need handling any more. I'd be very interested in examples where that isn't true. But in any case I expect it's enough to have a reminder (such as this annotation) which we would remove when we've taken whatever action needs taking.
I am not wholly convinced we need this flexibility. I see some benefits in forcing the relevant code to be isolated in its own method, and I'm sure we can always find something to annotate even where it's tricky to isolate exactly the relevant code.
I only see one in |
server/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java
Outdated
Show resolved
Hide resolved
libs/core/src/main/java/org/elasticsearch/core/UpdateBeforeV9.java
Outdated
Show resolved
Hide resolved
@elasticmachine rerun elasticsearch-ci/part-3 |
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.
LGTM
Thanks all for all the input! |
Follow up of #101767 Move from exception and assertions using Version.CURRENT to @UpdateForV9 annotation
In elastic#101815 we made some changes to the get-aliases API that need followup actions when preparing to release v9. At the time they were marked with a transport version that will become obsolete in v9, but with elastic#101767 we now have a better mechanism for leaving a reminder for this kind of action. This commit updates things to use the new @UpdateForV9 annotation instead.
In elastic#101815 we made some changes to the get-aliases API that need followup actions when preparing to release v9. At the time they were marked with a transport version that will become obsolete in v9, but with elastic#101767 we now have a better mechanism for leaving a reminder for this kind of action. This commit updates things to use the new @UpdateForV9 annotation instead.
After discussion, we came to the agreement that keeping poison pills in code is beneficial; we also agreed to use a global "symbol" that is specific to a precise version, so we can stop using different flavors of comparisons based on
Version
.The "symbol" we use is a public static function, for two reasons:it let us provide areason
message to help remember what the poison pill is about/what we need to fixit let us the freedom of modify the implementation later on, in case we need to make adjustments for specific cases (e.g. serverless - those should not be necessary, but just in case we need an additional tool)The javadoc summarizes very briefly how we intend to use this assertion going forward, making it trip on a dedicated branch in order to find and address all the poison pill before starting the release process.Update: second take, using an annotation.
As of David suggestion, I skipped any "reason" or "issueUrl" for now.
I also went on and replaced some
assert Version...
with the new annotation.The annotation can be less flexible and force you to refactor the code to change/replace into a separate method (see the examples). I do not think this is a bad thing, but I'll let you judge.
For the reviewers:
reason
or anissueUrl
(like in theAwaitsFix
annotation)? Theassert
a I replaced all had a message or a short comment. I kept it as a short comment for now.Related to ES-6873