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

fixes #12730 - removing the fakeFS gem #2962

Closed
wants to merge 1 commit into from

Conversation

unorthodoxgeek
Copy link
Member

No description provided.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 9ef4fee must be in the format fixes #redmine_number - brief description.

If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project.

More guidelines are available on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@domcleal
Copy link
Contributor

domcleal commented Dec 7, 2015

Please add info about the "issues" on the ticket so we have it for future reference.

@domcleal
Copy link
Contributor

domcleal commented Dec 7, 2015

Looking at the test that fakefs has been removed from, it looks like this will now hit the filesystem rather than being mocked, leaving this stray file behind in a top-level dir. It should probably be written to use a secure temp file if it can't be mocked.

@unorthodoxgeek
Copy link
Member Author

@domcleal - now removing the files this test has created.

@domcleal
Copy link
Contributor

domcleal commented Dec 7, 2015

Yeah, that's a bit messy and still leaves the test possibly interfering with development/production environments or vice-versa. It would be safer to replace fakefs with a temporary directory or full mocking of the File calls instead of interacting with the real Rails public path.

I think I'd prefer to see this run in a mktmpdir block and pass the temporary path into the method under test, with it defaulting to the prod directory for non-test usage. The file handle should probably be a regular Tempfile.

@unorthodoxgeek
Copy link
Member Author

@domcleal - this is the mother of all nitpicks, those files do not interfere with anything on development, they can't do that. Why complicate this insignificant change for the remotest of remote possibilities of interference with a development environment?

I see no upside in the changes you suggested, while merging this ASAP releases foreman-docker from its current state of limbo.

@domcleal
Copy link
Contributor

domcleal commented Dec 8, 2015

Tests shouldn't be writing to the filesystem like this, I stand by my comment. It should be correctly stubbed (as it was before) or moved to a temporary dir.

@unorthodoxgeek
Copy link
Member Author

@domcleal - done. pointless, IMHO, but done.

if I'm already at it, the way we're saving the files seems like a VERY bad idea. I'd consider using something like https://github.com/carrierwaveuploader/carrierwave or similar libraries. In foreman instances which run across multiple hosts behind a Load Balancer, those files will exist on the host which first created them, but won't exist on other hosts, leading to round-robin 404 errors, which might be funny to say, but isn't funny to debug 😄

I'd consider adding a feature request on this, which will allow us to configure an S3 bucket or similar stuff for other cloud providers, so multi-host foreman instances can work (and also, single hosts which don't want to rely on the host's file system)

begin
auth = AuthSourceLdap.new
FileUtils.mkdir_p(File.join(Rails.root, 'tmp'))
file = File.open("#{Rails.root}/tmp/out.txt", 'wb+')
Copy link
Contributor

Choose a reason for hiding this comment

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

This can also go straight into the temp_dir too now, FWIW.

Edit: saves having to delete it separately.

@domcleal
Copy link
Contributor

domcleal commented Dec 8, 2015

Indeed, all good points - please do file it, it's worth doing.

@ohadlevy
Copy link
Member

ohadlevy commented Dec 8, 2015 via email

auth.send(:store_avatar, file_string)
begin
auth = AuthSourceLdap.new
FileUtils.mkdir_p(File.join(Rails.root, 'tmp'))
Copy link
Contributor

Choose a reason for hiding this comment

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

This line's unused now the file creation was moved.

@unorthodoxgeek
Copy link
Member Author

@domcleal - can we merge this?

@domcleal
Copy link
Contributor

domcleal commented Dec 8, 2015

Merged as a4766c9, thanks @unorthodoxgeek.

@domcleal domcleal closed this Dec 8, 2015
@unorthodoxgeek unorthodoxgeek deleted the 12730 branch December 8, 2015 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants