Problem/Motivation

I'm trying to uninstall the s3fs module on my local and when the module uninstalls the site throws this error

InvalidArgumentException: Missing required client configuration options: region: (string) A "region" configuration value is required for the "s3" service (e.g., "us-west-2"). A list of available public regions and endpoints can be found at http://docs.aws.amazon.com/general/latest/gr/rande.html. in Aws\ClientResolver->throwRequired() (line 435 of /app/vendor/aws/aws-sdk-php/src/ClientResolver.php).
Aws\ClientResolver->resolve(Array, Object) (Line: 199)
Aws\AwsClient->__construct(Array) (Line: 353)
Aws\S3\S3Client->__construct(Array) (Line: 347)
Drupal\s3fs\S3fsService->getAmazonS3Client(Array) (Line: 277)
Drupal\s3fs\StreamWrapper\S3fsStream->getClient() (Line: 185)
Drupal\s3fs\StreamWrapper\S3fsStream->__construct() (Line: 262)
Drupal\Component\DependencyInjection\Container->createService(Array, 'stream_wrapper.public') (Line: 176)
Drupal\Component\DependencyInjection\Container->get('stream_wrapper.public', 1) (Line: 50)
Drupal\webprofiler\DependencyInjection\TraceableContainer->get('stream_wrapper.public') (Line: 131)
Drupal\Core\StreamWrapper\StreamWrapperManager->getWrapper('public', 'public://') (Line: 96)
Drupal\Core\StreamWrapper\StreamWrapperManager->getViaScheme('public') (Line: 47)
Drupal\image\PathProcessor\PathProcessorImageStyles->processInbound('/admin/content', Object) (Line: 70)
Drupal\Core\PathProcessor\PathProcessorManager->processInbound('/admin/content', Object) (Line: 138)
Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->onKernelRequestCheckRedirect(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 134)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 42)
Drupal\force_password_change\Service\ForcePasswordChangeRedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Uninstall module

Proposed resolution

Uninstalling shouldn't break the site. Not sure what needs to be done to fix though.

CommentFileSizeAuthor
#6 uninstall_breaks_sit-3261587-6.patch2.42 KBcmlara

Comments

smustgrave created an issue. See original summary.

cmlara’s picture

I haven't been able to duplicate this during the uninstall step yet, it looks like this will be depend upon having the force_password_change module installed.

Drupal\s3fs\StreamWrapper\S3fsStream->__construct() (Line: 262)
Drupal\Component\DependencyInjection\Container->createService(Array, 'stream_wrapper.public') (Line: 176)
Drupal\Component\DependencyInjection\Container->get('stream_wrapper.public', 1) (Line: 50)
Drupal\webprofiler\DependencyInjection\TraceableContainer->get('stream_wrapper.public') (Line: 131)
Drupal\Core\StreamWrapper\StreamWrapperManager->getWrapper('public', 'public://') (Line: 96)
Drupal\Core\StreamWrapper\StreamWrapperManager->getViaScheme('public') (Line: 47)

From this snippet we can gather that $settings['s3fs.use_s3_for_public'] = TRUE; was set in settings.php at the time of uninstall (or that the service container had not been refreshed after removing)

In #3061878: Uninstall does not allow reversion to local file system I touch on the fact that normally I (as a sysadmin) would anticipate that admins have fully migrated off s3fs before they try an uninstall it and this issue is somewhat in the same spirit. If s3fs is still handling public:// file streams when it is uninstalled Drupal core is expecting to use s3fs and if in the middle of an uninstall that ability is taken out from Drupal the results are undefinable.

Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 42)
Drupal\force_password_change\Service\ForcePasswordChangeRedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)

Best I can speculate is that force_password_change does something with the filesystem in the same request(or serialized into the cache) and that action is retained through the uninstall where the service container hasn't yet done a refresh to determine that s3fs is no longer available. This isn't intended to imply force_password_change is doing anything wrong, it is only intended to mean that it takes a perfect combination of another third party module utilizing the filesystem in middleware and not having fully decommissioned the s3fs module before uninstalling it.

Considering this doesn't appear to happen in a stock Drupal and it requires having not fully decommissioned the s3fs module before uninstalling I'm leaning towards this being either works as designed or won't fix unless someone can think of some step that can solve this easily.

About the only change I can think of at the moment is perhaps we can throw an exception during hook_uninstall however I'm not sure that is any better than the situation as it exists right now, both are WSOD's.

smustgrave’s picture

Not sure if this helps. But uninstalling module through UI doesn't cause issue. But uninstalling through drush does.

cmlara’s picture

But uninstalling module through UI doesn't cause issue. But uninstalling through drush does.

Good to know, so this issue may be even more isolated and unlikely to occur.

I'm starting to be inclined to think at most this is a documentation addition.

I did discover uninstall validators but background reading it appears they were intended for content entities instead of situations like this. Additionally since s3fs is bootstrapped in at such a low level in Drupal I'm hesitant to make it harder to remove.

smustgrave’s picture

Priority: Major » Normal

I’ll check the behavior on aws. Also may be an issue with docker caching something. I do run several cache clears. Lower The severity though since you can’t replicate.

cmlara’s picture

Status: Active » Needs review
StatusFileSize
new2.42 KB

In line with #4 I've attached a draft for addition to the README providing some initial documentation on requirements to safely remove the s3fs module.

Just documenting will not prevent the issues reported in this issue from reoccurring, however I do not believe the s3fs module can every be safely uninstalled without proper planning and consideration about how it has been utilized in a deployment and the future steps that will be taken to replace it.

  • cmlara committed 5f9c266 on 8.x-3.x
    Issue #3261587 by cmlara, smustgrave: Uninstall breaks site
    
cmlara’s picture

Component: Code » Documentation
Category: Bug report » Task
Status: Needs review » Fixed

With no objections raised to suggested documentation I've merged it into Dev.

This doesn't hard prevent this from occurring in the future, but will provide a bit of background information for administrators to consider before uninstalling the module.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.