Skip to content

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Sep 10, 2025

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict

When merge conflicts arise with transport versions we want to be able to
regenerate ids for all the branches currently defined in the newly added
transport version definition. This commit adds an `--update` flag to the
generate task which figures out the appropriate branches automatically
from the outstanding definition. With this the command line to
regenerate on a merge conflict is as simple as:

`./gradlew generateTransportVersion --update`
@rjernst rjernst requested a review from a team as a code owner September 10, 2025 04:27
@rjernst rjernst added >non-issue :Core/Infra/Core Core issues without another label auto-backport Automatically create backport pull requests when merged v8.19.5 v9.1.5 v8.18.8 v9.0.8 labels Sep 10, 2025
@elasticsearchmachine elasticsearchmachine added v9.2.0 Team:Core/Infra Meta label for core/infra team labels Sep 10, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@prdoyle
Copy link
Contributor

prdoyle commented Sep 10, 2025

Could this "just work" without specifying --update? The mental model where I just run ./gradlew generateTransportVersion to fix stuff will be easier for users to remember.

If the answer is "no", then let's rename the flag to something more explicit. Since generateTransportVersion is designed to be idempotent, people will think that generateTransportVersion already "updates" the TV, and so the flag --update won't mean much. Perhaps --resolve-conflict?

@mark-vieira
Copy link
Contributor

If the answer is "no"

The answer is indeed no as we cant distinguish between --backport-branches missing because we actually want to remove those backports or we've just omitted the option. We don't want people to have to pass that.

Perhaps --resolve-conflict?

Yeah, but that's not really what it's doing. This is what you run after you resolve the conflict by doing a merge.

Really what we're trying to communicate with this flag is it's "non-destructive". It's not going to remove any existing transport ids, just "update" or "refresh" them to align with upstream changes.

