-
Notifications
You must be signed in to change notification settings - Fork 140
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
Creating a buildx fails when using matrix strategy on self hosted runners #47
Comments
Hi @crazy-max, how about changing the name generation from this line and this line to be a random generated number and then verify if the builder exists already with the ls? Something like: On main.ts: const builderName: string =
inputs.driver == 'docker' ? 'default' : `${(await buildx.generateNewName(builder-${process.env.GITHUB_JOB}))}`;
core.setOutput('name', builderName);
stateHelper.setBuilderName(builderName); On buildx.ts: export async function nameExists(name: string): Promise<boolean> {
return await exec.exec(`docker`, ['buildx', 'ls'], true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(`Cannot list builders: ${res.stderr}`);
}
for (const line in res.stdout.trim().split(`\n`)) {
if (line.split(` `)[0] == name) {
return true;
}
}
return false;
});
}
function getRandomInt() {
return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);
}
export async function generateNewName(namePrefix: string): Promise<string> {
let name = "";
do {
name = namePrefix+getRandomInt()
} while (await nameExists(name)) ;
return name;
} Do you think that this could impact other things? Note: My javascript is very basic and I hadn't used it in a long time so this probably has a lot of errors but that's the idea. |
Hi @crazy-max thanks for the quick fix but it's actually still failing:
So the new naming is correct, but when booting up the builder a different (already existing) name is logged, and doing a |
@malkam03 I will make some changes about this one. Thanks for your feedback. |
@malkam03 Ok can you try again with |
This works perfect! Thank you @crazy-max 😄 |
Behavior
When creating a builder instance using GitHub's matrix strategy to build multiple images in parallel the
Creating a new builder instance
action step fails with an error that looks related to the naming strategy used to create new builders:Probably related to this line?
Steps to reproduce this issue
setup-buildx-action
to the workflowExpected behavior
Actual behavior
Configuration
The text was updated successfully, but these errors were encountered: