Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install android tools r25.2.3 concurrently #639

Merged

Conversation

@aneeshusa
Copy link
Member

aneeshusa commented Apr 19, 2017

Install the new Android tools concurrently with the old Android tools, including automatically cleaning up the old version of the tools and handling the directory layout change. (Keep the default tool version the same.)
Backport the archive.py state module to fix zip file permissions extraction.
Fix ownership setting on extracted files.
Add testing for the Android SDK due to repeated issues and the android tool always exiting with a 0 return code even in case of error.


This change is Reviewable

@aneeshusa aneeshusa force-pushed the aneeshusa:install-android-tools-r25.2.3-concurrently branch 7 times, most recently from d18c648 to 6215be2 Apr 19, 2017
@aneeshusa aneeshusa changed the title WIP: Install android tools r25.2.3 concurrently Install android tools r25.2.3 concurrently Apr 20, 2017
@aneeshusa
Copy link
Member Author

aneeshusa commented Apr 20, 2017

I got this working! r? @larsbergstrom
Also cc @MortimerGoro @fabricedesre in case I've made any bad assumptions about how the various Android tools are packaged

@aneeshusa aneeshusa force-pushed the aneeshusa:install-android-tools-r25.2.3-concurrently branch from 6215be2 to a99d2c4 Apr 20, 2017
@jdm
Copy link
Member

jdm commented Apr 20, 2017

Amazing!

aneeshusa and others added 6 commits Apr 19, 2017
The newer version of this module will prefer to use the unzip command
instead of the python zipfile module for unzipping.
This works around https://bugs.python.org/issue15795,
namely a bug where the zipfile module does not respect permissions.
This will fix our Android toolchain `archive.extracted` states.

Note that this version of the module does not include
saltstack/salt#36552,
so keep the `archive_user` argument to `archive.extracted` states.

`archive.extracted` sets ownership only on the `if_missing` path,
so ensure Salt sets ownership on all the extracted files
by unsetting `if_missing`, which defaults to `name`.
This now refers to the top level extracted directory,
so all extracted files will be properly owned by `servo/servo`,
which ensures we are able to run the `android` command as the `servo`
user to download the platform and build tools in the `cmd.run` state.

Because the `unzip` binary will be used to extract the zip files,
require the `android-dependencies` `pkg.installed` state from
`archive.extracted` states that extract zip archives
to ensure that the `unzip` binary is available.
Install a new version of the Android tools along with the old one.
Keep the old version as the current version for now to avoid breaking
builds, but still make the new version available.
This will also make future upgrades more smooth as well.

Switch to the new URL scheme for SDK downloads,
which also has switched to using zip files instead of .tar.gz files.
Note that the new packaging format
no longer has a top-level `android-sdk-linux` folder.

Move the `build_tools` and `platform` attributes under `sdk`,
as they are only used with the SDK-related states.

Reinstate `if_missing` for the SDK `archive.extracted` state to ensure
that the new archive will be extracted if the old one is present,
so that the SDK has the correct directory layout.
This also means ownership will only be updated for that file
(the `android` binary), so add a `file.directory` state to handle
fixing the ownership for the rest of the extracted files,
and fixup the requisites as necessary.
The SDK layout has changed due to the new packaging format,
so simply extracting the new archive over the old one will leave
extraneous files around.
To fix this, if we expect to make changes in the `archive.extracted`
state, then completely remove the existing version of the SDK.

Also, unlink the `current` symlink before making changes to an SDK
to avoid processes inadverently using the SDK while it is being changed
(the symlink will be restored once the SDK is done being updated.)
Unfortunately, the `android` tool always returns a 0 exit code even in
case of failure, so this does not yet catch failures.
However, the new `sdkmanager` tool seems to return appropriate exit
codes, so this will kick in in the future.

This will prevent errors from passing silently,
such as bad executable bits or incorrect file permissions.
The Android SDK installation states often have tricky changes
due to upstream changes by Google,
and additionally often fail silently in various different ways
e.g. because the `android` tool always has a zero exit status.
Additionally, some failures are not evident until Servo builds
themselves start failing.

Add a somke test in saltfs to catch common problems early on,
and automatically run it on Travis.
This will clear the entire cache in between runs
when running with SALT_FROM_SCRATCH=false.
Originally, only sls and other files in the state tree were cleared,
but since external modules and other files also need to be cleared,
just clear everything for robustness.

Additionally, move this to after we checkout the new code,
since we sync everything after invalidating the cache,
and we want to sync the new configuration instead of the old one.
@aneeshusa aneeshusa force-pushed the aneeshusa:install-android-tools-r25.2.3-concurrently branch from a99d2c4 to c82043c Apr 20, 2017
@aneeshusa
Copy link
Member Author

aneeshusa commented Apr 20, 2017

BTW, I would appreciate a highstate/deploy to roll out #638 and confirm that it's working before we apply this PR, to make it easier in case we need to revert something.

@MortimerGoro
Copy link
Contributor

MortimerGoro commented Apr 20, 2017

LGTM ;)

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Apr 20, 2017

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Apr 20, 2017

@aneeshusa Wow, this is an epic PR! I think I'm ready to r+ this if the logs from the run above look good to you. We'll probably have to be a little careful with the rollout to the cross builders and make sure we have folks on call if something goes south. Maybe morning/afternoon tomorrow (Friday), US time? I have some actual meeting-free slots then :-)

@aneeshusa
Copy link
Member Author

aneeshusa commented Apr 20, 2017

@larsbergstrom Looks like the JAVA_HOME PR is working (or at least didn't break anything). I'm free after 2PM EST tomorrow for a rollout. I also recommend playing with this in Vagrant to see how it changes the filesystem - AFAICT everything under the sdk/current symlink (which is the only place Buildbot looks) looks the same before and after.

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Apr 21, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Apr 21, 2017

📌 Commit c82043c has been approved by larsbergstrom

@bors-servo
Copy link
Contributor

bors-servo commented Apr 21, 2017

Testing commit c82043c with merge b7f2db0...

bors-servo added a commit that referenced this pull request Apr 21, 2017
…ntly, r=larsbergstrom

Install android tools r25.2.3 concurrently

Install the new Android tools concurrently with the old Android tools, including automatically cleaning up the old version of the tools and handling the directory layout change. (Keep the default tool version the same.)
Backport the `archive.py` state module to fix zip file permissions extraction.
Fix ownership setting on extracted files.
Add testing for the Android SDK due to repeated issues and the `android` tool always exiting with a 0 return code even in case of error.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/639)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Apr 21, 2017

☀️ Test successful - status-travis
Approved by: larsbergstrom
Pushing b7f2db0 to master...

@bors-servo bors-servo merged commit c82043c into servo:master Apr 21, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.