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 #12894 - remove 'users' from org update params #5792
Conversation
@@ -62,6 +62,7 @@ def show | |||
param :redhat_repository_url, String, :desc => N_("Red Hat CDN URL") | |||
param_group :resource, ::Api::V2::TaxonomiesController | |||
def update | |||
params.delete(:users) if params[:users] # Cannot PUT a GET result as the UI does |
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.
Do you even remember the point of this?
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 suggested that users be removed from the attr_accessible on the taxonomy but apparently a usage of Organization.new() is required. Trying to update an org w/ a users param fails with the error. The katello UI gets org json, modifies some of it, then PUTs it back. Foreman UI doesn't use API so they don't encounter this.
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.
ahhh when we update the cdn url in the UI i see, I should have read the issue!
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.
Wondering if we should add a comment so that we can remove this line when foreman moves to strong_params.
I'm still getting an error: "ERF42-6434 [Foreman::Exception]: You cannot set an organization's parent_id. This feature is disabled." |
I wonder if it would make sense to just update the cdn url here: https://github.com/Katello/katello/blob/master/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/manifest/manifest-import.controller.js#L152 instead of PUT'ing the whole object. |
The parent_id is likely from this PR theforeman/foreman#3094 |
f8de045
to
a6b8624
Compare
@jlsherrill @daviddavis - updated to remove json fields on GET /organizations and added comment there. |
delete org.users; | ||
delete org.parent_id; | ||
delete org.parent_name; | ||
return org; |
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.
would you be opposed to building up what we need (and calling Organization.update()) rather than deleting what we don't?
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 originally was just going to modify the org update from the manifests page to just send redhat_repository_url. However, any bastion page that updates an org would end up sending the GET values and would also break (as I discovered in one of my local plugins).
To be honest, I first tried to fix this in foreman itself (not allow 'users') but that was nack'ed. The parent params should also not be present in katello.
Thus! This seemed like the safest thing all around.
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.
right, walden hit this very similarly with hosts recently and I liked the approach he ended up taking much better. Editing the object in the GET seems really hacky (or even more hacky) and means if we ever actually need to use users, parent_id or parent_name, we can't.
I don't mean to be a stickler, but this just seems like the wrong approach.
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.
@jlsherrill - That looks good, I'll change PR to that pattern.
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.
In the controller all it would be would be something like changing the line here:
https://github.com/Katello/katello/blob/master/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/manifest/manifest-import.controller.js#L152
from
organization.$update(function (response) {
to
Organization.update({'id': organization.id, 'redhat_cdn_url': organization.redhat_cdn_url}, function() {
It may be slightly more complex than that, but not much
@jlsherrill - So I updated the call to Organization.update() call to just send up the id and redhat_repository_url. This results, however, in
You'll notice that in the controller the redhat_repository_url is handled specially and then 'super' is called. Perhaps when we switch to PATCH this will work? Thoughts? |
@thomasmckay can you paste your code? What you're seeing doesn't make a whole lot of sense given the foreman controller just uses .update_attributes. I tried this myself doing: PUT /api/v2/organizations/1/ and it seemed to work fine. |
@jlsherrill - You're right! That error was due to the org having "mismatches" for domains and environments. I'll update this PR shortly. |
a6b8624
to
68b4ede
Compare
68b4ede
to
501ecbf
Compare
[test] |
Updated this PR to only send redhat_repository_url for update. + fixed push of global success message + removed unused var
501ecbf
to
54f872d
Compare
ACK |
fixes #12894 - remove 'users' from org update params
No description provided.