-
Notifications
You must be signed in to change notification settings - Fork 991
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
Fixes #31521 - structured plugin information in statuses API #8207
Conversation
Issues: #31521 |
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.
👍 for an explicit way. I do wonder about API compatibility here.
@ofedoren mind taking a look?
app/services/ping.rb
Outdated
name: plugin.name, | ||
version: plugin.version, | ||
author: plugin.author, | ||
description: plugin.description, |
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.
Curious your thoughts on why send out author and description on a status API?
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.
it was there before
foreman/app/registries/foreman/plugin.rb
Lines 233 to 235 in da7bca2
def to_s | |
"Foreman plugin: #{id}, #{version}, #{author}, #{description}" | |
end |
and I didn't want to loose that data.
personally I only need id
and version
:)
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.
Well, I doubt that someone would require those data... On hammer side we only show name and version anyway.
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.
Speaking of name… the Foreman::Plugin
object has both, name
and id
attributes, but both seem to be the same?
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.
Hm.. what could be id of the plugin except its name anyway?.. AFAIK it's not possible to install two versions of a plugin and use both at the same time. I'd expect that id == name.
But apparently there can be such thing as id != name:
foreman/app/registries/foreman/plugin.rb
Lines 96 to 98 in 036bbe6
plugin = new(id) | |
if (gem = Gem.loaded_specs[id.to_s]) | |
plugin.name gem.name |
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.
Yeah, name is the name of the gem, while id is what you put in when you register the plugin, so I'd actually say the id is the name and the name is worthless 😅
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.
That said, let's make the data {name: plugin.id, version: plugin.version}
and be done with it?
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.
@evgeni +1
we could also add it as a new entry, "plugin_data" or whatever, to keep it backwards compatible |
this will require changes to hammer, as it actually splits that thing itself: theforeman/hammer-cli-foreman#553 takes care of this |
c33dd60
to
786c9db
Compare
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.
@evgeni, surely this looks and is better to work with, thanks :)
@ekohl, about backward compatibility: currently information about plugins is being sent as an array of strings (which was quite dumb from my side to let it that way) as
{ "plugins" =>
[ "plugin_a, version, etc",
"plugin_b, version, etc"
]
}
To actually save compatibility we would need to add a new entry such as plugins_structured
with this new data. This wouldn't break any automation (if there is any for such response), but will lead to data duplicity. Which is not so horrible for such amount, but.. is not so okay also.
I'd take a risk and change to @evgeni's version, but if others are okay with solution above I'm totally okay with having both entries.
app/services/ping.rb
Outdated
name: plugin.name, | ||
version: plugin.version, | ||
author: plugin.author, | ||
description: plugin.description, |
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.
Well, I doubt that someone would require those data... On hammer side we only show name and version anyway.
I too would prefer not to duplicate the data, unless someone really wants that :) |
05695ac
to
02d468e
Compare
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, @evgeni :) Can't merge though :(
@@ -365,7 +365,12 @@ def test_register_status_extension | |||
api: { | |||
version: Apipie.configuration.default_version, | |||
}, | |||
plugins: [Foreman::Plugin.find(:foo)], | |||
plugins: [ |
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.
To be more accurate, I think it should be something like:
...
plugin = Foreman::Plugin.find(:foo)
...
plugins: [ { name: plugin.id, version: plugin.version } ]
...
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 think it's a good practice to have exact values in your expected results. Otherwise you may miss a situation where a property may be nil for example. Essentially there is no assertion then.
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 had the dynamic version before, and then had the same thought as Ewoud: lets test explicit values.
@tbrisker can I ask you what you think about the API compatibility here? |
@evgeni, now test fails are related :( |
Hah, that's because the version is taken from the Gem, but in the tests we mock the plugin and have no gem. Will have a thought how to fix that on Monday. |
514236b
to
a46f631
Compare
The plugins info was introduced in Foreman 1.24. That's 3 versions already. I can imagine people use /ping endpoint to monitor Foreman. However I don't think people would monitor plugin versions specifically. I think it's a safe change for the better, but it is breaking backwards compatibility. If we decide to go with the duplication of the information, can we deprecate the existing way in release notes and drop it in Foreman 3.0? The problem is, we can't easily display the deprecation to the user, since we have no idea if they use this piece of the response. The other option is to be less dogmatic, ask on community or use RSS notification and drop it in e.g. one minor release if no one objects. |
[test foreman] |
Looks unrelated?! |
Yeah, it is unrelated. See https://projects.theforeman.org/issues/31533 |
[test foreman] |
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 fine with modifying the existing API with an upgrade warning in this case. One could even argue that the previous response was a bug, calling to_s
on the plugins instead of returning the hash of installed plugins. Perhaps we could also keep the authors and description so we can reuse it in the ui about page, but that's not crucial.
I can add the details back in (my original version had them, but the feedback so far was "nobody needs that"). By upgrade warning you mean release notes in the docs? Can open a PR for that. |
I'm not sure if the about page should use ping. It reaches out to all backend services so if all you need to do is retrieve installed plugins, it's too heavy. |
good point, perhaps in the future we would want to use it so you can see that status in a nice ui, but we're getting ahead of ourselves. we can always add it later. |
AFAIU we use ping on the about page already.. Or you meant that the current way is not so good? |
upgrade warning in theforeman/theforeman.org#1752 |
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.
Thanks @evgeni, @ofedoren - can you take a look at the hammer side please? I'm assuming we'll need to merge theforeman/hammer-cli-foreman#553 at the same time as this one?
@tbrisker, sure thing. |
Technically? Yes. Realistically, no, as hammer status (vs hammer ping) is IIRC not part of the pipelines ;) |
Was this intended for another PR? |
No, it was an answer to tomers question whether it needs to go together with the hammer change |
Ok, but the Katello pipeline does call |
|
hammer is merged now. |
Thanks @evgeni et al! |
Foreman 2.4 [1] started to return plugin information in a structured way, let's be nice and support that too :-) [1] theforeman/foreman#8207
Foreman 2.4 [1] started to return plugin information in a structured way, let's be nice and support that too :-) [1] theforeman/foreman#8207
No description provided.