The description of the profile lock options reads:

Locking this platform will not delete or disable it or its sites, but will
prevent any new sites from being created on it. This may be useful when you have sites that
cannot be migrated onto a newer platform, but you wish to prevent other users or clients
from continuing to provision on this platform. The platform can be unlocked later.

Thus after locking a platform it should no longer show up as an option on the 'Create Site' form (maybe for admins, but certainly not for clients).

This however is not happening and a client is able to create a site on a locked platform.

The radios in the create site form are populated by hosting_get_profile_platforms(), which never checks the platform_status to see if the platform is locked:

function hosting_get_profile_platforms($profile, $check_old_short_name = FALSE) {
  $defaults = array('default', 'standard', 'minimal', 'testing');

  $platforms = array();
  $instances = hosting_package_instances_load(array(
    'i.package_id' => $profile, 
    'n.status' => 1, 
    'r.status' => 1, 
    'r.type' => 'platform',
  ));

  if ($check_old_short_name) {
    $instances = array_merge($instances, hosting_package_instances_load(array(
      'p.old_short_name' => $instances[key($instances)]->short_name, 
      'n.status' => 1, 
      'r.status' => 1, 
      'r.type' => 'platform',
    )));
  }
  foreach ($instances as $iid => $instance) {
    $platform = node_load($instance->rid);
    // this is one of the default profiles
    if (in_array($instance->short_name, $defaults) && 
      sizeof(array_diff(array_values($platform->profiles), $defaults)) && 
      variable_get('hosting_ignore_default_profiles', FALSE)) {
      // there are other profiles available on this platform. skip this.
      continue;
    }
    if ($platform->platform_status != HOSTING_PLATFORM_DELETED) {
      $platforms[$instance->rid] = $platform->title;
    }
  }

  return $platforms;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Neograph734 created an issue. See original summary.

Neograph734’s picture

Issue summary: View changes
Neograph734’s picture

Issue summary: View changes
Neograph734’s picture

Title: Clients can create sites on locked platforms » Clients can select unavailable platforms during site creation
Priority: Major » Normal
Status: Active » Needs review
FileSize
810 bytes

Okay... It seems the client cannot actually create the site (lowering priority), the form validation catches it. Yet it is very strange the client is offered an option he cannot use.

There is the hosting_site_available_options()function that performs several checks for the available form options (this is what the validation uses as well). Attached patch uses this to also limit the displayed platforms.

  • helmo committed 245ac2e on 7.x-3.x authored by Neograph734
    Issue #2821401 by Neograph734: Clients can select unavailable platforms...
helmo’s picture

Status: Needs review » Fixed

Thanks, committed after a quick review on https://github.com/aegir-project/hosting/pull/8

memtkmcc’s picture

Version: 7.x-3.7 » 7.x-3.x-dev
Component: Code » User interface
Status: Fixed » Needs work
FileSize
956.54 KB
827.77 KB

This patch actually breaks things for all platforms with installation profiles other than those by default included by D7 core.

When you click on any such installation profile, you no longer can choose corresponding platform, even when you have all access rights (uid=1)

See the screenshots attached.

s1

s2

memtkmcc’s picture

FileSize
950.72 KB

And here is how it looks after reverting this patch.

s3

Jon Pugh’s picture

Assigned: Unassigned » helmo
Priority: Normal » Critical

This looks critical to me, now that it is in a released version...

helmo: how do you want to proceed? revert completely or try to fix it?

Neograph734’s picture

FileSize
36.94 KB

memtkmcc are you sure those platforms are not restricted (locked, assigned to certain clients, etc) somehow? The listing has become stricter as result of this patch.

I cannot reproduce this error:

Screenshot

memtkmcc’s picture

Hmmm.. no, there are no restrictions used at all. The platforms are not locked either. I can reproduce the problem using Hosting head version. I have also checked all remaining BOA specific modifications we have had in place, and there is nothing which could affect this form behaviour.

Note that to reproduce this you need to go to /node/add/site form directly, and not via Add site link on the platform node -- which still works, because it redirects to /node/add/site?platform=4090 type URL.

As for the settings, we don't use "Lock platforms by default on initial creation" and "Hide platforms with non-default profiles" is also left disabled, while "standard" is set for Default profile.

Neograph734’s picture

I just spun up a new virtual machine, and installed Hosting 7.x-3.8+5-dev (2016-Nov-11) (as part of Hostmaster (Aegir) 7.x-3.8+1-dev (2016-Nov-11)). This contains all recent patches.

I have built Open Atrium from their make file, but placed the include inline, so that it now looks like this (you can verify the contents of the included file in their repository):

api = 2
core = 7.x

; MAKE file for Drupal core.  Used by the Drupal.org packager.

; Drupal Core
projects[drupal][type] = core
projects[drupal][version] = 7.44

; ***** Patches from Panopoly *******
; Bug with image styles on database update
projects[drupal][patch][1973278] = http://www.drupal.org/files/issues/image-accommodate_missing_definition-1973278-16.patch
; ***** End of Panopoly patches *****

; *********** PATCHES ************

; Patch for handling inherited profiles
projects[drupal][patch][1356276] = http://drupal.org/files/1356276-make-D7-21.patch

; Patch for fixing node_access across non-required Views relationships
projects[drupal][patch][1349080] = https://www.drupal.org/files/issues/1349080-195-d7-move-access-to-join-condition.patch

; Patch for simpletest
projects[drupal][patch][911354] = http://drupal.org/files/911354-drupal-profile-85.patch

; Patch to allow install profile enabling to enable dependencies correctly.
projects[drupal][patch][1093420] = http://drupal.org/files/1093420-22.patch

; Patch to prevent empty titles when menu_check_access called more than once
projects[drupal][patch][1697570] = http://drupal.org/files/drupal-menu_always_load_objects-1697570-5.patch

; Patch to move registry build so entity_get_info can be called during install.
projects[drupal][patch][1311820] = https://www.drupal.org/files/issues/1311820-drupal-registry_update-13.patch

; Make node access queries more performant
projects[drupal][patch][106721] = https://www.drupal.org/files/issues/drupal-106721-optimize_node_access_queries-115.patch

; Cache user grants.
projects[drupal][patch][2199001] = https://www.drupal.org/files/issues/node_access_grants-static-cache-11.patch

; Fix javascript error with angular
projects[drupal][patch][2492993] = https://www.drupal.org/files/issues/2492993-drupal-hash-1.patch

; Fixes an issue where _registry_check_code() gets called early in the bootstrap process. Stills throws a warning but
; keeps it from throwing a fatal.
projects[drupal][patch][412808] = https://www.drupal.org/files/issues/drupal-registry_fix-412808-32.patch

; Fixes sticky headers are not calculating the column widths properly.
projects[drupal][patch][2097081] = https://www.drupal.org/files/2097081-fix-sticky-header-column-width-7.x-6.patch

; Prevent Drupal from scanning node_module and bower_component directories in theme
projects[drupal][patch][2329453] = https://www.drupal.org/files/issues/ignore_front_end_vendor-2329453-111.patch

; Issues with "required, multiple" fields in forms.
projects[drupal][patch][980144] = https://www.drupal.org/files/issues/d7-issues_with_required-980144-76.patch

; Download the OpenAtrium install profile and recursively build all its dependencies:
projects[openatrium][type] = profile
projects[openatrium][download][type] = git
projects[openatrium][download][branch] = 7.x-2.x

And it showed up nicely on node/add/site.

Perhaps any of the aegir dev's can give a second opinion?

memtkmcc’s picture

What happens when you delete minimal & standard profiles (which are useless for platforms with distro-specific profile anyway), so there will be only open atrium profile in the OA platform? Can you still see the OA platform in this form then?

memtkmcc’s picture

I have just tested this, and I can confirm that if you delete those default core profiles, you no longer can see the platform in this form, while the other platform with those default core profiles still existing, can be displayed w/o problems. This is not how it should work, though.

Neograph734’s picture

What happens when you delete minimal & standard profiles (which are useless for platforms with distro-specific profile anyway), so there will be only open atrium profile in the OA platform? Can you still see the OA platform in this form then?

How can I delete these profiles? I can only delete the Drupal base platform (which caused no errors).

memtkmcc’s picture

You delete not used profiles via SSH/SFTP from /profiles/ in the OA platform, and then re-verify the platform, so it will have only its single, distro specific profile. We delete all those useless profiles in BOA automatically for years, because their presence is known to cause a high level of confusion for users.

Jon Pugh’s picture

Issue tags: +Needs tests

Adding Needs Tests tag, this is a great candidate for a Behat test. Access control issues are very easy to create and very difficult for a human to test.

See http://github.com/aegir-project/tests

Jon Pugh’s picture

memtkmcc: That does sound like a good feature...

Neograph734’s picture

@memtkmcc: yes, confirmed. It appears to be coming from hosting_site_available_options($node), that for a new node defaults to the first platform it encounters. It can be overridden per profile, so replacing the lines from the patch with something like this works:

  $p2 = array();

  // We have to obtain the options for all platforms individually.
  foreach($platforms as $platform) {
    $options = hosting_site_available_options($node, $platform);
    $p2[] = $options['platform'][0];
  }

  $platforms = array_flip($platforms);

  $available_platforms = array_flip($p2);
  $platforms = array_intersect_key($platforms, $available_platforms);

  $platforms = array_flip($platforms);

I'll tidy it up and build a new patch. Perhaps it would be better to change the logic in hosting_site_available_options, but that depends on how and where it is used.

Neograph734’s picture

Whoa, it is way easier. We just have to make the node aware of the selected profile.

This basically concludes to adding this before the lines of the patch.

$node->profile = $selected_profile;

So the entire patch looks like:

  $node->profile = $selected_profile;
  $available_options = hosting_site_available_options($node);
  $available_platforms = array_flip($available_options['platform']);
  $platforms = array_intersect_key($platforms, $available_platforms);
Neograph734’s picture

Status: Needs work » Needs review
Neograph734’s picture

Neograph734’s picture

It appears this still needs some work, currently the 'add site' tab on a platform node is showing the form, but not with the selected platform.

Basically the wrong profile is pre-selected, and as such the chosen platform might not available.
I am not sure if this is caused by the patch, or by manually deleting several profiles. (I suppose the latter because all platforms used to be available for the standard profile.)

For now, please review the proposed solution and then revert this to 'needs work'.

Neograph734’s picture

@helmo, since #4 has been committed, can you add #20to it or revert #4 so that dev functions again? From there we can start looking at tests (I'd like some examples before I proceed with those)

  • helmo committed 8ce0005 on 7.x-3.x authored by Neograph734
    Issue #2821401 by Neograph734: Fix regression in custom profile...
helmo’s picture

Status: Needs review » Needs work

#20 is now committed.

Neograph734’s picture

Thanks helmo.

@memtkmcc, could you check if your issue is solved?
@helmo, or Jon Pugh, could you provide me with some example of a test?

helmo’s picture

@Jon Pugh is the best source about behat ... but I can get you a link to the feature files.

memtkmcc’s picture

Status: Needs work » Fixed

I can confirm that it is now fixed without any side effects. Thanks!

Neograph734’s picture

Assigned: helmo » Neograph734
Priority: Critical » Normal
Status: Fixed » Needs work

Thanks for checking.

Reopening in order to add a test for this. Behat is still a lot of magic for me, but I'll take a stab at it later this week.

memtkmcc’s picture

Priority: Normal » Critical

This patch breaks things totally now, albeit this time on site's node edit (like when you add an alias, etc) -- any site with custom/non-default profile will lose association with its real profile, replaced in the hostmaster database with default profile (which either doesn't exist in that site's platform, or has no codebase expected), which breaks drushrc.php for that site, all its tasks, and the site itself is now completely broken, because Drupal can't find the site's modules.

Please revert all four lines until something truly working will be proposed.

helmo’s picture

Status: Needs work » Needs review
FileSize
1.29 KB

Please check this new patch ... it reverts both previous commits and 'fixes' the hosting_get_profile_platforms() function.

It changes platform_status != HOSTING_PLATFORM_DELETED to platform_status == HOSTING_PLATFORM_ENABLED as I could not find a use for the function to return platforms with status HOSTING_PLATFORM_QUEUED or HOSTING_PLATFORM_DELETED

Neograph734’s picture

Status: Needs review » Needs work

This patch seems to work partially;

Working:
- Locked platforms to not show up.

Not working:
- Clients are able to see and create sites on the hostmaster platform (could be solved by #2821402: Lock the hostmaster platform by default?)
- Clients are able to see but NOT create sites on platforms where exclusive access was granted to another client.

  • helmo committed 47428ed on 7.x-3.x
    Issue #2821401 by Neograph734, helmo, memtkmcc: Clients can select...
helmo’s picture

Priority: Critical » Major

I've committed #32 to get rid of the regression mentioned in #31 and to get in into the 3.10 Aegir release.

Setting this back to Major to find a proper solution.

  • helmo committed 245ac2e on 7.x-4.x authored by Neograph734
    Issue #2821401 by Neograph734: Clients can select unavailable platforms...
  • helmo committed 8ce0005 on 7.x-4.x authored by Neograph734
    Issue #2821401 by Neograph734: Fix regression in custom profile...
  • helmo committed 47428ed on 7.x-4.x
    Issue #2821401 by Neograph734, helmo, memtkmcc: Clients can select...