When working with multiserver environments, a common task is to take a server out of the pool. Currently, I can go to a site node and tack /delete on the end of it, and that'll delete the node, but that also makes lots of other things break.

There should be a safe way to remove a server from the frontend.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ergonlogic’s picture

I guess we need to add a 'delete' task to servers. We'll need to check that there aren't any platforms on web servers, and no sites installed on database servers before allowing it. This could be similar to how we block platform deletions if sites remain.

Does anyone know why we don't already have something like this? Were there technical reasons, or did we just never get around to it?

ergonlogic’s picture

Interestingly, we already have this commented-out in hosting_server_hosting_tasks():

  /**
   * @TODO: support various other tasks like Delete
    $tasks['server']['delete'] = array(
      'title' => t('Delete'),
      'description' => t('Delete the server.'),
    );
   */
ergonlogic’s picture

... and it works as is. So I guess it's really just the validation that's left.

ergonlogic’s picture

Actually, deleted servers still appear in our server list. This isn't generated through Views (yet? see: #1876354: Convert list of servers to use views), so we'll have to fix that too.

ergonlogic’s picture

Issue summary: View changes
Status: Active » Needs work

I went ahead and un-commented the above in d359bdb. It appears to delete the server context properly. We still need to add a server_status field so we can filter on it in views.

Since this is in hook_menu(), remember to clear your menu cache after pulling down this change, or you'll get an error on the task confirmation form.

ergonlogic’s picture

In 7bd8ea2, I added the deletion of tasks related to a server when it's node is deleted.

ergonlogic’s picture

Perhaps we should add a 'lock' or 'disable' task, comparable to platforms and sites (respectively). It seems like we'd want to be able to bar usage of a server without necessarily deleting it's configuration.

  • Commit f191376 on 7.x-3.x by ergonlogic:
    Issue #2040445: Provide a safe way to remove a server from the system.
    
ergonlogic’s picture

Status: Needs work » Needs review

This should mostly be fixed by f191376. I added both 'status' and 'verified' fields to servers, including the Views integration, etc.

I say "mostly", because, while we can now delete servers from the front-end, and have the corresponding context alias removed as well, I don't consider this particularly "safe". That is, before allowing a platform to be deleted, we check whether there are any sites installed on it. We should perhaps do something similar here. I suppose we'd have to check what services are being used by platforms/sites, etc...?

cweagans’s picture

The code looks good to me. I haven't been able to test it, though, as I don't have a cluster running Aegir 3 just yet.

There are two things we need to check: 1) are there any platforms provisioned on the server, and 2) if there's a database service, are there any sites that are using it?

ergonlogic’s picture

Maybe we should add a hook to allow entities consuming a service to declare it safe to disable the service. Then the delete task can attempt to disable any active services before proceeding with the deletion of the server.

Maybe something like: hook_hosting_service_allow_disable($server, $service)

Then sites could implement:

hosting_site_hosting_service_allow_disable($server, $service) {
  if ($service == 'database') {
    if (hosting_site_get_db_sites($server)) {   // This function doesn't exist (yet)
      return FALSE;  // STOP! Sites are running on $server's db.
    }
    return TRUE;  // No sites running on $server's db.
  }
return TRUE;  // Not a db service, so irrelevant to sites.
}

Platforms could do similarly for 'http' services. This way when we add a static site entity that just requires a vhost (for example), we don't have to alter hosting_server overly to accommodate it.

  • ergonlogic committed f191376 on dev-helmo-3.x
    Issue #2040445: Provide a safe way to remove a server from the system.
    
helmo’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs review » Needs work

Or should we expand drush_http_provision_delete() to have a case for type = server.
And let it check e.g. if there are platforms on the server left?

  • ergonlogic committed f191376 on 7.x-3.x-1995506
    Issue #2040445: Provide a safe way to remove a server from the system.
    

  • ergonlogic committed f191376 on dev-2223033
    Issue #2040445: Provide a safe way to remove a server from the system.
    

  • ergonlogic committed f191376 on dev-2359571
    Issue #2040445: Provide a safe way to remove a server from the system.
    

  • ergonlogic committed f191376 on 7.x-4.x
    Issue #2040445: Provide a safe way to remove a server from the system.
    
formatC'vt’s picture

After server deleted we should remove services provided by this server, because services still available in list when we create new sites/platforms.

gboudrias’s picture

Status: Needs work » Needs review

Hi format, is your patch for 7.x-3.x? Just clarifying since this is an old issue.

formatC'vt’s picture

yes, for 7.x-3.x

gboudrias’s picture

Issue tags: +Aegir 3.1
gboudrias’s picture

#18 works great, but maybe it should go into its own issue? I'm hesitant to mark this as RTBC seeing as this is a larger issue than just the form.

cweagans’s picture

Status: Needs review » Reviewed & tested by the community

I think it's fine. It's normal cleanup that needs done when a server is deleted. LGTM.

ergonlogic’s picture

Has #10 been addressed? We need to validate that removing a server won't pull the platform or database from under a site. This is comparable to how a platform won't allow itself to be deleted if there are any sites installed on it.

  • gboudrias committed f963e1d on 7.x-3.x authored by formatC'vt
    Issue #2040445 by formatC'vt: Provide a safe way to remove a server from...
gboudrias’s picture

Status: Reviewed & tested by the community » Active

Pushed formatC'vt's patch since it seemed important, back to active to address #10.

  • gboudrias committed f963e1d on 7.x-4.x, aegir4_https authored by formatC'vt
    Issue #2040445 by formatC'vt: Provide a safe way to remove a server from...