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

Use string version internally for PluginDescriptor #100713

Merged

Conversation

williamrandolph
Copy link
Contributor

Since the work to use a String version in the plugin descriptor is pretty simple, I'm putting it in its own PR and saving the work changing PluginDescriptor#getElasticsearchVersion to return a string for a follow-up PR.

@williamrandolph williamrandolph added >non-issue :Core/Infra/Core Core issues without another label v8.12.0 labels Oct 11, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Oct 11, 2023
@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Contributor

@ldematte ldematte left a comment

Choose a reason for hiding this comment

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

LGTM with one comment (using BWC_PLACEHOLDER_VERSION) which I'm very interested in since I want to do the same :)

Version.writeVersion(Version.fromString(elasticsearchVersion), out);
} catch (IllegalArgumentException e) {
// can't parse current version, so send placeholder
Version.writeVersion(BWC_PLACEHOLDER_VERSION, out);
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this solution; I was contemplating of doing something similar myself (we are solving basically the same problem in 2 places - #100746 - but I was wondering what version could be used. I was thinking Version.CURRENT. What made you choose a fixed one?
(I will update my PR to be consistent with yours afterwards)

Copy link
Member

Choose a reason for hiding this comment

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

I would use Version.current if possible, is there a reason it can't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is Version.CURRENT going to stick around indefinitely? I went with a placeholder because I wasn't sure if we were going to get rid of Version.CURRENT altogether at some point.

Copy link
Member

Choose a reason for hiding this comment

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

We do want to get rid of it. Perhaps we can defer what to do here because this still doesn't seem like a case we need to catch/send a fallback, as noted in my other comment on this block.

@@ -163,7 +163,7 @@ private static NodeInfo createNodeInfo() {
randomAlphaOfLengthBetween(3, 10),
randomAlphaOfLengthBetween(3, 10),
randomAlphaOfLengthBetween(3, 10),
VersionUtils.randomVersion(random()),
randomAlphaOfLengthBetween(3, 10),
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note for the record: I am using randomAlphaOfLengthBetween(6, 32) as a replacement for version (to cover "8.12.0" as well as a build hash). But it's just a note: I think every random "any string" have to work.

ldematte added a commit to ldematte/elasticsearch that referenced this pull request Oct 12, 2023
Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

Just a couple thoughts

Version.writeVersion(Version.fromString(elasticsearchVersion), out);
} catch (IllegalArgumentException e) {
// can't parse current version, so send placeholder
Version.writeVersion(BWC_PLACEHOLDER_VERSION, out);
Copy link
Member

Choose a reason for hiding this comment

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

I would use Version.current if possible, is there a reason it can't work?

@@ -106,6 +108,9 @@ public PluginDescriptor(
this.isLicensed = isLicensed;
this.isModular = isModular;
this.isStable = isStable;
this.builtWithSemanticVersion = Optional.ofNullable(elasticsearchVersion)
Copy link
Member

Choose a reason for hiding this comment

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

I get what you are trying to do, but I don't think this is something we need to worry about right now. Plugins cannot be built outside of an ES "semantic version", even for serverless. I think we should change this simply here for now (just assume a semantic version string), and figure out the best way to represent serverless plugins later when we are ready for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks to me like PluginUtils#verifyCompatiblity gets called even for the built-in module case, though. If the version field in the plugin descriptor starts getting built with an commit hash value (rather than a 8.x.y-SNAPSHOT value), it seems like validation will fail at that point.

Should I instead find a way to skip that verification for modules in serverless, or can I assume that serverless's plugin building code will always write a semantic version to the elasticsearch.version field of the plugin descriptor?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know about "always", but for the time being, the build won't change (we will continue to have the semantic version in the build). Note this isn't just plugin metadata, we have the semantic version in the file paths themselves. This is ok since it is completely local to a node; we don't actually care what the filenames are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the code path checking for non-semantic versions.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

@williamrandolph williamrandolph merged commit 96184dd into elastic:main Oct 17, 2023
@williamrandolph williamrandolph deleted the version/plugin-descriptor-internal branch October 17, 2023 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team test-update-serverless v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants