Problem/Motivation

Currently, drush make --drupal-org requires that *everything* in the projects array in the .make file corresponds with a valid release node on d.o. If we can't find a release node (e.g. no releases for the project yet at all), we consider it a fatal build error. Furthermore, it will currently blindly pull the latest recommended release if the project has history but we still can't find the right release node.

Also, since the data currently being propagated to the packaging script is so minimal, the packaging script has to do an extra SQL query on every distro it builds to get data that drush make already has.

Proposed resolution

  • We should be smarter about how we search for release nodes in the release history XML. If we can't find a release node, it shouldn't be a fatal error. Given #1432312: Set project-level 'version' attribute automatically if a Git 'branch' or 'tag' attribute is defined. we can always look for a top-level version attribute, and if we have that, we request the history for exactly that version.
  • Never fall back to find the latest recommended release for a given project/branch.
  • If we can't find a release node, just remember the download attributes we used (url, revision, branch, etc)
  • Instead of writing out a package_contents.txt file with just release nids, we'll write out a package_contents.json file with a nested array of data about each project and what we found. If we've got a release node, we include that nid. Otherwise, we include the download attributes we have. For example, the PHP array for the data would look something like this:
    array(
      'coder' => array(
        'nid' => 124124,
      ),
      'devel' => array(
        'url' => 'git://git.drupal.org/project/devel.git',
        'revision' => 'c2048dfe1d8caf9aa2608641f4f4fec413e4c46b',
        'branch' => '6.x-4.x',
      ),
    );
    

    In this imaginary example, we have a release node for coder (could be official or -dev, doesn't matter), but there's some revision on a new branch of devel that doesn't even have a -dev release node yet so we just explain WTF was checked out. The resulting package_contents.json file would therefore look something like this:

    {"coder":{"nid":124124},"devel":{"url":"git:\/\/git.drupal.org\/project\/devel.git","revision":"c2048dfe1d8caf9aa2608641f4f4fec413e4c46b","branch":"6.x-4.x"}}
    
  • Fix the packaging script to parse this .json file and use that to a) avoid the query it's doing to find project shortnames for all the release node IDs (since we'll already have those as the top-level array keys) and then figure out what contents to display on the distro release node based on the data for each project (instead of assuming they're just release node ids).

Remaining tasks

  • Fix drupalorg_drush to be smarter about how it searches for release nodes from the release history XML for the projects in the .make file.
  • Have it construct the array of project => release/Git id/whatever data for everything it built, and write that out to the package_contents.json file.
  • Fix the packaging script to read/parse this .json file, and store the right stuff in the project_package tables as appropriate (needs a separate issue)

User interface changes

When something is packaged into a distribution on d.o that doesn't have a release node we can associate with it, we'll just display that on the distro release node as if it was external code and print a URL (and the revision/branch whatever we know).

API changes

When the --drupal-org-log-package-items-to-file is set, a package_contents.json file will be written with a full nested array of info about projects instead of the old package_contents.txt file that just contained a newline-separated list of release nid integers.

Original report by dww

I'm nearly positive there's some infra or webmaster issue related to this bug, but I can't find it now...

I just discovered that if you're building a .make file and pointing it at Git stuff that doesn't correspond to a release node, drupalorg_drush just blindly pulls the release nid of the latest official release from the recommended branch. So, for example, if you do this:

projects[update_test_module][type] = module
projects[update_test_module][download][type] = git
projects[update_test_module][download][branch] = 7.x-4.x

You end up with:

Could not locate update_test_module version 7.x-4.x-dev, downloading   [warning]
latest stable version
update_test_module cloned from                                              [ok]
git://git.drupal.org/project/update_test_module.git.
Checked out branch 7.x-4.x.                                                 [ok]

And the package-contents.txt file contains: 683972 which is update_test_module 7.x-1.3.

I'm not 100% sure what we should do in this case, but we definitely shouldn't do what's happening here. ;)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dww’s picture

Title: If the .make file specifies something that doesn't correspond to a release node, we blindly pull a recommended release nid » Fix how drupalorg_drush handles release history XML and propagates data to the packaging script
Assigned: Unassigned » hunmonk

Just had a thorough discussion with hunmonk about this to come up with a plan. I wrote a full issue summary to reflect the new thinking on this. He's going to take the first stab at a patch for all this in the morning.

dww’s picture

Actually, I've got a few open questions:

A) Should that be 'nid' => 12141 or something like 'release_nid' => 12312 for clarity?

