Fixes #34026 - authorize puppet reports via Proxy#8958
Fixes #34026 - authorize puppet reports via Proxy#8958ezr-ondrej merged 1 commit intotheforeman:developfrom
Conversation
|
Issues: #34026 |
|
The reporter says it did NOT help: https://community.theforeman.org/t/no-smart-proxy-server-found-on-foreman-puppet-example-com-and-is-not-in-trusted-hosts/26215 Any clue? @ShimShtein and @tbrisker ? |
| before_action :compatibility, :only => :create | ||
|
|
||
| add_smart_proxy_filters :create, :features => proc { ConfigReportImporter.authorized_smart_proxy_features } | ||
| add_smart_proxy_filters :facts, :features => proc { Foreman::Plugin.fact_importer_registry.fact_features } |
There was a problem hiding this comment.
the endpoint here is called :create, not :facts. Also i'm not sure if there are plugins that import reports but don't have a fact importer, especially now that all fact importers are in core?
There was a problem hiding this comment.
Oh copy and paste error. Good find.
I do not understand why this endpoint is used, normally /v2/host/xxx/facts should be used. But it should save the same purpose I guess and the change I refer to should should change both.
f70778d to
310d21e
Compare
|
I asked gvde to try again, it could not work since I had the typo there. |
Yes. Works for me now. Applied the patch, then restarted Config reports still coming in from my puppet only smart proxy... |
| before_action :compatibility, :only => :create | ||
|
|
||
| add_smart_proxy_filters :create, :features => proc { ConfigReportImporter.authorized_smart_proxy_features } | ||
| add_smart_proxy_filters :create, :features => proc { Foreman::Plugin.fact_importer_registry.fact_features } |
There was a problem hiding this comment.
Why do we use fact features to allow config reports?
There was a problem hiding this comment.
Right, I accidentally mis-read the #5010 patch I thought it was about reports while it was about facts. This is wrong, need to dig deeper.
|
DO NOT MERGE |
|
This appears like some issue with class overriding after we pulled all report importers into core. Without Ansible: With Ansible plugin: |
I've marked it as a draft to make that clear. You can do the same thing: there's a well hidden link in the Reviewers block on the top right. |
310d21e to
5b1e10e
Compare
|
Thanks, I figured it out. The problem was that Ansible plugin simply includes module into ConfigReportImporter and overrides the So the fix is to remove overriding of the Puppet and Ansible are both overriding the This have never worked, the moment you installed either Chef or Ansible (Salt does appear to implement reports differently), Puppet feature was always removed from the list. Weird that we only got this reported recently, looks like not many people are using more than one configuration management. Or I dunno why we see it now. So with this patch in core, the following changes needs to be done in order to fully fix this:
|
|
It sounds like we have a regression and shortest term fix is to use |
Yes but I prefer to change Chef to use Going to do Chef one as well. |
|
Here is the chef PR: theforeman/foreman_chef#98 I am going to deprecate the ConfigReportImporter register method just in case there is something still utilizing it. |
5b1e10e to
3ac7e06
Compare
|
I was mostly concerned with cherry picks and compatibility. I haven't looked at the exact details since I just came back from PTO. |
|
Hmm I could actually call class methods from one of the classes so it is always stored just once: def self.authorized_smart_proxy_features
ReportImporter.authorized_smart_proxy_features
end
def self.register_smart_proxy_feature(feature)
ReportImporter.register_smart_proxy_feature(feature)
end
def self.unregister_smart_proxy_feature(feature)
ReportImporter.unregister_smart_proxy_feature(feature)
endThis is backport-friendly, however, Ansible still needs a patch because currently it overrides the |
3ac7e06 to
1712b92
Compare
| end | ||
| end | ||
|
|
||
| ReportImporter.register_smart_proxy_feature("Puppet") |
There was a problem hiding this comment.
Should this be in an initializer? I wonder how it would deal with code reloads.
There was a problem hiding this comment.
It should behave fine, but it is ugly
| def self.register_smart_proxy_feature(feature) | ||
| ReportImporter.register_smart_proxy_feature(feature) | ||
| end | ||
|
|
||
| def self.unregister_smart_proxy_feature(feature) | ||
| ReportImporter.unregister_smart_proxy_feature(feature) | ||
| end |
There was a problem hiding this comment.
Perhaps I'm missing something, but ConfigReportImporter inherits from ReportImporter so isn't this redundant?
There was a problem hiding this comment.
It is not actually, because the definition of the parent method means it's defined on class, so you'd define another array on ConfigReportImporter tho this issue would appear in any of the descendants. That is one of the reasons to not have registries in a parent classes.
There was a problem hiding this comment.
@lzap could we deprecate these then and disable it's usage through ConfigReportImporter?
There was a problem hiding this comment.
Ah right, that's why I dislike static methods with state.
|
|
||
| def self.register_smart_proxy_feature(feature) | ||
| @authorized_smart_proxy_features = (authorized_smart_proxy_features + [feature]).uniq | ||
| @authorized_smart_proxy_features = (authorized_smart_proxy_features + [feature.freeze]).uniq |
There was a problem hiding this comment.
didn't you want to freeze the array instead? You're creating new one here, so it would be fine and it would not allow touching the array anywhere else, then through this method. But freezing the strings sounds weird, are we worried someone is changing the actual strings?
Signed-off-by: Lukas Zapletal <lzap+git@redhat.com>
1712b92 to
67fbecc
Compare
ezr-ondrej
left a comment
There was a problem hiding this comment.
I do not totally agree with this solution, but as a temporary workaround untill we have the new sollution for Reports, I'm ok 👍
|
[test foreman][test katello] |
|
Thanks @lzap 👍 |
|
Shall this be cherry-picked into 3.1? |
|
Just run into the issue myself with 3.1. Would be nice if it could be included in the next release. Just a friendly reminder. :) |
|
Thanks, sorry late on my GH inbox. |
The patch #5010 changed how fact importer features are registered, the change was made in the host controller but not in the API controller. Therefore uploading reports via host controller works fine, however, using the API endpoint does not authorize automatically as the feature is not found.