-
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
Don't format PersistentVolume-capacity as bytes #17278
Don't format PersistentVolume-capacity as bytes #17278
Conversation
There are other tables that have `capacity` columns that are formatted as bytes. This newer column is serialized and will blow when trying to apply this formatting to it. Since the existing way of mapping columns to formats does not take table name into account, we need a temporary way to override this for colliding column names. This can later be reworked so all mapped formats will be qualified in some way. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1563861
59d6a73
to
32c9f02
Compare
@imtayadeway Is this gaprindashvili/yes? |
@Fryguy ah yes, I believe it should be (corrected). |
db/fixtures/miq_report_formats.yml
Outdated
:formats_by_path: | ||
:PersistentVolume-capacity: null | ||
:ContainerVolumeKubernetes-capacity: null | ||
:ContainerVolume-capacity: null |
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.
Minor, but this should be alphabetized.
default_format_for(col, sfx, dt) | ||
end | ||
|
||
def self.default_format_for(column, suffix, datatype) |
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.
Is this not use anywhere else?
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.
Doesn't look like it! I preferred to inline it rather than change the signature in this case
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.
referenced only in manageiq proper:
app/models/miq_report/formats.rb
app/models/miq_report/formatting.rb
app/models/miq_report.rb
spec/models/miq_report/formats_spec.rb
updated -- those use default_format_for_path
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.
@kbrock are you sure those are all hits, and not hitting default_format_for_path
?
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 reference (after my change):
tim@tim-thinkpad:~/src/manageiq$ ag "default_format_for"
spec/models/miq_report/formats_spec.rb
20: describe '.default_format_for_path' do
32: subj = described_class.default_format_for_path("ChargebackVm-#{name}", datatype.first)
48: expect(described_class.default_format_for_path("ContainerVolume-capacity", :text)).to be_nil
49: expect(described_class.default_format_for_path("PersistentVolume-capacity", :text)).to be_nil
50: expect(described_class.default_format_for_path("ContainerVolumeKubernetes-capacity", :text)).to be_nil
app/models/miq_report.rb
134: :default_format => Formats.default_format_for_path(path, data_type),
app/models/miq_report/formatting.rb
15: format_name ||= MiqReport::Formats.default_format_for_path(col, nil)
app/models/miq_report/formats.rb
22: def self.default_format_for_path(path, datatype)
36: format = FORMATS[default_format_for_path(path, datatype)]
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.
No hits in the classic UI also, which is the only other place I might expect to find 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.
Looks good to me. would like a second opinion.
was asked in gitter about other "capacity" columns and data types:
|
32c9f02
to
9a33943
Compare
9a33943
to
c858e35
Compare
@@ -43,5 +43,12 @@ | |||
end | |||
end | |||
end | |||
|
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.
Since this spec is pretty small, perhaps it would be good to add another case that tests when there isn't the specific override. Just to be safe.
Checked commits imtayadeway/manageiq@8e4918c~...4c32131 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
db/fixtures/miq_report_formats.yml
Outdated
@@ -1,7 +1,10 @@ | |||
--- | |||
:defaults_and_overrides: | |||
:formats_by_path: | |||
:ContainerVolume-capacity: null | |||
:ContainerVolumeKubernetes-capacity: null |
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.
just FYI , ContainerVolumeKubernetes subclass is completely unused.
(I tried to drop it, #15646, we concluded I should also do a migration but never got around to it)
…rt-format Don't format PersistentVolume-capacity as bytes (cherry picked from commit ad11173) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1566530
Gaprindashvili backport details:
|
There are other tables that have
capacity
columns that are formattedas bytes. This newer column is serialized and will blow when trying to
apply this formatting to it. Since the existing way of mapping columns
to formats does not take table name into account, we need a temporary
way to override this for colliding column names. This can later be
reworked so all mapped formats will be qualified in some way.
Screens:
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1563861
NOTE: I did some refactoring to make this easier - probably best viewed as separate commits