Hello guys! I'm trying to configure infracost to r...
# help
b
Hello guys! I'm trying to configure infracost to remove the old GitLab comment and add a new one (with
--behavior delete-and-new
). But, for some reason, it doesn't work. The actual behavior is the same as
new
. However,
update
works fine. So, I'm wondering if I missed something or if it doesn't work for GitLab at all?
b
Hello! Do you see any logs about deleting the comment?
b
I'm using it with Atlantis, so in its log, I see only that
infracost comment gitlab
was successfully executed. Any idea how can I debug it?
b
Try to add
INFRACOST_LOG_LEVEL=debug
in front of the command
Did it show anything?
b
Hi, @busy-agent-35515. As I mentioned, Infracost is incorporated into Atlantis workflow (
post_workflow_hooks
), so adding this env var won't show me anything in the deployment log. Let me try to figure out how I can get those logs
b
Alternatively, you can try to run the comment command locally for an existing merge request. Maybe it'll be simpler to debug this way. You'd need to generate an estimate, so you can pass it to the comment command. 1.
infracost breakdown --path=path/to/repo --format=json --out-file=infracost.yml
2.
infracost comment gitlab  --path=infracost.json ...
details here: https://www.infracost.io/docs/features/cli_commands/#gitlab You'd need to generate the GL token for that though
The logic is the following: each comment has a tag at the top of its body, CLI uses GitLab API to find comments with this matching tag. If it find them, it'll delete them via API. The logs should show if CLI finds those matching comments.
b
hah... right. it works fine... but the way it works is confusing. Maybe cuz it's not like Atlantis works, and it's just a bit unusual, but I do believe that "Atlantis way" is more convenient. And let me elaborate on why: 1. Atlantis allows superseded old plans... So, it will enable us to keep old attempts for the history. Infracost - it deletes old comments, so there is no way to track changes in Git UI. 2. When Atlantis superseded the old comment, it updated it in place, and GL UI refreshed automatically. But when infra cost removes old comments, the UI doesn't refresh. That's why I was under the impression that
delete-and-new
doesn't work. If I refresh the page, the old comment is gone.
Anyway - that's for helping me to sort it out, Vadim... Much appreciate
b
The default “update” behavior updates the comment in-place as well. The downside as this comment stays at the top of the thread. But, as you said, Atlantis does the same thing, right? Unfortunately, we can’t control GL UI :) Glad you figured it out. Let me know if you have other questions.
b
> But, as you said, Atlantis does the same thing, right? no... and that's is a key point... Atlantis "superseded" the old comment... simply put, it edited it and hid the original comment under the cat named "Superseded Atlantis Plan"... So it looks more clean
b
Ah, interesting. Infracost just replaces the whole body with update, that’s the difference. But the superseded Atlantis comment also stays in original place, right?
b
But the superseded Atlantis comment also stays in original place, right?
correct
so you can always refer to the prev run
b
Would you prefer having old comment to be in “superseded” collapsible section as well? What happens if it’s updated multiple times? Does it accumulate all versions?
I guess it’s another GL UI limitation. GitHub, for example, allows seeing previous versions of the comment
b
yes... it accumulates all versions... so if you update PR 100 times - there will be 100 comments. but... in a real life, the probability of such a case is quite low.
b
Thanks for the explanation 👍
b
so it's not a problem... at the same time, updated comments refreshed automatically, so there is no need to refresh page (like in case of infracost denete-and-new)
b
I guess you could create an issue in our GitHub proposing to mimic this behavior so people can upvote it :)
b
Thanks, @busy-agent-35515 will do it next week