tree: fd9d9a7c45affa748ea0de3c4a9a619629045e98 [path history] [tgz]
  1. static/
  2. test/
  3. testdata/
  4. __init__.py
  5. app.py
  6. app.yaml
  7. appengine_config.py
  8. appengine_test_base.py
  9. config.py
  10. config_test.py
  11. cron.yaml
  12. filesystem_adapter.py
  13. filesystem_adapter_test.py
  14. git_util.py
  15. git_util_test.py
  16. goldeneye_ingestion.py
  17. hwid_api.py
  18. hwid_api_messages.py
  19. hwid_api_test.py
  20. hwid_manager.py
  21. hwid_manager_test.py
  22. hwid_updater.py
  23. hwid_util.py
  24. hwid_util_test.py
  25. hwid_util_unittest.py
  26. hwid_validator.py
  27. hwid_validator_unittest.py
  28. ingestion.py
  29. ingestion_test.py
  30. memcache_adaptor.py
  31. memcache_adaptor_test.py
  32. README.md
  33. requirements.txt
py/hwid/service/appengine/README.md

HWID Service

This folder contains the mandatory files to deploy HWID Service on AppEngine. Most of the files are porting from HWID Server with modifications to adapt to factory repository.

Design

The origin HWID Server Arch Overview and Design Doc.

Important Files

  • app.yaml: Config file for deploying service on AppEngine.
  • cron.yaml: Config file for deploying cronjob on AppEngine.
  • ${factory_dir}/deploy/cros_hwid_service.sh: The main script to deploy and test HWID Service. Run cros_hwid_service.sh for more usage.
  • appengine_config.py: The very first loading file on AppEngine.
  • app.py: The API entry point. It defines the API handlers.
  • hwid_api.py: The HWID API function implementation.

Run and Deploy

Environments

There are three environments to deploy to:

  1. prod
  2. staging
  3. local

AppEngine Deployment Flow

  1. Make sure the contents of three repos is what you want:

Normally, we would use ToT: Run repo sync . in each repo.

  1. Before deploying to prod, you have to deploy to staging:
# If you use Google Cloud Platform for the first time, you may have to
# install gcloud sdk (https://cloud.google.com/sdk/install).  gcloud may ask you
# to register or loging your account.  Please enter your google domain acount.
# It may also ask you to register or login a GCP project account, you can
# use 'chromeos-factory'.  The deploy script will choose the right GCP project
# to deploy.
deploy/cros_hwid_service.sh deploy staging
  1. Make sure all tests are passed:
# In chroot: unittest
make test
# Out of chroot: integration test and e2e test
# - Integration test creates a docker image, which may take a long time for the
#   first time running this script.
# - e2e test list is placed at go/factory-private-git
deploy/cros_hwid_service.sh test
  1. If all tests are passed, now we can deploy the HWID Service to prod:
deploy/cros_hwid_service.sh deploy prod
  1. Open the AppEngine management page, and watch the traffics are not blocked.

Invoking API

Example request for local environment:

# Before invoking local API, you have to deploy local env
deploy/cros_hwid_service.sh deploy local
# Now you can test HWID Service locally.
curl http://localhost:8080/_ah/api/chromeoshwid/v1/boards
curl --data '{ "hwidConfigContents": "\n\nchecksum: test\n\n" }' \
--dump-header - http://localhost:8080/_ah/api/chromeoshwid/v1/validateConfig

Example request for staging/prod environment, using HWID CHROMEBOOK B2A-M5N:

curl "${ENDPOINT_URL}/bom/CHROMEBOOK%20B2A-M5N?key=${APIKEY}"

Where ${APIKEY} can be created from AppEngine Management Page -> APIs & Services -> Credentials.

Test

cros_sdk make -C ../platform/factory test  # factory unittests
./deploy.sh test  # integration tests and e2e tests

Log

To view the logs, you have to go to AppEngine Management Page -> Versions -> Diagnose -> Logs

HWID Database Ingestion Pipeline

The ingestion pipeline helps AppEngine get access to the HWID Database on Gerrit, there are two stages of the pipeline.

  1. Borgcron Job Ingestion
  2. AppEngine Cronjob Ingestion
    • Validates the HWID Databse files in BigStore bucket [bucket]/staging. If the file is validated, move the file from [bucket]/staging to [bucket]/live.

Borgcron Job Deployment

The borgcron job is to periodically(every 24h) upload the latest HWID Database from git(via git/gerrit-on-borg) to the cloud buckets. Since it is a borgcron job, we don't port this part to the factory repository. To modify the code and deploy, please refers to http://go/hwid-server-arch -> Run & deploy -> Deploying the borgcron job.

Changing the APIary Endpoint Configuration

APIary publishes chromeoshwid API from AppEngine to google domain. The APIary configuration file is stored in the google3. To change the config, please refers to https://go/hwid-server-arch -> Run & deploy -> Changing the Apiary Configuration.