Thank you Jeff! No rush at all. I’m running the rake tasks to refresh the avatars now, and will keep this post updated
Running the rake tasks had no results. I will try to debug more tomorrow.
Can you be sure to update to latest, I did notice some issues with one of our once off jobs did play up on meta FIX: reduce amount of work onceoff does · discourse/discourse@8d06731 · GitHub
Upload.find(1282) return an upload record?
Thanks for replying. Yes, it does and the file exists in the bucket too.
 pry(main)> Upload.find(1282) => #<Upload:0x00005627d96730e8 id: 1282, user_id: 303, original_filename: "gravatar.png", filesize: 201626, width: 360, height: 360, url: "//thewatercooler.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bdbc5de045297d6279f41cafe5486799823c526b.png", created_at: Mon, 03 Sep 2018 07:30:35 UTC +00:00, updated_at: Mon, 03 Sep 2018 07:30:36 UTC +00:00, sha1: "bdbc5de045297d6279f41cafe5486799823c526b", origin: "https://www.gravatar.com/avatar/e1e727c941ed663e9da7123bf05921cc.png?s=360&d=404", retain_hours: nil, extension: "png", thumbnail_width: 360, thumbnail_height: 360>
@sam updating from Beta to Stable now and I’ll post back here in a bit. Should I run the rake tasks to refresh everything again?
Interesting, what about
That returns an empty array:
 pry(main)> upload.optimized_images =>   pry(main)>
Hmm that is the problem here. I’ll have a look at this tomorrow to see if I can reproduce with the given image.
Thank you so much! I’m now updating to get Sam’s commit and will run the rake tasks to refresh again, and see what happens.
The problem seems to be widespread actually. Now I’m on tests-passed branch, and I ran both refresh and clean rake tasks, but no luck. The weird thing is that I’m also noticing the same issue with some users that have custom_uploads as well. The ones with custom uploads have optimized_images, but deleting them has no effect either.
I also noticed that the reference that discourse has for the file is not the same URL that I can get from the bucket itself. For example, this the link I get from S3 directly (using their UI):
But this is what I get from the Discourse’s database:
But that’s not the S3 endpoint I have set on my settings page (I have the default). I just changed my s3 endpoint to https://s3-us-west-2.amazonaws.com but no luck either.
If you think having some Gravatar images might help, here’s a list of the one that I noticed the issue:
https://www.gravatar.com/avatar/a65aa3101e9ae2cae094ff045527cf4f.png?s=360&d=404 https://www.gravatar.com/avatar/b19d019cab25762612252799f44a2b96.png?s=360&d=404 https://www.gravatar.com/avatar/1fc4324f4e1fe24c6587f900ff795229.png?s=360&d=404 https://www.gravatar.com/avatar/186f9af07d20464bae0e5be5ca060a17.png?s=360&d=404 https://www.gravatar.com/avatar/bcf814a93c75a521821ceebb74e6df90.png?s=360&d=404 https://www.gravatar.com/avatar/1face0cac8f8d45e23699ec830c04954.png?s=360&d=404 https://www.gravatar.com/avatar/2822ffe52dff31cb708edd4469704d2f.png?s=360&d=404 https://www.gravatar.com/avatar/bcf814a93c75a521821ceebb74e6df90.png?s=360&d=404 https://www.gravatar.com/avatar/5d04a3641d34189806ac548cf24b282e.png?s=360&d=404 https://www.gravatar.com/avatar/600c032e2bcbe65a04676c33add4b8d2.png?s=360&d=404 https://www.gravatar.com/avatar/add7942f5530b8d9a3bb06f9aac1baf6.png?s=360&d=404
Did you happen to reconfigure
SiteSetting.s3_region recently? It looks like that site setting has been configured to be
us-east-1 when it should be
https://thewatercooler.s3.dualstack.us-west-2.amazonaws.com/original/2X/d/de05564186252ab863d84df88dc83bfa45b0dd70.jpeg works while https://thewatercooler.s3.dualstack.us-east-1.amazonaws.com/original/2X/d/de05564186252ab863d84df88dc83bfa45b0dd70.jpeg doesn’t.
Yeah, I had to change after one of the last updates (I explained what happened here Avatar upload failing)
I’m gonna write a rake task to update all the images. I wasn’t sure if changing the region could have affected it since it always worked before the other thread.
I will post my gist with my script to update the images in a bit to maybe help others in the future.
Thanks a lot!
Does that mean the region was incorrectly set initially before it was corrected? You can remap the URLs with
bundle exec script/discourse remap //thewatercooler.s3.dualstack.us-east-1.amazonaws.com //thewatercooler.s3.dualstack.us-west-2.amazonaws.com. Please take a backup before running that in case it doesn’t remap correctly.
Awesome, will run the script now. I don’t understand what happened. I never touched the bucket settings on Discourse and my bucket was always west. For some reason it worked before. What I’m noticing is that images stored under 1x don’t use the dualstack url format and all my old uploads are 1x. Don’t know if something changed in the code recently that could have affected that.
Here’s an example:
"//thewatercooler.s3.amazonaws.com/original/1X/03eb07a5e93b9e2cb80c63d3fd86a310fb18968c.png" "//thewatercooler.s3.amazonaws.com/original/1X/073fe33269897de4d0d7973b7f43e0c61a355f4f.png" "//thewatercooler.s3.amazonaws.com/original/1X/8a34f55c0451703d672181f46cc9c9c4e8b9b457.png" "//thewatercooler.s3.amazonaws.com/original/1X/9ee647f24b1d3d32653facb9da5d56469d22b6f9.jpeg" "//thewatercooler.s3.amazonaws.com/original/1X/6f96e830f8f68e1b3232b33934569707f5406b1b.jpg" "//thewatercooler.s3.dualstack.us-east-1.amazonaws.com/original/2X/8/868a566f2f56afe1a3e6fd16997e5a021a535a8b.jpeg" "//thewatercooler.s3.dualstack.us-east-1.amazonaws.com/original/2X/9/9f175016fdd217566c4803d45bc8f99d996fe9b9.jpeg" "//thewatercooler.s3.dualstack.us-east-1.amazonaws.com/original/2X/c/c3cd9870fa16a4875583183b833462cc8b1d40ff.jpeg" "//thewatercooler.s3.dualstack.us-east-1.amazonaws.com/original/2X/4/40ef5880701b79c2968a284840925e632b4a9ad2.jpeg" "//thewatercooler.s3.dualstack.us-east-1.amazonaws.com/original/2X/c/c90759b41f603fd18b75a41221850d40f0245ea9.jpeg"
All the 1X urls work independent of the region but the 2X ones have the region on the url.
OnceoffLog.where(job_name: "CorrectMissingDualstackUrls") return anything for you?
I just ran Remap, but checking OnceOfflLog shows this:
[#<OnceoffLog:0x00005639fcad5e58 id: 25, job_name: "CorrectMissingDualstackUrls", created_at: Fri, 07 Sep 2018 18:05:52 UTC +00:00, updated_at: Fri, 07 Sep 2018 18:05:52 UTC +00:00>]
Running Remap and the rake tasks to refresh and clean the avatars solved the problem.
Thank you so much for all the help!!
Just curious, which rake tasks did you run?
rake avatars:refresh and