`rake uploads:migrate_to_s3` needs some love

The uploads:migrate_to_s3 rake task could use some attention.

There is no GlobalSetting.use_s3?, but a GlobalSetting.use_s3 and the ENV variables have changed, as DISCOURSE_S3_BUCKET has been replaced by DISCOURSE_S3_UPLOAD_BUCKET.

https://github.com/discourse/discourse/blob/master/lib/tasks/uploads.rake#L231

I’m only a little bit sure that I know how to fix this, and I think that it’s fresh in @gerhard’s mind. :slight_smile:

1 Like
[1] pry(main)> GlobalSetting.use_s3
NoMethodError: undefined method `use_s3' for GlobalSetting:Class
Did you mean?  use_s3?

https://github.com/discourse/discourse/blob/c08b2ddecfaed0f0ab3e3b30743b55d5f5230fb2/config/discourse_defaults.conf#L170

The code in the rake task is still valid from what I can tell. Did you run into any specific problems that made you bring up the issues above?

2 Likes

uh. Hmm. I’ll try again.

I think I’m confused because it seems like it should be able to read those variables from SiteSettings and I don’t understand how the backup and upload buckets get defined from just the S3 bucket.

For GlobalSettings,

https://github.com/discourse/discourse/blob/4f5aebc33812a56c34e553bd18c0cfe7ddc4c3f4/config/discourse_defaults.conf#L7-L13

Only SiteSettings that are marked shadowed_by_global can be configured via the env. In this case, s3_upload_bucket isn’t.

https://github.com/discourse/discourse/blob/4f5aebc33812a56c34e553bd18c0cfe7ddc4c3f4/app/models/site_setting.rb#L129-L131

Closing this as this isn’t a bug.

5 Likes