|
| 1 | +# Use Package Storage v2 |
| 2 | + |
| 3 | +## What is the Package Storage v2? |
| 4 | + |
| 5 | +Package Storage v2 is the successor of the [package-storage](https://github.com/elastic/package-storage) Git repository, |
| 6 | +and it is composed of Google Cloud buckets, service accounts and jobs responsible for maintenance including publishing and indexing. |
| 7 | + |
| 8 | +The Package Storage v2 is available publicly behind the endpoint: [package-storage.elastic.co](https://package-storage.elastic.co/) |
| 9 | +and exposes different package resources: |
| 10 | +* zipped packages (e.g. [barracuda-0.2.2.zip](https://package-storage.elastic.co/artifacts/packages/barracuda-0.2.2.zip)) |
| 11 | +* package signatures (e.g. barracuda-0.2.2 [signature](https://package-storage.elastic.co/artifacts/packages/barracuda-0.2.2.zip.sig)) |
| 12 | +* extracted static resources (e.g. cisco-0.11.5 [screenshot](https://package-storage.elastic.co/artifacts/static/cisco-0.11.5/img/kibana-cisco-asa.png)) |
| 13 | + |
| 14 | +The Package Storage v2 has flat structure. It does not introduce any logic to divide packages into stages or a control panel to promote them. |
| 15 | +We recommend to use proper versioning instead and follow these rules: |
| 16 | +* a package with `version < 1.0.0` is a technical preview. |
| 17 | +* a package with `version >= 1.0.0` can contain prerelease tags (beta1, SNAPSHOT, next) on its version to indicate its prerelease state. |
| 18 | + |
| 19 | +## What is the goal of storage migration from v1 to v2? |
| 20 | + |
| 21 | +We identified a few issues in v1 design, we couldn't easily overcome or patch: |
| 22 | +1. Automatically release new Docker images of the Package Storage without missing packages due to a race condition |
| 23 | + between CI jobs. |
| 24 | +2. Control the Docker image size, which is constantly growing (as of today, >1GB). Packages with size >1GB must be served through the Package Registry too. |
| 25 | +3. Deprecate promotion between stages. It caused a lot of frustration for package developers and most of them didn't follow the recommended promotion path |
| 26 | + `snapshot -> staging -> production`. |
| 27 | +4. Enable validation for incoming packages (spec and signatures). |
| 28 | +5. Support package signatures. It wasn't possible to calculate the signature for unarchived package directories. |
| 29 | + |
| 30 | +## What should a package owner do to automatically publish their packages? |
| 31 | + |
| 32 | +### Existing packages |
| 33 | + |
| 34 | +Package revisions already deployed in the production Package Storage (present in the `production` branch of the [package-storage](https://github.com/elastic/package-storage)) |
| 35 | +are automatically synced with the new storage. In this case we disable the validation as some older packages will not be able |
| 36 | +to pass current spec requirements. |
| 37 | + |
| 38 | +Sync between v1 and v2 will be enabled until we officially deprecate the v1 storage (no more PRs or promotions). |
| 39 | + |
| 40 | +### Next revisions |
| 41 | + |
| 42 | +Before we deprecate the v1 storage, package owners will have to adjust their releasing pipelines to submit packages |
| 43 | +to the new destination. Every package candidate should be submitted together with a corresponding signature, generated |
| 44 | +using the [Elastic signing pipeline](https://internal-ci.elastic.co/job/elastic+unified-release+master+sign-artifacts-with-gpg/). |
| 45 | + |
| 46 | +Here is the list of requirements and code modifications based on the `beats-ci`. |
| 47 | + |
| 48 | +#### Requirements |
| 49 | + |
| 50 | +1. CI job signing credentials (`sign-artifacts-with-gpg-job`) - use them to call the signing pipeline on |
| 51 | + the `internal-ci` Jenkins instance. The pipeline will sign artifacts uploaded to the signing bucket and upload there their signatures. |
| 52 | +2. Signing bucket credentials (`internal-ci-gcs-plugin`) - use them to upload zipped packages to be signed |
| 53 | + and download matching signatures. |
| 54 | +3. Package Storage GCP uploader credentials (`upload-package-to-package-storage`) - use them to upload a package candidate to the "queue" bucket. |
| 55 | + The candidates will be picked by the publishing job and removed after processing. |
| 56 | +4. Package Storage uploader secret (`secret/gce/elastic-bekitzur/service-account/package-storage-uploader`) - use it to kick off |
| 57 | + the publishing job to process the uploaded candidate. |
| 58 | + |
| 59 | +#### Code modifications |
| 60 | + |
| 61 | +These code modifications refer to the Jenkinsfile/groovy files, which will orchestrate the Jenkins worker to sign the package |
| 62 | +and publish it using the Package Storage publishing job. |
| 63 | + |
| 64 | +Function [packageStoragePublish(...)](https://github.com/elastic/elastic-package/blob/f8f678d20b9b60d438188e8dfd2fb4e7519b5a69/.ci/package-storage-publish.groovy#L70) |
| 65 | + |
| 66 | +##### Sign the package candidate |
| 67 | + |
| 68 | +Function [signUnpublishedArtifactsWithElastic(...)](https://github.com/elastic/elastic-package/blob/f8f678d20b9b60d438188e8dfd2fb4e7519b5a69/.ci/package-storage-publish.groovy#L87-L122). |
| 69 | + |
| 70 | +1. Check if the package has been already published (HTTP request to EPR). |
| 71 | +2. Upload the package candidate to the signing bucket. |
| 72 | +3. Call the Elastic signing pipeline to create matching signatures. The pipeline signs them using the Elastic private key. |
| 73 | +4. Once the job succeeded, download package signatures. |
| 74 | + |
| 75 | +##### Publish the package candidate |
| 76 | + |
| 77 | +Function [uploadUnpublishedToPackageStorage(...)](https://github.com/elastic/elastic-package/blob/f8f678d20b9b60d438188e8dfd2fb4e7519b5a69/.ci/package-storage-publish.groovy#L124-L151). |
| 78 | + |
| 79 | +1. Check if the package has been already published (HTTP request to EPR). |
| 80 | +2. Upload the package candidate to the special "queue" bucket - `elastic-bekitzur-package-storage-internal`. |
| 81 | +3. Call the [publishing job](https://internal-ci.elastic.co/job/package_storage/job/publishing-job-remote/). The publishing jobs verifies |
| 82 | + correctness of the package format and corresponding signature. Next, the job extracts static resources, uploads the zipped package |
| 83 | + to the public bucket, and schedules indexing in background. |
0 commit comments