Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cloudfront cache invalidation after each promotion #4262

Closed
peterzhuamazon opened this issue Dec 1, 2023 · 8 comments
Closed

Add Cloudfront cache invalidation after each promotion #4262

peterzhuamazon opened this issue Dec 1, 2023 · 8 comments
Labels
enhancement New Enhancement release

Comments

@peterzhuamazon
Copy link
Member

peterzhuamazon commented Dec 1, 2023

Add Cloudfront cache invalidation after each promotion.

We are currently manually invalidate the caches, need a mechanism to do so after running promote-repos.

Thanks.

Acceptance Criteria:

  • Save cloudfront id in the secret manager
  • Use the id to make a call with awscli to invalidate based on major version:
/releases/bundle/opensearch-dashboards/1.x/*
/releases/bundle/opensearch/1.x/*

or

/releases/bundle/opensearch-dashboards/2.x/*
/releases/bundle/opensearch/2.x/*

......
@github-actions github-actions bot added the untriaged Issues that have not yet been triaged label Dec 1, 2023
@jordarlu jordarlu added enhancement New Enhancement and removed untriaged Issues that have not yet been triaged labels Dec 5, 2023
@gaiksaya
Copy link
Member

gaiksaya commented Jan 5, 2024

All the S3 upload happens via jenkins. Found an inbuilt cloudfront invalidation for AWS jenkins plugin https://plugins.jenkins.io/pipeline-aws/#plugin-content-cfinvalidate
We need to incorporate this with all the upload steps to Prod bucket: https://github.com/search?q=repo%3Aopensearch-project%2Fopensearch-build-libraries%20ARTIFACT_PRODUCTION_BUCKET_NAME&type=code

@dblock
Copy link
Member

dblock commented Jan 9, 2024

What caches are we invalidating? It feels like most things should have a permanent URI that doesn't have files changing underneath. The only one would be for the index file in distributions that handles the redirect to latest?

@gaiksaya
Copy link
Member

gaiksaya commented Jan 9, 2024

The redirect to latest is a different set up (all things CI). This is about artifacts.opensearch.org. Whenever a new artifact is uploaded to the bucket looks we are not invalidating the cache today which results in delay in availability of the artifacts.

@peterzhuamazon
Copy link
Member Author

peterzhuamazon commented Feb 5, 2024

The invalidation here is mainly on the metadata files for YUM and APT repo, as part of the end call of https://build.ci.opensearch.org/job/distribution-promote-repos/.

Maybe this too: https://build.ci.opensearch.org/job/publish-opensearch-min-snapshots/

@jordarlu
Copy link
Contributor

jordarlu commented Feb 6, 2024

Maybe we can add cfInvalidate(distribution:'someDistributionId', paths:['/*'], waitForCompletion: true) after this line https://github.com/opensearch-project/opensearch-build-libraries/blob/2.0.2/vars/promoteRepos.groovy#L213

We will need to do AWS CLI to retrieve the CloudFront Distribution Id first, maybe something like this ?
aws cloudfront list-distributions | jq -r '.DistributionList.Items[].Id'
or
aws cloudfront list-distributions | jq -r '.DistributionList.Items[]|select(.Aliases.Items[] == "ci.opensearch.org")|.Id'

Do we expect to have more than one CloudFront distribution created on this CI account?

@peterzhuamazon
Copy link
Member Author

peterzhuamazon commented Mar 18, 2024

Maybe we can add cfInvalidate(distribution:'someDistributionId', paths:['/*'], waitForCompletion: true) after this line https://github.com/opensearch-project/opensearch-build-libraries/blob/2.0.2/vars/promoteRepos.groovy#L213

We will need to do AWS CLI to retrieve the CloudFront Distribution Id first, maybe something like this ? aws cloudfront list-distributions | jq -r '.DistributionList.Items[].Id' or aws cloudfront list-distributions | jq -r '.DistributionList.Items[]|select(.Aliases.Items[] == "ci.opensearch.org")|.Id'

Do we expect to have more than one CloudFront distribution created on this CI account?

In our case we can just save the id in secret manager as it is fixed.
And retrieve the id just like any other secrets.

@prudhvigodithi
Copy link
Member

@gaiksaya and @peterzhuamazon can we close this?
@getsaurabh02

@peterzhuamazon
Copy link
Member Author

We should, it has already been resolve in this PR:

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New Enhancement release
Projects
Development

No branches or pull requests

5 participants