a year ago
I am currently having an issue with a race condition where I create a service and a volume after that, but because the service image was run before the volume was created persistent storage doesnt happen until a restart of the deployment.
I am currently using the API to create services and volumes.
I have also tried creating the service, then the volume, then removing the deployment and restarting it all sequentially, this doesnt work either. I have to remove and redeploy the service deployment after its completed the first time, only then does the volume work.
62 Replies
a year ago
Hey, maybe you can create a service and remove the deployment right after? Can I know what mutations are you using?
a year ago
mutation ServiceCreate($input: ServiceCreateInput!) {
serviceCreate(input: $input) {
id
name
icon
createdAt
updatedAt
project {
baseEnvironmentId
environments {
edges {
node {
deployments(first: 1) {
edges {
node {
id
status
}
}
}
}
}
}
}
}
}Service Create
a year ago
mutation VolumeCreate($projectId: String!, $environmentId: String!, $serviceId: String!, $mountPath: String!, $region: String!) {
volumeCreate(
input: {projectId: $projectId, environmentId: $environmentId, serviceId: $serviceId, mountPath: $mountPath, region: $region}
) {
id
name
createdAt
}
}Then Volume Create
a year ago
In this order, the first deplyoment isnt persisted
a year ago
Then I added a
mutation DeploymentRemove($id: String!) {
deploymentRemove(id: $id)
}
mutation DeploymentRedeploy($id: String!) {
deploymentRedeploy(id: $id) {
id
status
createdAt
}
}So that this runs immediately after volume creation, but it didnt seem to work either (the first deployment wast removed and redployed)
a year ago
Sorry, missed the last part of your message, so basically when you try to remove the initial deployment, nothing happens?
a year ago
yeah
a year ago
Will give it a test, give me a minute.
a year ago
I see another way of doing this, create an empty service (with no source), attach volume and then call serviceInstanceUpdate with your source.
a year ago
Thats actually not bad
a year ago
That eliminates the need for the deployments relation and all of the deployments call
a year ago
Let me give it a go
a year ago
i think i am meant to run something else after this, to actually get the deployment started
a year ago
Maybe serviceInstanceRedeploy should do the trick
a year ago
im about to try DeployV2
a year ago
if that doesnt work ill go redeploy
a year ago
Great, looks like the dashboard uses serviceInstanceDeploy
a year ago
love the help and effort with the debugging man!
a year ago
thank you so much
a year ago
moment of truth
a year ago
wtf, it just stopped
a year ago
after deploying lol
a year ago
Stopped?
a year ago
yeah
a year ago
What do you mean? the deployment stopped?
a year ago
Like removed
a year ago
I think i know why give me a second, to try again
a year ago
IT WORKS
a year ago
Ig there is just one more thing, I manually set the region on the service update, etc
a year ago
But now I get this always on the service
a year ago
a year ago
Maybe the volume or service are in different regions?
a year ago
i set them up to be the same
a year ago
After creating the empty service I do this
mutation UpdateRegions($environmentId: String!, $serviceId: String!, $multiRegionConfig: JSON!) {
serviceInstanceUpdate(
environmentId: $environmentId
serviceId: $serviceId
input: {multiRegionConfig: $multiRegionConfig}
)
}Set it to EU
a year ago
Create the Volume, in EU
a year ago
Then do this new flow
mutation serviceInstanceUpdateAndDeploy($environmentId: String!, $serviceId: String!, $image: String!, $region: String!) {
serviceInstanceUpdate(input: {source: {image: $image}, region: $region}, serviceId: $serviceId)
serviceInstanceDeployV2(environmentId: $environmentId, serviceId: $serviceId)
}Setting EU as well
a year ago
wtf, the deployment is removed now lol
a year ago
time for more tests, give me a minute again
a year ago
dont worry about this, its because the system was off
a year ago
Just a guess but maybe try serviceInstanceDeploy?
a year ago
"lastCommit": true works for images too
a year ago
will do next, rn im switching the possitions of the calls
- EmptyServiceCreate
- UpdateServiceInstanceRegionOnly
- Create Volume in same region
- Update service adding image and deploying after
a year ago
Doesnt work
a year ago
ill try this now
a year ago
Also, I see that you're using $region here, maybe continue with $multiRegionConfig?
a year ago
Yeah
a year ago
trying
a year ago
nshh
a year ago
donest work
a year ago
this is weird
a year ago
For some reason it migrates the Volume to US East
a year ago
The only reason I can see here for this is that Railway is using some kind of default region, maybe try updating the preferred region? Not a fix but can help us debug a little bit more
a year ago
Yeah isnt, because I want dynamic regions
a year ago
this worked before when I didnt have volumes
a year ago
But now with volumes its broken
a year ago
I had no problems following what you did
a year ago
Here's what I did:
ServiceCreate:
mutation ServiceCreate($input: ServiceCreateInput!) {
serviceCreate(input: $input) {
id
name
icon
createdAt
updatedAt
}
}
{
"input": {
"name": "teste",
"projectId":"40f983b6-e729-4f32-be47-346ef7d5a9c0"
}
}ServiceInstanceUpdate:
mutation update($config: JSON!) {
serviceInstanceUpdate(
environmentId: "55bc433f-96d0-4415-9814-cacf9bd1e475"
serviceId: "cfa44c0c-3f88-4a16-a465-998286082d8a"
input: {multiRegionConfig: $config, source: {image: "hello-world"}}
)
}
{
"config": {
"us-east4-eqdc4a": null,
"europe-west4-drams3a": {
"numReplicas": 1
}
}
}VolumeCreate:
mutation VolumeCreate($projectId: String!, $environmentId: String!, $serviceId: String!, $mountPath: String!, $region: String!) {
volumeCreate(
input: {projectId: $projectId, environmentId: $environmentId, serviceId: $serviceId, mountPath: $mountPath, region: $region}
) {
id
name
createdAt
}
}
{
"projectId": "40f983b6-e729-4f32-be47-346ef7d5a9c0",
"environmentId": "55bc433f-96d0-4415-9814-cacf9bd1e475",
"serviceId": "cfa44c0c-3f88-4a16-a465-998286082d8a",
"mountPath": "/data",
"region": "europe-west4-drams3a"
}ServiceDeploy:
mutation {
serviceInstanceDeploy(
latestCommit: true
serviceId: "cfa44c0c-3f88-4a16-a465-998286082d8a"
environmentId: "55bc433f-96d0-4415-9814-cacf9bd1e475"
)
}a year ago
Hmm you are forcing null on us east
a year ago
I’ll try
a year ago
It works
a year ago
You are a life saver
Status changed to Solved brody • 12 months ago