atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

Automerge happens on an apply of 0 projects

Open grimm26 opened this issue 3 years ago • 8 comments

I just upgraded to atlantis 0.17.1 from 0.17.0 and I'm using it with a GitHub Enterprise instance. When I did the atlantis upgrade, there were a couple of pull requests that were planned and approved but had not yet been applied. Someone ran an atlantis apply on them and they applied and automerged. The apply was for 0 projects because there was no plan in play, but it still called that apply successful and then automerged. The log showed:

{
    "level": "info",
    "ts": "2021-06-29T14:31:03.359Z",
    "caller": "events/apply_command_runner.go:110",
    "msg": "pull request mergeable status: true",
    "json": {
        "repo": "terraforms/production",
        "pull": "6111"
    }
}
{
    "level": "info",
    "ts": "2021-06-29T14:31:04.623Z",
    "caller": "events/automerger.go:31",
    "msg": "automerging pull request",
    "json": {
        "repo": "terraforms/production",
        "pull": "6111"
    }
}

I tried to reproduce this by creating a new PR, planning and approving it, then unlocking it from the atlantis UI and then trying an apply. It still did the 0 projects apply, but it did not automerge.
When I looked at the log, it shows "

{
    "level": "info",
    "ts": "2021-06-29T17:09:23.608Z",
    "caller": "events/apply_command_runner.go:110",
    "msg": "pull request mergeable status: false",
    "json": {
        "repo": "terraforms/production",
        "pull": "6128"
    }
}

{
    "level": "info",
    "ts": "2021-06-29T17:09:24.335Z",
    "caller": "events/automerger.go:19",
    "msg": "not automerging because project at dir \"infrastructure/staging/junk\", workspace \"default\" has status \"plan_discarded\"",
    "json": {
        "repo": "terraforms/production",
        "pull": "6128"
    }
}

So I assume there must be a saved state in the second case to show that the plan was discarded. Why does the first one go ahead with applying a merging when it applied 0 projects and there was obviously no plan to begin with?

grimm26 avatar Jun 29 '21 18:06 grimm26

Is it possible that when you upgraded, atlantis' boltdb instance got deleted? Atlantis stores pull request specific states inside its boltdb instance, so one explanation could be that the db was wiped during upgrade.

msarvar avatar Jul 13 '21 04:07 msarvar

Is it possible that when you upgraded, atlantis' boltdb instance got deleted? Atlantis stores pull request specific states inside its boltdb instance, so one explanation could be that the db was wiped during upgrade.

@msarvar Absolutely. I run atlantis as an AWS fargate task, so the new task had a new container. I'm fully aware of that. I just wonder why atlantis would allow an apply to be run on a Pull Request that did not have a valid plan and had changes.

grimm26 avatar Jul 13 '21 14:07 grimm26

FYI, my only workaround for this is that whenever I refresh atlantis is to run a script that comments atlantis plan on all open PRs. That does also help with the annoying error from https://github.com/runatlantis/atlantis/issues/1067

grimm26 avatar Jul 13 '21 14:07 grimm26

looks to be related to https://github.com/runatlantis/atlantis/issues/1264 and https://github.com/runatlantis/atlantis/issues/1575

grimm26 avatar Jul 14 '21 15:07 grimm26

@msarvar if only I could add a waiting-on-response-response tag

grimm26 avatar Jul 26 '21 19:07 grimm26

@grimm26 Sorry for the wait, but looks like other similar issues were marked already. So I will update the tags accordingly.

msarvar avatar Jul 27 '21 19:07 msarvar

is this still an issue with v0.19.8?

jamengual avatar Aug 26 '22 02:08 jamengual

Sometimes I see this even on the latest version, but I have no idea how to repro, it seems totally ittermitent.

Dilergore avatar Sep 09 '22 06:09 Dilergore