Channels
  • b

    Bryce Bonvillain

    4 months ago
    Hey everyone, does anyone have any issues with MR comments not updating? My pipeline keeps creating new comments despite passing the update bahavior perimeter. Ive tried changing the tagging as well from the default. This is my current gitlab-ci command:
    - infracost comment gitlab
          --gitlab-server-url $CI_SERVER_URL
          --gitlab-token $GITLAB_TOKEN
          --path infracost.json
          --repo $CI_PROJECT_PATH
          --merge-request $CI_MERGE_REQUEST_IID
          --behavior update
    
    Logs:
    time="2022-02-25T14:44:44Z" level=info msg="Finding matching comments for tag infracost-comment"
    time="2022-02-25T14:44:44Z" level=info msg="Found 0 matching comments"
    time="2022-02-25T14:44:44Z" level=info msg="Creating new comment"
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Hey Bryce! Interesting šŸ¤”
    Can you see the text of the existing comments? At the very top they should have
    [//]: <> (infracost-comment)
    markdown comment. That's how we track them. It should be visible in comment's editor
  • b

    Bryce Bonvillain

    4 months ago

    [//]: <> (infracost)
    
    šŸ’° Infracost estimate: **monthly cost will not change**
    <table>
      <thead>
        <td>Project</td>
        <td>Previous</td>
        <td>New</td>
        <td>Diff</td>
      </thead>
      <tbody>
        <tr>
          <td>mmsys/fed/EMR/terraform/test.json</td>
          <td align="right">$0</td>
          <td align="right">$0</td>
          <td>$0</td>
        </tr>
      </tbody>
    </table>
    
    <details>
    <summary><strong>Infracost output</strong></summary>
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Hm, okay. So this comment has the tag
    infracost
    . If you use the CI command without the
    --tag infracost
    flag, it will start searching for
    infracost-comment
    . So this one won't be matched.
    Are there other comments?
  • b

    Bryce Bonvillain

    4 months ago
    So I am trying this locally as well:
    [//]: <> (infracost-comment)
    
    šŸ’° Infracost estimate: **monthly cost will not change**
    <table>
      <thead>
        <td>Project</td>
        <td>Previous</td>
        <td>New</td>
        <td>Diff</td>
      </thead>
      <tbody>
        <tr>
          <td>mmsys/fed/EMR/terraform/mmsys-preprod-plan.out.json</td>
          <td align="right">$0</td>
          <td align="right">$0</td>
          <td>$0</td>
        </tr>
      </tbody>
    </table>
    
    <details>
    <summary><strong>Infracost output</strong></summary>

    this comes from
    infracost comment gitlab \ 
    --gitlab-server-url <https://gitlab.com> \
    --repo mmsys/fed/EMR \
    --merge-request 10 \
    --tag GITLAB_TOKEN_FED_EMR \
    --path infracost.json \
    --behavior update \
    --gitlab-token $TOKEN \
    --log-level debug

    if I run this again I still see
    time="2022-02-25T16:46:45+01:00" level=info msg="Finding matching comments for tag GITLAB_TOKEN_FED_EMR"
    time="2022-02-25T16:46:45+01:00" level=info msg="Found 0 matching comments"
    time="2022-02-25T16:46:45+01:00" level=info msg="Creating new comment"
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Is
    GITLAB_TOKEN_FED_EMR
    and env var or a tag value?
  • b

    Bryce Bonvillain

    4 months ago
    no its just a string
    for testing purposes
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    From the command it will be treated as a string, and if there are no any other comments with
    GITLAB_TOKEN_FED_EMR
    in them, it won't match. Could you please change your TF file and push it again? Currently I'm seeing you using 3 different tags (default one,
    infracost
    and
    GITLAB_TOKEN_FED_EMR
    )
    As you already have one comment with
    infracost
    tag, could you try to use
    --tag infracost
    ?
    BTW, I just tested the command on our demo app, it worked as expected. Although it's not a self-hosted version https://gitlab.com/infracost/gitlab-ci-demo/-/merge_requests/26#note_855633119
  • b

    Bryce Bonvillain

    4 months ago
    Well, I've been cleaning up the multiple comments šŸ˜† and trying to experiment locally which is where the other tags came from
    I will try another build with the following commands:
    - infracost breakdown --sync-usage-file
          --usage-file infracost-usage.yml
          --format json --path ${PLAN}.json
          --out-file infracost.json
    
        - infracost comment gitlab
          --gitlab-server-url $CI_SERVER_URL
          --gitlab-token $GITLAB_TOKEN
          --path infracost.json
          --tag infracost
          --repo $CI_PROJECT_PATH
          --merge-request $CI_MERGE_REQUEST_IID
          --behavior update

    creating a comment
    [//]: <> (infracost)
    
    šŸ’° Infracost estimate: **monthly cost will not change**
    <table>
      <thead>
        <td>Project</td>
        <td>Previous</td>
        <td>New</td>
        <td>Diff</td>
      </thead>
      <tbody>
        <tr>
          <td>mmsys/fed/EMR/terraform/mmsys-preprod-plan.out.json</td>
          <td align="right">$0</td>
          <td align="right">$0</td>
          <td>$0</td>
        </tr>
      </tbody>
    </table>
    
    <details>
    <summary><strong>Infracost output</strong></summary>
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Okay, looks correct. Let's change a TF file and re-run the comment command šŸ™‚
  • b

    Bryce Bonvillain

    4 months ago
    sure
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    FYI if there are no any changes in the output, the command won't post anything
  • b

    Bryce Bonvillain

    4 months ago
    Just changing some s3 bucket names...
    $ infracost comment gitlab --gitlab-server-url $CI_SERVER_URL --gitlab-token $GITLAB_TOKEN --path infracost.json --tag infracost --repo $CI_PROJECT_PATH --merge-request $CI_MERGE_REQUEST_IID --behavior update
    time="2022-02-25T16:01:40Z" level=info msg="Finding matching comments for tag infracost"
    time="2022-02-25T16:01:41Z" level=info msg="Found 0 matching comments"
    time="2022-02-25T16:01:41Z" level=info msg="Creating new comment"

  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Seems like a bug. Do both comments have the
    infracost
    tag?
  • b

    Bryce Bonvillain

    4 months ago
    yah, its the same build same commands adjusting some bucket names in the terraform code
    image:
        name: infracost/infracost:ci-0.9

    full comment, if it helps
    [//]: <> (infracost)
    
    šŸ’° Infracost estimate: **monthly cost will not change**
    <table>
      <thead>
        <td>Project</td>
        <td>Previous</td>
        <td>New</td>
        <td>Diff</td>
      </thead>
      <tbody>
        <tr>
          <td>mmsys/fed/EMR/terraform/mmsys-preprod-plan.out.json</td>
          <td align="right">$0</td>
          <td align="right">$0</td>
          <td>$0</td>
        </tr>
      </tbody>
    </table>
    
    <details>
    <summary><strong>Infracost output</strong></summary>
    Project: mmsys/fed/EMR/terraform/mmsys-preprod-plan.out.json + module.s3_log_storage.aws_s3_bucket.default[0] Monthly cost depends on usage + Standard + Storage Monthly cost depends on usage +$0.0245 per GB + PUT, COPY, POST, LIST requests Monthly cost depends on usage +$0.0054 per 1k requests + GET, SELECT, and all other requests Monthly cost depends on usage +$0.00043 per 1k requests + Select data scanned Monthly cost depends on usage +$0.00225 per GB + Select data returned Monthly cost depends on usage +$0.0008 per GB + Standard - infrequent access + Storage Monthly cost depends on usage +$0.0135 per GB + PUT, COPY, POST, LIST requests Monthly cost depends on usage +$0.01 per 1k requests + GET, SELECT, and all other requests Monthly cost depends on usage +$0.001 per 1k requests + Retrievals Monthly cost depends on usage +$0.01 per GB + Select data scanned Monthly cost depends on usage +$0.00225 per GB + Select data returned Monthly cost depends on usage +$0.01 per GB + Glacier flexible retrieval + Storage Monthly cost depends on usage +$0.00405 per GB + PUT, COPY, POST, LIST requests Monthly cost depends on usage +$0.036 per 1k requests + GET, SELECT, and all other requests Monthly cost depends on usage +$0.00043 per 1k requests + Retrieval requests (standard) Monthly cost depends on usage +$0.036 per 1k requests + Retrievals (standard) Monthly cost depends on usage +$0.012 per GB + Select data scanned (standard) Monthly cost depends on usage +$0.0096 per GB + Select data returned (standard) Monthly cost depends on usage +$0.012 per GB + Retrieval requests (expedited) Monthly cost depends on usage +$12.00 per 1k requests + Retrievals (expedited) Monthly cost depends on usage +$0.036 per GB + Select data scanned (expedited) Monthly cost depends on usage +$0.024 per GB + Select data returned (expedited) Monthly cost depends on usage +$0.036 per GB + Select data scanned (bulk) Monthly cost depends on usage +$0.0012 per GB + Select data returned (bulk) Monthly cost depends on usage +$0.003 per GB + Early delete (within 90 days) Monthly cost depends on usage +$0.00405 per GB Monthly cost change for mmsys/fed/EMR/terraform/mmsys-preprod-plan.out.json Amount: $0.00 ($0.00 ā†’ $0.00) ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ Key: ~ changed, + added, - removed 37 cloud resources were detected: āˆ™ 1 was estimated, 1 includes usage-based costs, see https://infracost.io/usage-file āˆ™ 1 wasn't estimated, report it in https://github.com/infracost/infracost: āˆ™ 1 x aws_emr_cluster āˆ™ 35 were free: āˆ™ 8 x aws_security_group_rule āˆ™ 5 x aws_security_group āˆ™ 3 x aws_iam_role āˆ™ 3 x aws_iam_role_policy_attachment āˆ™ 2 x aws_network_acl āˆ™ 2 x aws_route_table āˆ™ 2 x aws_route_table_association āˆ™ 2 x aws_subnet āˆ™ 1 x aws_default_security_group āˆ™ 1 x aws_iam_instance_profile āˆ™ 1 x aws_internet_gateway āˆ™ 1 x aws_key_pair āˆ™ 1 x aws_route āˆ™ 1 x aws_s3_bucket_public_access_block āˆ™ 1 x aws_vpc āˆ™ 1 x aws_vpc_endpoint
    </details>
    
    This comment will be updated when the cost estimate changes.
    
    <sub>
      Is this comment useful? <a href="<https://www.infracost.io/feedback/submit/?value=yes>" rel="noopener noreferrer" target="_blank">Yes</a>, <a href="<https://www.infracost.io/feedback/submit/?value=no>" rel="noopener noreferrer" target="_blank">No</a>
    </sub>
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Thank you very much for helping with the debug! May I ask what version of GitLab you're using? Is it Enterprise Edition?
  • b

    Bryce Bonvillain

    4 months ago
    GitLab Enterprise Edition 13.12.9-ee
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    We are using GitLab GraphQL API to fetch the MR comments. It works with the cloud version as I mentioned above, so I assume there might be something up with EE's API.
  • b

    Bryce Bonvillain

    4 months ago
    the big sad šŸ˜­, in the meanwhile maybe I can post to slack or so instead
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    We always want to know more how our users use Infracost. May I ask how often do you push to the same MR and are the new comments too noisy for you?
    If you have couple more minutes, maybe you'd be able to run a curl command to the API? Maybe we can see what it returns and pinpoint the issue
    Also, maybe you know the API scope of the access token? It should be
    api
    for read and write requests
  • b

    Bryce Bonvillain

    4 months ago
    This is a new project to move to gitlab from some legacy stuff, it will be used quite heavily in the future. I guess merge request can get quite noisy if it post a comment every commit push
    the token is read/write for the repo and has full api access
    I can maybe test a curl command or two šŸ˜Ž
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Haha, nice. Thank you šŸ™ Let me prepare it and I'll get back to you asap.
  • b

    Bryce Bonvillain

    4 months ago
    sure
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Sorry for the delay. Here's the command
    curl -X POST \
    -H "Authorization: Bearer $GITLAB_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"query": "{project(fullPath: \"mmsys/fed/EMR\") {mergeRequest(iid: \"10\") {notes { nodes {id url createdAt body}}}}}"}' \
    $CI_SERVER_URL
    I think you just need to have the token and the url env vars set up and it should work. Well, we'll see šŸ˜„
  • b

    Bryce Bonvillain

    4 months ago
    with that curl I am unfortunately getting a 404 return šŸ˜ž
    <title>The page you're looking for could not be found (404)</title>
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    hey Bryce. My bad, the url should be
    $CI_SERVER_URL/api/graphql
    if it's the same as for the gitlab.com. Could you please try again?
  • b

    Bryce Bonvillain

    4 months ago
    {"data":{"project":null}}%
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Okay, this response can explain the 0 matching comments. Now need to figure out how to actually get something back
    Will try to replicate same structure of the project with community edition, will see if it works there. Thanks for running the requests.
    Hey Bryce! May I ask you how is the repo name formed? GitLab cloud/CE doesn't allow to use slashes in the name, and your full path has two. I suspect this may be an issue for the GraphQL API. However I'm confused as it worked for posting the comment apparently (we use REST API for posting). I've tried the curl request on an local CE server and that's how the result looks like for no results:
    {"data":{"project":{"mergeRequest":{"notes":{"nodes":[]}}}}}%
    and with one comment returned:
    {"data":{"project":{"mergeRequest":{"notes":{"nodes":[{"id":"<gid://gitlab/Note/1>","url":"<http://gitlab.example.com/root/terraform-test/-/merge_requests/1#note_1>","createdAt":"2022-03-01T11:04:04Z","body":"foobar"}]}}}}}%
  • b

    Bryce Bonvillain

    4 months ago
    .com/mmsys/fed/EMR

    mr url
    com/mmsys/fed/EMR/-/merge_requests/10
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Is
    mmsys
    the org and
    fed/EMR
    a project name? Or
    mmsys/fed
    and
    EMR
    ? Sorry, I don't have much experience with GitLab, so trying to understand where to investigate next šŸ™‚
  • b

    Bryce Bonvillain

    4 months ago
    mmsys is the parent group, then a sub group of FED
    EMR is the repo name
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    Reproduced the issue with replicated group/subgroup/repo project. First, I saw the same response you receive and thought something's wrong with the API. I tried
    Project Access Tokens
    with api or all scopes. Then I switched the test repo to be public and the curl request started to return proper data. And then I use
    Personal Access Token
    with api scope and private repo - it also worked. Here's the response
    {"data":{"project":{"mergeRequest":{"notes":{"nodes":[{"id":"<gid://gitlab/Note/2>","url":"<http://gitlab.example.com/mssys/fed/emr/-/merge_requests/1#note_2>","createdAt":"2022-03-01T16:22:55Z","body":"foobar"}]}}}}}%
    The
    infracost comment
    command also worked with that access token. Could you please double check what kind of token do you use?
  • b

    Bryce Bonvillain

    4 months ago
    I was using a Repo user access token, but I can try with a personal token to verify
    Yah, so that works with my user access token in the ci/cd as well as locally. Strange
    I'll see if i can get an application user to set this up without my personal user
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    I still don't know the reason why it's happening, but I hope it unblocks your work. If I find anything about it, I'll let you know. We also need to mention this case in our documentation's troubleshooting guide.
  • b

    Bryce Bonvillain

    4 months ago
    its easier to get an application user regardless as gitlab doesnt seem to offer group level access tokens, only repo specific access tokens for api access
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    True, but it's still strange that the repo token doesn't have access to the repo in GraphQL, but REST API works fine. Might be a bug on GitLab side
  • b

    Bryce Bonvillain

    4 months ago
    oh fake news, gitlab includes group level tokens in 14.7
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    But do they work for your repo? šŸ™‚
  • b

    Bryce Bonvillain

    4 months ago
    well I guess ill learn that when we upgrade our gitlab server
    could also be a bug with my specific gitlab version
  • Vadim (Infracost)

    Vadim (Infracost)

    4 months ago
    How do you see the update comment feature? Does it work as you expect?