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 MiqTempfile initialize kwargs error #198

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

agrare
Copy link
Member

@agrare agrare commented Sep 19, 2024

Tempfile takes a **options parameter which we were passing in as splat-ed positional parameters causing this error:

>> MiqTempfile.new("test", :encoding => 'ascii-8bit')
/usr/lib/ruby/3.1.0/tempfile.rb:134:in `initialize': wrong number of arguments (given 3, expected 0..2) (ArgumentError)
	from /home/grare/adam/src/manageiq/manageiq-smartstate/lib/miq_tempfile.rb:10:in `new'
	from /home/grare/adam/src/manageiq/manageiq-smartstate/lib/miq_tempfile.rb:10:in `initialize'

With this change applied:

>> MiqTempfile.new("test", :encoding => 'ascii-8bit')
=> #<File:/var/www/miq_tmp/test20240919-14037-7833j7>

ManageIQ/manageiq-providers-openstack#890

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.

Should we add specs too? (not sure it's worth it)

FWIW, CI only shows support for 3.0 and 3.1, so this should be fine. Also this is only called from one place in our entire org and it's right in this gem.

@agrare
Copy link
Member Author

agrare commented Sep 19, 2024

Should we add specs too? (not sure it's worth it)

Yeah I started looking at this but I don't know that I could show the failure in a spec without actually calling Tempfile.new and hitting the filesystem

Also this is only called from one place in our entire org and it's right in this gem.

Interesting maybe we could drop this and just use Tempfile normally in the caller

@Fryguy
Copy link
Member

Fryguy commented Sep 19, 2024

Also this is only called from one place in our entire org and it's right in this gem.

Interesting maybe we could drop this and just use Tempfile normally in the caller

Yeah, I'm not sure. I think the idea, based on the comment, was to have a single place to defined the /var/www/miq_tmp dir and be sure all callers are using it consistently, but the path is all over the code base.

@agrare
Copy link
Member Author

agrare commented Sep 19, 2024

Right the path is referenced in a number of places but Openstack SSA seems to be the only place actually using it, the rest of those are around configuring a disk (appliance_console) or monitoring the disk usage.

Based on the original commit message

    OpenStack fleecing: utilize extended temp storage.
    
    If additional temp storage has been added to the appliance - via appliance console -
    the OpenStack fleecing code will use it when downloading image contents.

It seems like the purpose of this class was to use this directory if it was configured, not just if it existed. Maybe somewhere along the line we pre-created the directory even if a disk wasn't mounted? Either way even back then it seems openstack ssa was the only caller of this class.

@agrare
Copy link
Member Author

agrare commented Sep 19, 2024

It seems like on an appliance we will always have a /var/www/miq_tmp mountpoint https://github.com/ManageIQ/manageiq-appliance-build/blob/master/kickstarts/partials/main/disk_layout.ks.erb#L7 so the "if /var/www/miq_tmp exists" doesn't make sense?

@Fryguy
Copy link
Member

Fryguy commented Sep 19, 2024

It seems like on an appliance we will always have a /var/www/miq_tmp mountpoint https://github.com/ManageIQ/manageiq-appliance-build/blob/master/kickstarts/partials/main/disk_layout.ks.erb#L7 so the "if /var/www/miq_tmp exists" doesn't make sense?

I think the backup is more about non-appliance development and possibly just a safety net - better to have a backup than try to use a non-existent dir.

@Fryguy Fryguy merged commit d8d2bd4 into ManageIQ:master Sep 19, 2024
4 checks passed
@Fryguy
Copy link
Member

Fryguy commented Sep 19, 2024

Merging anyway cause this fixes a bug. I am very curious how this is supposed to work on containerized though.

@agrare agrare deleted the fix_miq_tempfile_kwargs branch September 19, 2024 14:50
agrare added a commit that referenced this pull request Sep 19, 2024
Fixed:
- Fix MiqTempfile initialize kwargs error (#198)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants