Skip to content
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

Merged

Conversation

imtayadeway
Copy link
Contributor

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.

Screens:

manageiq_reports_-_2018-04-10_12 07 22

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

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
@imtayadeway imtayadeway force-pushed the fix-pers-vol-capacity-report-format branch from 59d6a73 to 32c9f02 Compare April 10, 2018 19:34
@Fryguy
Copy link
Member

Fryguy commented Apr 10, 2018

@imtayadeway Is this gaprindashvili/yes?

@imtayadeway
Copy link
Contributor Author

@Fryguy ah yes, I believe it should be (corrected).

:formats_by_path:
:PersistentVolume-capacity: null
:ContainerVolumeKubernetes-capacity: null
:ContainerVolume-capacity: null
Copy link
Member

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)
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@kbrock kbrock Apr 10, 2018

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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)]

Copy link
Contributor Author

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

Copy link
Member

@kbrock kbrock left a 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.

@kbrock
Copy link
Member

kbrock commented Apr 10, 2018

was asked in gitter about other "capacity" columns and data types:

column datatype
Hardware.disk_capacity bigint
MiqScsiLuns.capacity bigint
PersistentVolumeClaim text
ContainerVolume text

@imtayadeway imtayadeway force-pushed the fix-pers-vol-capacity-report-format branch from 32c9f02 to 9a33943 Compare April 10, 2018 20:39
@imtayadeway imtayadeway force-pushed the fix-pers-vol-capacity-report-format branch from 9a33943 to c858e35 Compare April 10, 2018 20:48
@@ -43,5 +43,12 @@
end
end
end

Copy link
Member

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.

@miq-bot
Copy link
Member

miq-bot commented Apr 10, 2018

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
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@Fryguy Fryguy merged commit ad11173 into ManageIQ:master Apr 11, 2018
@Fryguy Fryguy added this to the Sprint 84 Ending Apr 23, 2018 milestone Apr 11, 2018
@@ -1,7 +1,10 @@
---
:defaults_and_overrides:
:formats_by_path:
:ContainerVolume-capacity: null
:ContainerVolumeKubernetes-capacity: null
Copy link
Contributor

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)

simaishi pushed a commit that referenced this pull request Apr 12, 2018
…rt-format

Don't format PersistentVolume-capacity as bytes
(cherry picked from commit ad11173)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1566530
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 9dbcf7914405a091cd55a8c38a82200b677054d2
Author: Jason Frey <[email protected]>
Date:   Tue Apr 10 21:57:38 2018 -0400

    Merge pull request #17278 from imtayadeway/fix-pers-vol-capacity-report-format
    
    Don't format PersistentVolume-capacity as bytes
    (cherry picked from commit ad111733f385518df6e95773825955db4da38b9f)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1566530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants