-
Notifications
You must be signed in to change notification settings - Fork 13
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
Docker ratelimit ci #3679
Merged
Merged
Docker ratelimit ci #3679
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
b2c33b3
images command
busma13 9745a5f
add docker-limit-check.sh
busma13 0cf1758
disable dockerPull in e2e tests
busma13 15e46c8
update workflow to test changes
busma13 3937093
updates for testing
busma13 cc2788e
yarn sync
busma13 df49249
update command name in CI
busma13 15246f7
fix script
busma13 4b235fe
fix typo, cat image-list.txt
busma13 2ff4f43
update list
busma13 cbc92ac
add in all tests
busma13 8e2423f
wait for cache
busma13 b24bf8a
add caching to all jobs that use docker images
busma13 c8c346e
fix kafka version
busma13 a607155
update kind to load from cache in CI
busma13 7a7da43
fix kind loadServiceImage function
busma13 5a9c109
add faster pull and save images in ci
sotojn f7f28e6
add comment
busma13 8329463
remove pullServices
busma13 473ca3b
images load cmd
busma13 e991351
refactor, clean up
busma13 5fb9213
remove unused import
busma13 4af2230
update test:k8sV2 CI job
busma13 f00b1a2
add 'needs' to k8sV2 e2e job
busma13 26fa583
add quotes to docker:loadImages commands
busma13 6c6e45e
rework to load images in test-runner
busma13 ae12db0
test single job in workflow
busma13 8468be5
limit test job
busma13 ac400e9
test different job
busma13 72c732c
fix await error
busma13 35b4912
larger test
busma13 b052810
test an e2e job
busma13 262f570
test e2e only
busma13 0f16262
load base image in CI
busma13 f8ce872
move delete cache to test-runner
busma13 a408d2e
test k8s e2e
busma13 77b19bf
run all tests, skip cache download in cache-docker-images job
busma13 65011ae
clean up
busma13 81abb17
bump: (minor) @terascope/[email protected]
busma13 9f60ade
pull if cache not found
busma13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,6 @@ website/i18n/* | |
docs/packages/*/api | ||
|
||
.ts-test-config | ||
|
||
# CI test files | ||
images/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { CommandModule } from 'yargs'; | ||
import { ImagesAction } from '../helpers/images/interfaces'; | ||
import { images } from '../helpers/images'; | ||
import { GlobalCMDOptions } from '../helpers/interfaces'; | ||
|
||
interface Options { | ||
action?: ImagesAction; | ||
} | ||
|
||
const cmd: CommandModule<GlobalCMDOptions, Options> = { | ||
command: 'images <action>', | ||
describe: 'Helper function related to docker images.', | ||
builder(yargs) { | ||
return yargs | ||
.example('$0 images list', 'Get the list of docker images needed for a test.') | ||
.example('$0 images save', 'Save the docker images needed for a test.') | ||
.positional('action', { | ||
description: 'The action to take', | ||
choices: Object.values(ImagesAction), | ||
coerce(arg): ImagesAction { | ||
return arg; | ||
}, | ||
}) | ||
.requiresArg('action'); | ||
}, | ||
async handler(argv) { | ||
if (argv.action) { | ||
await images(argv.action); | ||
} | ||
}, | ||
}; | ||
|
||
export = cmd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import fse from 'fs-extra'; | ||
import execa from 'execa'; | ||
import path from 'node:path'; | ||
import * as config from '../config'; | ||
import { ImagesAction } from './interfaces'; | ||
import signale from '../signale'; | ||
|
||
export async function images(action: ImagesAction): Promise<void> { | ||
if (action === ImagesAction.List) { | ||
return createImageList(config.DOCKER_IMAGES_PATH); | ||
} | ||
|
||
if (action === ImagesAction.Save) { | ||
return saveImages(config.DOCKER_CACHE_PATH, config.DOCKER_IMAGES_PATH); | ||
} | ||
} | ||
|
||
/** | ||
* Builds a list of all docker images needed for the teraslice CI pipeline | ||
* @returns Record<string, string> | ||
*/ | ||
async function createImageList(imagesTxtPath: string): Promise<void> { | ||
const filePath = path.join(imagesTxtPath, `${config.DOCKER_LIST_FILE_NAME}`); | ||
|
||
signale.info(`Creating Docker image list at ${filePath}`); | ||
|
||
const list = 'terascope/node-base:18.19.1\n' | ||
+ 'terascope/node-base:20.11.1\n' | ||
+ 'terascope/node-base:22.2.0\n' | ||
+ `${config.ELASTICSEARCH_DOCKER_IMAGE}:6.8.6\n` | ||
+ `${config.ELASTICSEARCH_DOCKER_IMAGE}:7.9.3\n` | ||
+ `${config.OPENSEARCH_DOCKER_IMAGE}:1.3.10\n` | ||
+ `${config.OPENSEARCH_DOCKER_IMAGE}:2.8.0\n` | ||
+ `${config.KAFKA_DOCKER_IMAGE}:7.1.9\n` | ||
+ `${config.ZOOKEEPER_DOCKER_IMAGE}:7.1.9\n` | ||
+ `${config.MINIO_DOCKER_IMAGE}:RELEASE.2020-02-07T23-28-16Z\n` | ||
+ 'kindest/node:v1.30.0'; | ||
|
||
if (!fse.existsSync(imagesTxtPath)) { | ||
await fse.emptyDir(imagesTxtPath); | ||
} | ||
fse.writeFileSync(filePath, list); | ||
} | ||
|
||
async function saveAndZip(imageName:string, imageSavePath: string) { | ||
const fileName = imageName.replace(/[/:]/g, '_'); | ||
const filePath = path.join(imageSavePath, `${fileName}.tar`); | ||
const command = `docker save ${imageName} | gzip > ${filePath}.gz`; | ||
await execa.command(command, { shell: true }); | ||
} | ||
|
||
async function saveImages(imageSavePath: string, imageTxtPath: string): Promise<void> { | ||
try { | ||
if (fse.existsSync(imageSavePath)) { | ||
fse.rmSync(imageSavePath, { recursive: true, force: true }); | ||
} | ||
fse.mkdirSync(imageSavePath); | ||
const imagesString = fse.readFileSync(path.join(imageTxtPath, config.DOCKER_LIST_FILE_NAME), 'utf-8'); | ||
const imagesArray = imagesString.split('\n'); | ||
const pullPromises = imagesArray.map(async (imageName) => { | ||
signale.info(`Pulling Docker image ${imageName}`); | ||
await execa.command(`docker pull ${imageName}`); | ||
}); | ||
await Promise.all(pullPromises); | ||
|
||
for (let i = 0; i < imagesArray.length; i += 2) { | ||
if (typeof imagesArray[i + 1] === 'string') { | ||
await Promise.all([ | ||
saveAndZip(imagesArray[i], imageSavePath), | ||
saveAndZip(imagesArray[i + 1], imageSavePath) | ||
]); | ||
} else { | ||
await saveAndZip(imagesArray[i], imageSavePath); | ||
} | ||
} | ||
} catch (err) { | ||
throw new Error(`Unable to pull and save images due to error: ${err}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum ImagesAction { | ||
List = 'list', | ||
Save = 'save' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
### | ||
## This checks the docker rate limit | ||
### | ||
TOKEN=$(curl -Ss --user "$USER:$PASS" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) | ||
result=$(curl -Ss --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest) | ||
|
||
echo "$result" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how the
<(gunzip ..)
subprocess would work without theshell=true
option.