Skip to content

Conversation

@mtojek
Copy link
Contributor

@mtojek mtojek commented Dec 14, 2021

This PR modifies the Jenkinsfile to call the Infra singing pipeline to sign package artifacts using Elastic public key.

Summing up:

CI test builds the package, cross-call the internal CI to sign it, fetches signature, and archives them. It proves that we can freely call the internal-ci pipeline from beats-ci.

@mtojek mtojek self-assigned this Dec 14, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 14, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Reason: null

  • Start Time: 2022-01-28T15:42:29.214+0000

  • Duration: 30 min 17 sec

  • Commit: 9cc2640

Test stats 🧪

Test Results
Failed 0
Passed 471
Skipped 0
Total 471

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

.ci/Jenkinsfile Outdated
pattern: 'build/integrations/*.zip',
sharedPublicly: false,
showInline: true)
build(wait: true, propagate: true, job: 'elastic+unified-release+master+sign-artifacts-with-gpg',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @v1v,

I think I have just understood the architecture used by the apm-agent-php to sign their artifacts. It's a bit different than I imagined :) Let me know if I'm correct - the signing procedure is executed in the internal-ci, but not only the signing step but the entire pipeline (see: internal-ci, apm-ci).

Let's consider the elastic/integrations:
I was wondering if there is an option to support it without re-running the entire Integrations pipeline in the internal-ci, but just call the signing pipeline there?

Otherwise, I understand that we need a similar JJB in the internal-ci for elastic/integrations, which will run just building (not testing), signing, and publishing to the Package Storage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that I can close this PR - I tried to build a PoC or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought:

is there an option to use the remote API? so that any Elastic pipeline (with auth) can trigger a build in the internal-ci instance?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an option to use the remote API? so that any Elastic pipeline (with auth) can trigger a build in the internal-ci instance?

IIRC, I think there is no such a integration, though let me dig a bit into what we discussed for the php agent in case those questions were also answered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm afraid that it will force package owners to create artificial pipelines just to reach out to the internal-ci pipeline, which seems to be an unnecessary step if we have such an API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid I could not find something that validates my hypothesis , so I just asked the infra-automation team, you are also poked in that particular conversation. To be clear, the conversation is outside of this thread, but I'll comment here the outcome

@mtojek mtojek requested a review from v1v December 16, 2021 17:20
@mtojek
Copy link
Contributor Author

mtojek commented Jan 13, 2022

/test

@mtojek mtojek requested a review from a team January 28, 2022 16:06
@mtojek mtojek marked this pull request as ready for review January 28, 2022 16:06
@mtojek mtojek requested a review from jsoriano January 28, 2022 16:17
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice to see we can sign things by calling this job.

useCrumbCache: true,
useJobInfoCache: true)
}
googleStorageDownload(bucketUri: "${env.INFRA_SIGNING_BUCKET_SIGNED_ARTIFACTS_PATH}/*",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this downloading all the packages ever signed? Or there is some cleanup process for the signed artifacts path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be ownest with you I have never tried downloading everything in that bucket as it could kill the CI worker :D It's the same job we're using to sign Beats artifacts.

triggerRemoteJob(auth: CredentialsAuth(credentials: 'local-readonly-api-token'),
job: 'https://internal-ci.elastic.co/job/elastic+unified-release+master+sign-artifacts-with-gpg',
token: TOKEN,
parameters: "gcs_input_path=${env.INFRA_SIGNING_BUCKET_ARTIFACTS_PATH}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, does this job check that this path belongs to elastic? In case somehow a malicious pipeline triggers this job to sign anything placed in a bucket with public access.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The job is configured in the internal-ci instance, so the malicious user should be also internal?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering more about a change in the Jenkinsfile in a PR.

credentialsId: env.INTERNAL_CI_JOB_GCS_CREDENTIALS,
localDirectory: "${env.INTEGRATIONS_SIGNATURES_PATH}/",
pathPrefix: "${env.INFRA_SIGNING_BUCKET_SIGNED_ARTIFACTS_SUBFOLDER}")
sh(label: 'Rename .asc to .sig', script: 'for f in ' + "${env.INTEGRATIONS_SIGNATURES_PATH}" + '/*.asc; do mv "$f" "${f%.asc}.sig"; done')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to encapsulate these steps of uploading, signing, downloading and renaming into a single signArtifacts helper 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they will be encapsulated. I'm planning to wrap (signing + push to Package Storage) into a single command. I have to make sure the push works correctly.

@mtojek mtojek merged commit 22521be into elastic:main Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants