Which mutations to update scale count and regions with the graphql api?

There’s a few mutations that sort of seem like what I’m looking for, but they don’t seem to quite do what I’m hoping. My goal is to be able to set it to run say 3 VMs, in regions sea, fra, and nrt.

I’ve tried this, which seems like exactly what I’d want:

mutation scaleApp{
  scaleApp(input: {
    appId: "myappid",
    regions: [{region: "sea", count: 1}, {region: "fra", count: 1}, {region: "nrt", count: 1}]
  }){
    delta {
      fromCount,
      region,
      toCount
    },
    placement {
      count,
      region
    }
  }
}

Which returns:

{
  "data": {
    "scaleApp": {
      "delta": [],
      "placement": [
        {
          "count": 0,
          "region": "ams"
        },
        {
          "count": 1,
          "region": "fra"
        },
        {
          "count": 1,
          "region": "lax"
        },
        {
          "count": 1,
          "region": "nrt"
        },
        {
          "count": 1,
          "region": "sea"
        },
        {
          "count": 0,
          "region": "sin"
        },
        {
          "count": 0,
          "region": "syd"
        }
      ]
    }
  }
}

But when I check the status or regions with flyctl they’ll be totally different:

REGION DESIRED STATUS  HEALTH CHECKS      RESTARTS CREATED              
lax(B) run     running 1 total, 1 passing 0        2021-06-23T00:36:46Z 
lax(B) run     running 1 total, 1 passing 1        2021-06-23T00:36:46Z 
ams(B) run     running 1 total, 1 passing 3        2021-06-01T10:16:28Z 

I know the way VMs are placed isn’t always straight forward, but I feel like I’m missing something here.

There’s also a bunch of extra regions tied to the app, so I’m guessing the scaleApp mutation is additive and not replacing the list. Do I need to remove the others as well?

Ah that’s an old mutation we should remove.

What you want is setVmCount and configureRegions

1 Like

Thanks, that makes sense, I’ll use those.

Hey michael, I think I found a graphql bug:

If I try to set configureRegions to allow only scl or gru and deny all others, I get an error saying there must be at least one region set. I don’t get the error if there are multiple, or if I solely allow any of the other regions on their own, just scl or gru.

This is the exact query that gives me the error:

mutation scaleCount{
  setVmCount(input: {
    appId: "myappid",
    groupCounts: [{group: "app", count: 1}]
  }){
    app {
      regions {
        code,
        name
      },
      deploymentStatus {
        desiredCount,
        inProgress,
        allocations{
          region,
        }
      }
    },
    warnings,
    taskGroupCounts {count, name}
  }
  
  configureRegions(input: {
    appId: "myappid",
    allowRegions: ["scl"]
    denyRegions: ["atl", "gru", "sea", "ord", "iad", "hkg", "lhr", "lax", "cdg", "ewr", "nrt", "sin", "sjc", "syd", "dfw", "yyz", "vin"]
  }){
    regions{
      code,
      name
    }
  }
  
}