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

Fix VimPerformanceOperatingRanges after upgrade. #13821

Merged
merged 1 commit into from
Mar 1, 2017

Conversation

Fryguy
Copy link
Member

@Fryguy Fryguy commented Feb 8, 2017

After the backport of #12792 and #13700, a user can be in a state where
their VimPerformanceOperatingRanges are inconsistent. Although it
doesn't really harm anything, this data migration makes it consistent
once again.

@gtanzillo Please review.

After the backport of ManageIQ#12792 and ManageIQ#13700, a user can be in a state where
their VimPerformanceOperatingRanges are inconsistent.  Although it
doesn't really harm anything, this data migration makes it consistent
once again.
@miq-bot
Copy link
Member

miq-bot commented Feb 8, 2017

Checked commit Fryguy@ee49af0 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 2 offenses detected

db/migrate/20170207215322_fix_vpor_time_profile_ids.rb

spec/migrations/20170207215322_fix_vpor_time_profile_ids_spec.rb

  • ❗ - Line 33, Col 7 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM, just have one question.

tp.profile[:days].try(:sort) == ALL_DAYS &&
tp.profile[:hours].try(:sort) == ALL_HOURS &&
tp.profile[:tz] == DEFAULT_TZ
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need `tp.profile_type == "global" here to ensure it's the default one that we match?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not in the usual default check, but I can add it in... Can't hurt.

@Fryguy
Copy link
Member Author

Fryguy commented Mar 1, 2017

@gtanzillo Bump? 🐢

@gtanzillo gtanzillo added this to the Sprint 56 Ending Mar 13, 2017 milestone Mar 1, 2017
@gtanzillo gtanzillo merged commit 58fbd03 into ManageIQ:master Mar 1, 2017
@durandom
Copy link
Member

@Fryguy this migration fails for me when running on an large mbu db:

❯ DB_SUFFIX=mbu_2 rails db:migrate
** master - DB vmdb_development_mbu_2 on localhost
** Using session_store: ActionDispatch::Session::MemCacheStore
** master - DB vmdb_development_mbu_2 on localhost
== 20170207215322 FixVporTimeProfileIds: migrating ============================
-- Updating old VimPerformanceOperatingRanges to the default TimeProfile

[36, 45] in /Users/hild/src/manageiq/db/migrate/20170207215322_fix_vpor_time_profile_ids.rb
   36:     elsif TimeProfile.any?
   37:       # User has not used an old version where TimeProfiles were corrected,
   38:       # so the TimeProfile-less records just need to be updated to the default TP
   39:       say_with_time("Updating old VimPerformanceOperatingRanges to the default TimeProfile") do
   40:         byebug
=> 41:         VimPerformanceOperatingRange.where(:time_profile_id => nil).update_all(:time_profile_id => TimeProfile.default.id)
   42:       end
   43:     end
   44:   end
   45: end
(byebug) TimeProfile.default
nil
(byebug) FixVporTimeProfileIds::TimeProfile.default
nil

But on rails console this is not nil?!

[7] pry(main)> require Rails.root.join('db/migrate/20170207215322_fix_vpor_time_profile_ids.rb')
=> true
[9] pry(main)> FixVporTimeProfileIds::TimeProfile.default
  FixVporTimeProfileIds::TimeProfile Load (1.6ms)  SELECT "time_profiles".* FROM "time_profiles" WHERE (id >= 0 AND id <= 999999999999) AND "time_profiles"."rollup_daily_metrics" = $1  [["rollup_daily_metrics", true]]
  FixVporTimeProfileIds::TimeProfile Inst Including Associations (5.4ms - 1rows)
=> #<FixVporTimeProfileIds::TimeProfile:0x007ff264dd3318
 id: 1,
 description: "UTC",
 profile_type: "global",
 profile_key: nil,
 profile: {:tz=>"UTC", :days=>[0, 1, 2, 3, 4, 5, 6], :hours=>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]},
 created_on: Thu, 16 Mar 2017 11:22:57 UTC +00:00,
 updated_on: Thu, 16 Mar 2017 11:22:57 UTC +00:00,
 rollup_daily_metrics: true>
=> 1

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.

4 participants