Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.5.0

### Added

- Implement `buildArgs` parameter for container build

### Changed

- Handle deprecation of `redeploy: false` parameter in `UpdateContainer`

### Fixed

- When pushing a built to the remote registry, use the correct credentials instead of relying on the local docker configuration.

## 0.4.18

### Fixed
Expand Down
33 changes: 20 additions & 13 deletions deploy/lib/buildAndPushContainers.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,28 @@ module.exports = {

const { containers } = this.provider.serverless.service.custom;

const buildPromises = Object.keys(containers).map((containerName) => {
const containerConfig = Object.assign(containers[containerName], {
name: containerName,
const buildPromises = Object.keys(containers)
.map((containerName) => {
const containerConfig = {
...containers[containerName],
name: containerName,
};
return containerConfig;
})
// If directory is not specified, the container does not need to be built,
// we can directly create it from the registry image.
.filter((containerConfig) => containerConfig.directory !== undefined)
.map((containerConfig) => {
validateContainerConfigBeforeBuild(containerConfig);

return buildAndPushContainer.call(
this,
registryAuth,
auth,
containerConfig
);
});

validateContainerConfigBeforeBuild(containerConfig);

return buildAndPushContainer.call(
this,
registryAuth,
auth,
containerConfig
);
});

await Promise.all(buildPromises);
},
};
29 changes: 25 additions & 4 deletions deploy/lib/createContainers.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,18 @@ module.exports = {

this.serverless.cli.log(`Creating container ${container.name}...`);

return this.createContainer(params);
return this.createContainer(params).then((createdContainer) => {
return this.deployContainer(createdContainer.id);
});
},

async updateSingleContainer(container, foundContainer) {
// Assign domains to the container before updating it, as it's not possible to manage domains
// while the container is updating or pending, and we already wait for the container
// to be in a final status before updating it.
// => This order of operation is simpler and does not require performing two separate waits.
this.applyDomainsContainer(foundContainer.id, container.custom_domains);

let privateNetworkId = container.privateNetworkId;
const hasToDeletePrivateNetwork =
foundContainer.private_network_id && !container.privateNetworkId;
Expand Down Expand Up @@ -225,9 +233,22 @@ module.exports = {

this.serverless.cli.log(`Updating container ${container.name}...`);

// assign domains
this.applyDomainsContainer(foundContainer.id, container.custom_domains);
return this.updateContainer(foundContainer.id, params).then(
(updatedContainer) => {
// If the container is updating, no need to do anything, a redeploy is already in progress.
if (
updatedContainer.status === "pending" ||
updatedContainer.status === "updating"
) {
return updatedContainer;
}

return this.updateContainer(foundContainer.id, params);
this.serverless.cli.log(
`Redeploying container ${container.name} to apply changes...`
);

return this.deployContainer(updatedContainer.id);
}
);
},
};
2 changes: 1 addition & 1 deletion deploy/lib/deployContainers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {

this.waitDomainsAreDeployedContainer(container.id).then((domains) => {
domains.forEach((domain) => {
this.serverless.cli.log(`Domain ready : ${domain.hostname}`);
this.serverless.cli.log(`Domain ready: ${domain.hostname}`);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-scaleway-functions",
"version": "0.4.18",
"version": "0.5.0",
"description": "Provider plugin for the Serverless Framework v3.x which adds support for Scaleway Functions.",
"main": "index.js",
"author": "scaleway.com",
Expand Down
2 changes: 1 addition & 1 deletion shared/api/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require("axios");
const https = require("https");

const version = "0.4.18";
const version = "0.5.0";

const invalidArgumentsType = "invalid_arguments";

Expand Down
15 changes: 14 additions & 1 deletion tests/utils/misc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,23 @@ function sleep(ms) {

async function createProject() {
const accountApi = new AccountApi(ACCOUNT_API_URL, secretKey);
return accountApi.createProject({

// Unfortunately, there's a small delay between the creation of a project and its availability for API calls.
// We wait 1 minute to ensure there's no issue with IAM cache.
const project = await accountApi.createProject({
name: `test-slsframework-${crypto.randomBytes(6).toString("hex")}`,
organization_id: organizationId,
});

console.log(
`Project ${project.name} created, waiting for it to be available...`
);

await sleep(60000);

console.log(`Project ${project.name} is now available.`);
Comment on lines +121 to +127
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: do we want to get the project instead of waiting one minute. To be honest, I don’t really know the state of the tests in this repo, so I don’t even know whether we actually use it or not, or whether this wait really slows down the tests.

Copy link
Copy Markdown
Contributor Author

@cyclimse cyclimse Feb 26, 2026

Choose a reason for hiding this comment

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

Oh yeah, I forgot I changed it. It's a similar problem to what Leila had, when creating a project if it's not quite reconciled, when performing actions that require an IAM permission-check, you sometimes run into a permission denied that's cached for a while, failing all subsequent attempts. That's honestly what motivated to look further into the issue Leila had.

For context, the SLS FW create multiple account projects on every run, then run the tests within them.

The problem is that besides doing a sleep, there's not much we can do, because projects are not transient resources and don't expose a status. Yet, the IAM reconciliation/sync thingy is entirely async.

It genuinely seems to help, I haven't seen a permission denied in our tests since doing that, but the tests still fail randomly.

I/we need to look into it at some point, but it's a lot of effort.


return project;
}

module.exports = {
Expand Down
Loading