-
Notifications
You must be signed in to change notification settings - Fork 897
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
Only store the hostname if the hostname is valid #16913
Conversation
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.
Given the comment on the validation, it might be better to fix this in two separate steps.
For this bug fix (which can't rely on a migration for backport reasons) I think we should fix the issue closer to where it is happening. So check for hostname validity in embedded ansible, central admin and wherever else we use it.
Then in a separate effort, only meant for master, we can add a migration and a validation to fix the issue in the table.
app/models/miq_server.rb
Outdated
@@ -33,6 +33,8 @@ class MiqServer < ApplicationRecord | |||
|
|||
scope :with_zone_id, ->(zone_id) { where(:zone_id => zone_id) } | |||
|
|||
validates :hostname, :allow_nil => true, :format => {:with => MoreCoreExtensions::StringFormats::RE_HOSTNAME, :multiline => true} |
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 this will fail save calls for unrelated changes if we have a record in the database with an invalid hostname already.
I would rather have a migration that removes invalid hostnames from the miq_servers table.
On retrieve, return the hostname only if it is valid https://bugzilla.redhat.com/show_bug.cgi?id=1537566
62a742e
to
287f25d
Compare
Checked commit bdunne@287f25d with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
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.
This looks good to me.
Can you also create a migration to remove invalid hostnames (only for master, of course).
Only store the hostname if the hostname is valid (cherry picked from commit 27e646c) https://bugzilla.redhat.com/show_bug.cgi?id=1550732
Fine backport details:
|
Only store the hostname if the hostname is valid (cherry picked from commit 27e646c) https://bugzilla.redhat.com/show_bug.cgi?id=1550730
Gaprindashvili backport details:
|
Only store the hostname if the hostname is valid (cherry picked from commit 27e646c) https://bugzilla.redhat.com/show_bug.cgi?id=1550732
https://bugzilla.redhat.com/show_bug.cgi?id=1537566