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

Clean Azure image names #198

Merged
merged 1 commit into from
Jun 6, 2018
Merged

Clean Azure image names #198

merged 1 commit into from
Jun 6, 2018

Conversation

djberg96
Copy link
Contributor

@djberg96 djberg96 commented May 7, 2018

Due to a quirk of File.dirname, the Azure provider can end up with leading "./" in the image name. This looks dumb and should be fixed.

Should be merged in conjunction with ManageIQ/manageiq-providers-azure#240

@@ -0,0 +1,12 @@
class AzureNormalizeImageName < ActiveRecord::Migration[5.0]
class Vm < ActiveRecord::Base

Choose a reason for hiding this comment

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

Should this be class VmOrTemplate < ActiveRecord::Base?


def up
say_with_time("Updating Azure template name") do
Vm.where(:type => "ManageIQ::Providers::Azure::CloudManager::Template")

Choose a reason for hiding this comment

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

Should this be VmOrTemplate.where(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Works either way afaik, since I'm specifying the type.

Choose a reason for hiding this comment

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

I think templates will not be returned by Vm.where(), I think it requires VmOrTemplate. Can you check on the console?

Vm.where(:type => "ManageIQ::Providers::Azure::CloudManager::Template")
.update_all("name = regexp_replace(name, '^./', '')")
end
end

Choose a reason for hiding this comment

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

do you need a down for rollback? Or a change instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not something that can be rolled back consistently I don't think, so no.

Choose a reason for hiding this comment

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

I think it is risky not to add one and writing one isn't a large effort. One of the scenarios I could see as being a problem is if the user does not back up the DB before an upgrade and the upgrade has to be undone.

@djberg96
Copy link
Contributor Author

@bronaghs ok, changed it to VmOrTemplate.

@Fryguy
Copy link
Member

Fryguy commented Jun 5, 2018

Should be merged in conjunction with ManageIQ/manageiq-providers-azure#239

except that's an issue and not a PR...do you have a PR on the other side?

Copy link
Member

@Fryguy Fryguy left a comment

Choose a reason for hiding this comment

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

LGTM

@Fryguy
Copy link
Member

Fryguy commented Jun 5, 2018

Waiting on merge until the other side is ready

@bronaghs
Copy link

bronaghs commented Jun 5, 2018

@Fryguy - I had asked Dan to add a down method or replace the up with a change method. Do you not think this is necessary?

Use VmOrTemplate instead of Vm.

Added down method, added specs.
@djberg96
Copy link
Contributor Author

djberg96 commented Jun 5, 2018

@bronaghs @Fryguy ok, added a down method. At first I didn't think it was practical, but then I remembered this only affects unmanaged images, so I can check the uid_ems.

@miq-bot
Copy link
Member

miq-bot commented Jun 5, 2018

Checked commit https://github.com/djberg96/manageiq-schema/commit/91d183c27cd0cf430a25e2734961020aad5ef762 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 4 offenses detected

db/migrate/20180507134810_azure_normalize_image_name.rb

@Fryguy Fryguy merged commit d0bdf22 into ManageIQ:master Jun 6, 2018
@Fryguy Fryguy added this to the Sprint 88 Ending Jun 18, 2018 milestone Jun 6, 2018
@Fryguy Fryguy self-assigned this Jun 6, 2018
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