If you attempt to install a site to a platform on a remote server which has never been successfully verified, you get the message

Install profile field is required

This happens regardless of whether there is an install profile involved.

Once the platform is validated, you don't get this error.

A better error would be "Site cannot be installed until platform is verified."

Comments

adrian’s picture

Unfortunately, there's not much we can do about it. forms api puts in those errors itself.

I suppose we could stop the user from submitting a site when there are no available platforms.

adrian’s picture

Unfortunately, there's not much we can do about it. forms api puts in those errors itself.

I suppose we could stop the user from submitting a site when there are no available platforms.

adrian’s picture

Unfortunately, there's not much we can do about it. forms api puts in those errors itself.

I suppose we could stop the user from submitting a site when there are no available platforms.

anarcat’s picture

Right, right, right... :)

So I do think that we shouldn't allow users to create sites on unverified platforms, that's pretty basic and I thought this was already there. Since it's not that big of an issue and we're so close to a release, I'll be tagging this 0.3...

anarcat’s picture

Issue tags: +aegir-0.4

targeting to 0.4

Anonymous’s picture

Title: Error "Install profile field is required" inexact/confusing » Inaccurate error thrown when site is attempted to be created on platform that isn't verified
Project: Provision » Hosting
Version: 5.x-0.2-alpha1 » 6.x-0.3-rc4
Status: Active » Needs review
StatusFileSize
new1.57 KB

Attached is a patch against Hosting HEAD that doesn't allow sites to be created on unverified platforms (at least through the standard Add Site node/add/site frontend interface).

The existing site form gets the list of available platforms via _hosting_get_platforms(), which gets its data from the node table (which doesn't know anything about whether a platform is actually verified or not).

I copied this function to make _hosting_get_verified_platforms(), which does basically the same thing but does a join on hosting_platforms table to only return rows where the verified field is greater than 0.

Substituting this function in favour of _hosting_get_platforms() in the site form only shows thus 'verified' platforms (or, shows no Platforms if the results are not greater than 1.. which is existing functionality that makes sense) . So in this sense it isn't 'preventing' sites from being created on this platform, but it's not giving the option to.

I decided not to modify the existing _hosting_get_platforms() because it's used elsewhere, plus even if it wasn't, it'd be a useful function to have for any future work that might want to just get a list of all platforms.

As a result I think this isn't a 'Provision' bug as it doesn't get this far, it's in Hosting. I've modified the issue metadata to suit (sorry if I'm overstepping my mark doing so)

Cheers (sorry digging up these old issues, I felt like doing some 'housecleaning' :) )

jonhattan’s picture

Patch tested. It works fine. But...

1/ hidding not verified platforms is annoying. It can be solved by just putting some extra in the field description, as "Unverified patforms are not listed".
2/ Most important: how will it behaves when trying to create a site in the first platform and that has not been verified yet?

Anonymous’s picture

1/ hidding not verified platforms is annoying. It can be solved by just putting some extra in the field description, as "Unverified patforms are not listed".

Not as annoying as trying to provision a site on an unverified platform and getting an error :)
It is trivial to add some wording to that effect. But remember you can always see the list of all Platforms even in the block that provides it.

2/ Most important: how will it behaves when trying to create a site in the first platform and that has not been verified yet?

Isn't the verification of the first platform, the first thing that happens post-install? Even before any existing sites are imported.

If this isn't the case, then to me that is a separate bug!

Anonymous’s picture

StatusFileSize
new1.93 KB

I should also add, that remember that even prior to this patch, if there is *only* one platform created, the entire 'Platform' field in the form is hidden, and has always been this way at least since I've been using Aegir.

I was reminded of this after editing the Description for this field, and then realised that this extra wording will still be hidden if two platforms exist and only the first platform is verified :) so to me there is little point in adding the wording. If it's seen as significant, use the attached patch.

Anonymous’s picture

Status: Needs review » Needs work

jonhattan has pointed out over IRC that if no platforms are verified ('verified = 0' on all platforms in hosting_platform), the install profile options (if applicable) are still shown on the Add Site form, and that this'd still break new site creations.

This is kind of based on the logic that people are trying to create sites prior to the initial platform being verified, and I can't imagine that being done realistically.

On the other hand it's occured to me another issue: what happens if a platform that was verified, becomes un-verified (maybe someone adds a new install profile to the platform, runs another Verify task to pick it up, and it's poorly coded and breaks the platform on a re-verify), does it have its 'verified' field set back to 0 ? If not, my patch may assume a false positive. I guess this needs more work.

jonhattan’s picture

Trying to create a site before the first platform is not verified is not realistic... if the platform is correctly veryfied within the first minute.

If platform is not verified a unexpected behaviour will happen. As you stated, I saw install profiles in site creation form when fake un-verified all platforms by settings verified=0 in the database. Install profiles I saw are default and hostmaster, and this is not the behaviur when the platform is verified. It would not be the case if the platform has never been verified instead of faking (profiles will not be imported yet).

On your other hand, I did a platform be unverified by chown to root and scheduling a verification again, that failed. In that case `verified` field in the database stays the same (it is not set to 0 anymore). The task becomes a failed task and you are prompt to retry but the platform itself is not unverified.

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new3.51 KB
new7.93 KB

Attached is a reroll, I offer two different versions.

Common changes

Both patches do the following:

1) Throw an error in hook_validate() of the site form if the platform is not valid

2) Edit hosting_site_hosting_verify_task_rollback so that if a verify fails of a site, set verification to '-1' instead of 0 (which translates to Never, which isn't really true). Also add a clause of the same sort but for task->ref->type 'platform' as opposed to just 'site'

3) Edit hosting_format_interval() to account for the '-1' parameter above, so that in a View of a platform or a site that is currently not verified, but has been verified in the past, 'Last verification failed' is shown instead of 'Never'

