a month ago
I'm using the mutation "serviceInstanceLimitsUpdate" and setting the memoryGB to update my service limits, but it doesn't seem to work, service memory doesn't change.
Am i using the correct mutation?
4 Replies
a month ago
It seems like it should be the correct one, I tried doing it myself and it also doesn't seem to update the service limits.
It just returns
{"data":{"serviceInstanceLimitsUpdate":true}}
There's something wrong and team will probably take a look once they read this.
a month ago
Alright I've been experimenting for the last 2 hours and I've come to the conlusion there I'm either stupid or this functionality is completely broken lmao
I also played around with the environmentPatchCommit mutation, it was close to working but it appears service definitions are impossible because either you define it a string which causes a syntax error because it expects a name, or you dont define it as a string but then it thinks it's a number (if your service id starts with a number) and syntax errors because of that
The best (and only) workaround I managed to conjure up was using the internal GraphQL endpoint to stage and commit changes, here's some example JS code that does that
const token = "railway api token";
const environmentId = "environment id";
const serviceId = "service id";
const stage = (cpu, memoryBytes) => fetch("https://backboard.railway.com/graphql/internal?q=stageEnvironmentChanges", {
headers: {
"content-type": "application/json",
"Authorization": `Bearer ${token}`,
},
body: JSON.stringify({
query: `mutation stageEnvironmentChanges($environmentId: String!, $payload: EnvironmentConfig!) {
environmentStageChanges(environmentId: $environmentId, input: $payload) { id }
}`,
variables: {
environmentId,
payload: {
services: {
[serviceId]: {
deploy: {
limitOverride: {
containers: { cpu, memoryBytes }
}
}
}
}
}
}
}),
method: "POST"
});
const deploy = () => fetch("https://backboard.railway.com/graphql/internal?q=environmentPatchCommitStaged", {
headers: {
"content-type": "application/json",
"Authorization": `Bearer ${token}`,
},
body: JSON.stringify({
query: `mutation environmentPatchCommitStaged($environmentId: String!, $skipDeploys: Boolean) {
environmentPatchCommitStaged(environmentId: $environmentId, skipDeploys: $skipDeploys)
}`,
variables: { environmentId, skipDeploys: false }
}),
method: "POST"
});
stage(4, 2147483648) // 4 vcpu, 2gb mem
.then(res => res.json())
.then(data => {
console.log("Staged:", data);
return deploy();
})
.then(res => res.json())
.then(data => console.log("Deployed:", data))
.catch(console.error);a month ago
Good news, the team just informed me that a fix for serviceInstanceLimitsUpdate is planned after they're back from their retreat
a month ago
Nevermind, they worked faster than expected, a fix has been implemented and I confirmed that the mutation works now
Here is a working example for setting your memory limit to 6GB:
mutation UpdateServiceLimits {
serviceInstanceLimitsUpdate(input: {environmentId: "your environment id", serviceId: "your service id", memoryGB: 6 })
}Status changed to Solved dev • 28 days ago
