android: detect runtime artifacts pin change in WriteLKGB
Android uprevs are only triggered when new Android builds are published.
However on release branches, we need to trigger an uprev as well when
the runtime artifacts pin is modified.
This CL introduces a field in the LKGB file generated by WriteLKGB, such
that a modification is made when the runtime artifacts pin changes, and
in turn triggers an uprev.
Notes when cherry-picking: this CL works with M110+ branches; for older
branches, the runtime artifacts pin is at a different location.
BUG=b:258558620
TEST=./run_tests
TEST=./api/contrib/call_scripts/android__write_lkgb
TEST=led run https://ci.chromium.org/swarming/task/5fdde541d9f71010?server=chromeos-swarming.appspot.com
Change-Id: Ic2f22b63883da4ed99ddb311fd9448c3c1fc3846
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4173177
Reviewed-by: Madeleine Hardt <hardtmad@google.com>
Reviewed-by: Yury Khmel <khmel@google.com>
Commit-Queue: Shao-Chuan Lee <shaochuan@chromium.org>
Tested-by: Shao-Chuan Lee <shaochuan@chromium.org>
Reviewed-by: Yury Khmel <khmel@chromium.org>
diff --git a/api/controller/android.py b/api/controller/android.py
index 01dd13e..faeb29b 100644
--- a/api/controller/android.py
+++ b/api/controller/android.py
@@ -158,8 +158,24 @@
except android.InvalidLKGBError:
logging.warning("Current LKGB file is invalid, overwriting.")
+ # For release branches: check if the runtime artifacts pin exists.
+ milestone = packages.determine_milestone_version()
+ runtime_artifacts_pin = android.FindRuntimeArtifactsPin(
+ android_package, milestone
+ )
+ if runtime_artifacts_pin is not None:
+ logging.info(
+ "Found runtime artifacts pin for M%s: %s",
+ milestone,
+ runtime_artifacts_pin,
+ )
+
+ lkgb = android.LKGB(
+ build_id=android_version, runtime_artifacts_pin=runtime_artifacts_pin
+ )
+
# Do nothing if LKGB is already set to the requested version.
- if current_lkgb == android_version:
+ if current_lkgb == lkgb:
logging.warning(
"LKGB of %s is already %s, doing nothing.",
android_package,
@@ -168,5 +184,5 @@
return
# Actually update LKGB.
- lkgb = android.WriteLKGB(android_package_dir, android_version)
- output_proto.modified_files.append(lkgb)
+ modified = android.WriteLKGB(android_package_dir, lkgb)
+ output_proto.modified_files.append(modified)