B) Should we just change the meaning and behavior of --drupal-org-log-package-items-to-file like this, or should we leave the old release-nid-only package_contents.txt file around, and add a new option like --drupal-org-log-package-contents-to-json which spits out the fancy new package_contents.json file? If we add a new option for the new behavior, it'd be easier to deploy this without having to coordinate a patch to the packaging script simultaneously. Then again, it's legacy bloat to maintain this old file that presumably *no one* cares about other than the packaging script, which just needs to change, anyway.

hunmonk’s picture

Status: Active » Needs review
FileSize
4.24 KB

first stab at this. seems to work fine for detecting both valid point releases and dev releases and adding their release nids to package_contents.txt. with the application of the patch at #1436624: Strict option for downloading release XML it also properly skips stuff adding to package_contents.txt when a specific revision is loaded. didn't check a valid tag or branch that's not attached to a release node, but guessing that will also work.

i was able to rip out almost the entire old drupalorg_drush_updatexml() function in favor of using native drush stuff, win!

dww’s picture

Status: Needs review » Reviewed & tested by the community

Code looks good. Light testing appears to do the right thing. Ship it!

hunmonk’s picture

Status: Reviewed & tested by the community » Fixed

committed and pushed.

dww’s picture

Status: Fixed » Active

Right, except now we have to do all the rest of this stuff with the JSON file. ;)

hunmonk’s picture

Status: Active » Needs review
FileSize
8.92 KB

first crack, untested. this leaves the old 'drupal-org-log-package-items-to-file' switch in place and adds a 'drupal-org-log-package-contents-to-json-file' switch, with TODO notes to rip out the old switch.

hunmonk’s picture

this is now working quite well as far as i can tell. tested quite a few permutations and it always seems to output the right json. i tested the old switch and it also seems to still be working properly.

dww’s picture

Assigned: hunmonk » dww
Status: Needs review » Needs work

Mostly working. So far, the biggest bug I've found is that it prints out info about a drupal core release, although currently --drupal-org continues to force --no-core and core is *not* being built. There are probably other examples where this code is just assuming that if something's in the .make file it actually got built.

Probably the only way to do this correctly is to put this functionality directly into drush make core itself. There's a desire to do so over at #1465810: Create an option to generate a single PATCHES.txt file for an entire make file although it's possible (likely?) that won't happen until Drush 6.

Anyway, I'm going to take a stab at fixing this later today. I'll probably clean up a lot of the code, too. I'm not a big fan of all the functions related to this being called "json" -- that's just a specific representation detail. Really, what we're operating on here is packaging metadata. In fact, it'd be reasonable for this option to take an optional value which determines what output representation the metadata should be printed as. And/or the filename to print it to. ;) Anyway, I'll re-roll this. Stay tuned.

dww’s picture

Status: Needs work » Fixed

Okay, I just pushed 5 commits. The first is the patch from #8 (which I committed using hunmonk as the author). The next 4 are various refactorings and fixes:

https://drupal.org/commitlog/commit/31076/0e487b98b9248ee010b20faceb2c6f...
https://drupal.org/commitlog/commit/31076/ade6d2f02df904cfed3b7b660f2b7b...
https://drupal.org/commitlog/commit/31076/b4bc058fcc973f987696246bdf773d...
https://drupal.org/commitlog/commit/31076/5185d2296cf77451eba32dbef8b493...
https://drupal.org/commitlog/commit/31076/866ed7b8da22dbf8176821b081e719...

We should probably be adding automated tests for all this, but I don't have time for that right now. If anyone wants to run with that, please do. ;)

Meanwhile, I opened #1472744: Change packaging script to use the new JSON metadata from drush make for package contents about fixing the packaging script to take advantage of the new package_contents.json file from here.

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

Anonymous’s picture

Issue summary: View changes

added a full issue summary based on an IRC chat with hunmonk