referableAndReferencedTransportVersion("new_tv", "8123000")
file("myserver/src/main/resources/transport/latest/9.2.csv").text =
"""
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

The intention is that folks do a merge (address conflicts) and then run this task right? So we should never be in a position where we have conflicts in files? I mean either way, the content of the file is sort of irrelevant as we're just going to override it so the test is still valid as-is. Just want to understand the intent here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that's the intention. You're right that the contents don't matter. I just made the test mimic the scenario as much as possible, and this is what it would like during a merge with a conflict.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would think the dev shouldn't have to resolve the conflicts in the generated files at all. I assume this is the intention still? So if that's the only conflict they can just run this gradle task again.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would think the dev shouldn't have to resolve the conflicts in the generated files at all. I assume this is the intention still?

I don't think we can avoid that. They are going to have to resolve those conflicts just like any other. The thing is that it doesn't really matter how they are resolved since we'll just fix it.

Files.writeString(path, upperBound.definitionName() + "," + upperBound.definitionId().complete() + "\n", StandardCharsets.UTF_8);

if (stageInGit) {
gitCommand("add", path.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really necessary? I mean we don't do this for any other kind of generation tasks. Can we not just rely on folks to do this themselves just as with any other local changes that need to be committed/pushed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not necessary, but I think it's good. I don't think devs should think about the files that need to be added, when there is a conflict, they just run this command, and these files will no longer show as unresolved. Otherwise they would have to add themselves (or run git commit -a, but not everyone does that with merge conflicts).

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean we don't do this for any other kind of generation tasks

We could consider doing this for other files...

Copy link
Contributor

Choose a reason for hiding this comment

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

I worry if we don't add the files it would actually be more confusing since they are absolutely necessary to run ES so I'm +1 on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have super strong feelings on this but I'm generally -1 on things that muck with folks' local git state. There's just so many unique workflows people use and we just don't know when we might be stepping on those.

Copy link
Member

Choose a reason for hiding this comment

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

I suppose the question is "how magic is the tool/transport versions". We don't auto-stage spotlessApply because it's touching code we wrote. No magic. But we do auto-stage it when CI does spotlessApply for us.

If transport versions are managed by the tool almost entirely, then, yeah, staging is nice and useful.

As far as commit -a - whenever I get a merge conflict I manually git add each resolved file one by one on the command line. But I'm old now. I have no idea what most folks do.

I'd be really creeped out if it auto-staged files it isn't managing. But that's not this.

Copy link
Contributor

Choose a reason for hiding this comment

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

If transport versions are managed by the tool almost entirely, then, yeah, staging is nice and useful.

That's a fair distinction. In which case to my previous comment, I would then expect it to auto stage for any changes it makes to files it manages, not just when passing --resolve-conflict.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just thinking maybe it should auto-stage for anything involving the internal transport version files because we really don't expect or want users to have to consider these at all.

Copy link
Contributor

@mark-vieira mark-vieira Sep 10, 2025

Choose a reason for hiding this comment

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

I don't think we expect folks to understand all those distinctions. Basically we don't expect folks to ever manually touch any of these files. If that's the case, then I agree with Nik that the task should just "own" these files and handle staging them in all scenarios if that's what we're gonna do.

Copy link
Contributor

Choose a reason for hiding this comment

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

++


@Input
@Optional
@Option(option = "update", description = "Update the transport version currently being added to upstream")
Copy link
Contributor

@jdconrad jdconrad Sep 10, 2025

Choose a reason for hiding this comment

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

I like @mark-vieira's suggestion of refresh better than update. Update implies we are working on something that already exists which the version being worked on doesn't.

Copy link
Member Author

@rjernst rjernst Sep 10, 2025

Choose a reason for hiding this comment

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

Per a suggestion from @nik9000 I've changed this to --resolve-conflict since that is what a developers is trying to do, resolve a merge conflict

Copy link
Member

Choose a reason for hiding this comment

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

Oh hey. Neat.

Copy link
Contributor

@mark-vieira mark-vieira Sep 10, 2025

Choose a reason for hiding this comment

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

Per a suggestion from @nik9000 I've changed this to --resolve-conflict since that is what a developers is trying to do, resolve a merge conflict

I'm still not a fan, mainly because just running this task doesn't actually resolve the conflict. You still have to merge upstream changes and then run this task. I'll defer my objections though if that makes intuitive sense to most folks. I might be too close to this work to provide an objective opinion here.

@rjernst rjernst changed the title Add --update flag to transport version generate task Add --resolve-conflict flag to transport version generate task Sep 10, 2025
@mark-vieira
Copy link
Contributor

It's worth noting that rather than having a single task and exposing this behavior as a cli option, we could just register another task with a better name that's preconfigured to do the right thing. For example just register a fixTransportVersions task and make this "resolve conflict" or "update" or whatever property be internal and set it by the plugin.

@prdoyle
Copy link
Contributor

prdoyle commented Sep 10, 2025

we cant distinguish between --backport-branches missing because we actually want to remove those backports or we've just omitted the option.

Does that indicate that we've neglected to collect certain requirements from the user? Why can't we tell this?

@prdoyle
Copy link
Contributor

prdoyle commented Sep 10, 2025

+1 on a separate task. Seems more Gradley.

@mark-vieira
Copy link
Contributor

we cant distinguish between --backport-branches missing because we actually want to remove those backports or we've just omitted the option.

Does that indicate that we've neglected to collect certain requirements from the user? Why can't we tell this?

Yes, because running the task with an empty set is perfectly fine, and actually the way most people will run it. Also, it's just super easy to forget.

@rjernst
Copy link
Member Author

rjernst commented Sep 11, 2025

we could just register another task with a better name

While that might work, the implementation will be annoying (having to duplicate much of the logic from the generate task). And I think it's simpler for devs to remember one task name for transport versions with a flag than two different tasks, but that's just a gut feeling which is easier to remember.

@rjernst
Copy link
Member Author

rjernst commented Sep 11, 2025

Yeah, but that's not really what it's doing. This is what you run after you resolve the conflict by doing a merge.

I don't think that's true. It's what you run after you run git merge when you have conflicts, and this is how you resolve conflicts within transport state files.

@mark-vieira
Copy link
Contributor

While that might work, the implementation will be annoying (having to duplicate much of the logic from the generate task).

My suggestion was just to use the same task type, just configure it differently so you wouldn't have to actually duplicate implementation logic.

And I think it's simpler for devs to remember one task name for transport versions with a flag than two different tasks, but that's just a gut feeling which is easier to remember.

Yeah, that might be true. Just figured I'd make it known that's an option.

@rjernst rjernst merged commit 47acb9a into elastic:main Sep 12, 2025
35 checks passed
@rjernst rjernst deleted the transport/generate_update_flag branch September 12, 2025 17:25
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 12, 2025
…ic#134421)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 12, 2025
…ic#134421)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 12, 2025
…ic#134421)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.19
9.1
8.18
9.0

rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 12, 2025
…ic#134421)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
elasticsearchmachine pushed a commit that referenced this pull request Sep 12, 2025
…) (#134662)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
elasticsearchmachine pushed a commit that referenced this pull request Sep 12, 2025
…) (#134661)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
elasticsearchmachine pushed a commit that referenced this pull request Sep 12, 2025
…) (#134660)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
elasticsearchmachine pushed a commit that referenced this pull request Sep 12, 2025
…) (#134663)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Sep 17, 2025
…ic#134421)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
gmjehovich pushed a commit to gmjehovich/elasticsearch that referenced this pull request Sep 18, 2025
…ic#134421)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
sarog pushed a commit to portsbuild/elasticsearch that referenced this pull request Sep 19, 2025
…ic#134421) (elastic#134660)

When merge conflicts arise with transport versions we want to be able to regenerate ids for all the branches currently defined in the newly added transport version definition. This commit adds a --resolve-conflict flag to the generate task which figures out the appropriate branches automatically from the outstanding definition. With this the command line to regenerate on a merge conflict is as simple as:

./gradlew generateTransportVersion --resolve-conflict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged :Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v8.18.8 v8.19.5 v9.0.8 v9.1.5 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants