1

I cloned a working EC2 instance to create a secondary staging server. Everything is working as it should with the exception of sorl-thumbnail.

Before I describe the errors I'm receiving, I think it might be helpful to describe the stack I'm working with. It involves 3 EC2 instances; an app server running django in combination with Nginx and Gunicorn; a database running MySQL and Redis; and a media server running Nginx. The app server uses NFS to mount the media directory from the media server locally. All appropriate ports are open in AWS and the app server has been added /etc/exports on the media server.

On to the issue I am seeing... The img src attribute for all images that should be generated by sorl-thumbnail is empty. When I take a look at my django app's log, I see an entry like this for every missing image:

[04/29/2013 13:11:54] DEBUG   : Could not find thumbnail image for rendering </media/images/12345.jpg>
ThumbnailException: Source file: '/images/12345.jpg' does not exist.
[04/29/2013 13:11:54] DEBUG   : Could not retrieve image for </media/images/12345.jpg>

However, 12345.jpg does exist at /media/images/.

I spent most of Friday trying to run down the issue to no avail. Has anyone come across anything like this?

JP1971
  • 880
  • 3
  • 10
  • 21

1 Answers1

1

Generated data like image thumbnails is often stored in a (comparatively) temporary filesystem location, and How sorl-thumbnail operates suggest the same:

When you use the thumbnail template tag sorl-thumbnail looks up the thumbnail in a Key Value Store. The key for a thumbnail is generated from its filename and storage. [...] It is worth noting that sorl-thumbnail does not check if source or thumbnail exists if the thumbnail key is found in the Key Value Store.

Note: This means that if you change or delete a source file or delete the thumbnail, sorl-thumbnail will still fetch from the Key Value Store. Therefore it is important that if you delete or change a source or thumbnail file notify the Key Value Store.

[emphasis mine]

Now, Amazon EC2 instances usually feature two distinct storage types, namely the persistent Amazon Elastic Block Store (Amazon EBS) volumes, which are copied when cloning an instance, and also the Amazon EC2 Instance Store volumes (usually referred to as ephemeral storage), which are lost when cloning an instance; see my answer to how to take backup of aws ec2 instance/ephemeral storage? for more on this difference/problem.

So presumably your thumbnails have been stored on the ephemeral volume and would need to be generated now accordingly.

Community
  • 1
  • 1
Steffen Opel
  • 63,899
  • 11
  • 192
  • 211
  • I actually created this EC2 instance using the ec2-bundle-vol AMI Tool command. I then uploaded the bundle to an S3 bucket using the ec2-upload-bundle command and used this bucket when registering the AMI for the secondary staging server. Therefore, it's my understanding that it is an exact copy of the working staging instance at the time of issuing ec2-bundle-vol command. – JP1971 Apr 29 '13 at 20:55
  • It also might be worth mentioning that I am using Redis for caching and modified the settings_local.py on the new secondary staging server to point to a different Redis key-value store than the one used by the primary staging server. – JP1971 Apr 29 '13 at 21:09