#121 coreos-download: use `parent-pkgdiff` directly from metadata
Merged 3 years ago by dustymabe. Opened 3 years ago by abai.
fedora-web/ abai/websites coreos-download  into  master

@@ -93,11 +93,21 @@ 

      return Promise.all(metaPromiseList);

    }

  

-   for (let i = currentReleaseIdx; i < targetReleaseIdx; i++) {

-     let metaPromise = fetchBuildMeta(base, builds[i], legacy);

-     metaPromiseList.push(metaPromise);

-   }

-   return Promise.all(metaPromiseList);

+   // check if `parent-pkgdiff` field is present, if present there's no need to manually

+   // calculate pkgdiff here, use the field directly

+   // xref: https://github.com/coreos/fedora-coreos-pipeline/pull/247#event-3413080221

+   let metaPromise = fetchBuildMeta(base, builds[currentReleaseIdx], legacy);

+   metaPromiseList.push(metaPromise);

+   return Promise.all(metaPromiseList)

+     .then(metaList => {

+       if (metaList[0][1]['parent-pkgdiff'] == null) {
abai commented 3 years ago

Sorry for the magic indexing here, the metaList is an array of metadata arrays, e.g. [ [ "x86_64", $meta.json ] ]

+         for (let i = currentReleaseIdx + 1; i < targetReleaseIdx; i++) {

+           let metaPromise = fetchBuildMeta(base, builds[i], legacy);

+           metaPromiseList.push(metaPromise);

+         }

+       }

+       return Promise.all(metaPromiseList);

+     });

  }

  

  // Get an accumulated pkgdiff given a list of metadata
@@ -258,7 +268,10 @@ 

    return gatherMetadataBtwReleases(fromIdx, toIdx, config).then(metaList => {

      let build = builds[fromIdx];

      let [basearch, meta] = metaList[0];

-     meta.pkgdiff = getPkgDiffFromMetaList(metaList);

+     // check if `parent-pkgdiff` field is present, if present there's no need to manually

+     // calculate pkgdiff here, use the field directly

+     // xref: https://github.com/coreos/fedora-coreos-pipeline/pull/247#event-3413080221

+     meta.pkgdiff = meta['parent-pkgdiff'] == null ? getPkgDiffFromMetaList(metaList) : meta['parent-pkgdiff'];

      sortPkgDiff(meta);

      build.meta = meta;

      // and fetch extra commit metadata in async

Previously we need to calculate the pkg diff between releases manually
from the existing build metadata. However, this will not be the case after
the build metadata includes parent-pkgdiff field which already calculates
the pkgdiffs between releases using coreos-assembler. In the future, we
should be able to completely remove the manual calculation logic from frontend
after a few releases and revert back to the same logic as fedora-coreos-browser.

Reference: https://github.com/coreos/coreos-assembler/pull/1507
Signed-off-by: Allen Bai abai@redhat.com

Sorry for the magic indexing here, the metaList is an array of metadata arrays, e.g. [ [ "x86_64", $meta.json ] ]

After there are enough releases that makes manual calculation completely out of scope, the code should be able to revert to the same as fedora-coreos-browser and the handling of magic indexing can be completely removed.

Seems reasonable to me!

Pull-Request has been merged by dustymabe

3 years ago
Metadata