Differences in the two options

Option one does 1) above differently: it uses the _hosting_get_verified_platforms() I created in the original patch to get the list of verified platforms, and it doesn't show platforms that are not verified, in the Site form. So any platform chosen by the user on form submit should already be valid (unless they have hit submit wildly despite no verified platforms existing yet: see below to see that we do still check this in hook_validate anyway just in case)

In Option 1 as a result, there is also now some extra sanity checking in there to not expose things like the install profiles etc on error, that jonhattan picked up on in #11.

Option 1 also throws an immediate form_set_error on the rendering of the Site form (before submit, when just visiting /node/add/site), telling the user they won't be able to create the site if there are no verified platforms, in an effort to stop them then and there (it later goes into hook_validate and sets a weightier check to see if the user has gone on anyway and submitted the form: if they have, and no verified platforms exist, that is the same error again that is thrown back, as opposed to bothering to run all the other checks like 'is this is a new client' and so on)

Then I rewrote this whole idea which became Option 2, as I wasn't sure that throwing such blanket errors at the user was good.. so here we have Option 2, which instead of hiding the unverified platforms and throwing an error if there are none, still displays all platforms that *exist*, but uses hook_validate and a new function I called '_hosting_platform_is_valid($platform)' to check if the platform specific to the user's choice in the form is valid or not, and if not, *then* throw an error in the more customary way.

To me Option 2 is a bit more graceful, lightweight and consistent with how Drupal tends to operate (using just hook_validate to deal with whether the choice is ok or not).. Option 1 takes things a bit more further by actually *hiding* unverified platforms altogether. I leave both options here for discussion, testing and choice for the developers!

Thanks jonhattan for ideas, testing and advice while I worked on this.

jonhattan’s picture

good job mig5! Those are my suggestions:

1/ setting the platform to -1 (or 0) should be done in hosting_platform_hosting_verify_task_rollback() not in hosting_site_hosting_verify_task_rollback(). If does not exist, create it :)

2/ If a first verification fails, dont change to -1 (ie: last verification failed) but stay in 0 (never verified).

3/ I think hiding platforms is better, to avoid further errors trying to get the available profiles (and languages) via ajax, mostly if the platform has not been verified ever. In fact it makes a difference a platform that has not been verified ever that one that has failed further verification. If not verified ever it shows profiles (and languages) from the default platform. If was verified, it shows the correct profiles. So we can speak of "bootstrapped platforms" although has become unverificable for some reason.

So perhaps it makes sense to only avoid creating sites in never-verified (non bootstrapped) platforms... as far as creating a site on a platform that has been bootstraped but last verification failed does not present the problem that opened this issue. In this case the site could be installed/verified although the platform is not last verified! (ej: chown to root; verify to fail the platform; chown back to aegir; create the site). If the site could not be installed it will stay there and will be able to retry install as soon as the platform becomes verified again.

Sumarizing:

* my points 1 and 2 apply.
* hidding is easier to handle in order to avoid ajax errors.
* hide only never-verified platforms (verified != 0).
* it must be tested the case where the first platform is not verified yet (hidding make no sense). Does the same "Install profile field is required" happen? => I think this can be handled in hook_validate as you are currently doing.

Anonymous’s picture

Crap, you're right, I didn't even realise I'd put 'platform' specific conditions into the site/ stuff. That was ugly, thanks for picking it up.

Anonymous’s picture

Jonhattan, I dunno if I agree with your point 2/ : about leaving new platforms as verified = '0' as opposed to setting them to -1.

The reason being that it's already like that, let me illustrate in a scenario:

1) User adds a platform
2) Task gets added to the scheduling queue. At this point it has already been added to the hosting_platform table with a 'verified' value of 0. This makes sense, it's never been verified. At this point the View shows Verified: Never. Good.

3) Verification fails when the task is executed. It is set to -1

4) The status of the platform is now 'Last verification failed'. To me this makes sense: the last verification *did* fail, and since a verification was attempted, it's both true that it's never been 'verified', and that the last verification attempt failed. But at this point, to me, it is more important to know the verification failed than whether it's the first time or not.

Arguments welcome! :)

jonhattan’s picture

mig5: my rationale is based in that "If was verified, it shows the correct profiles". As I said above: a never-verified platform is not the same as a verified platform that failed a later verification. In fact if a platform is not currently verified but has been verified at least once in the past... there's no problem adding sites to that unverified platform (sites can or not be succesfully created. If not, they will stay pending and can be succesfully created once the platform is working back again).

Anonymous’s picture

Status: Needs review » Needs work
anarcat’s picture

So this is heavily linked with #422970: have one task type per site node and is probably why it's been postponed post 0.3. I encourage you to start looking at that issue instead, it resolves (IMHO) the 0 vs -1 vs "bootstrapped" issue quite cleanly (through node revisions).

My opinion is similar to johnattan's: platforms that have verified *once* should be listed, even if their last verification failed.

I do not like setting the flag to -1: it may create problems elsewhere in the code that rely on the truth value of that flag...

Finally, I think that users should be forbidden to create sites in certain platforms. What I mean here is that this should be a permission as much as form validation: it should be impossible for users to create sites on certain platforms. So there should be some access checking function that would abstract that away, and that could eventually include ACL for platforms (the same way we have for sites now). See #558450: platform access control / permissions for that.

In other words, thanks mig5 for the excellent work again, but I'm not sure this is tackling the problem the right way.

adrian’s picture

Status: Needs work » Fixed

this has been resolved in head by the fact that you now select the profile first, and that shows you the list of platforms that have that profile, so this can never happen anymore.

Status: Fixed » Closed (fixed)
Issue tags: -aegir-0.4

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