Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with @cdktf/provider-postgresql Grant (Add terraform-parallelism flag) #1715

Closed
Joe-Kollin opened this issue Apr 12, 2022 · 19 comments · Fixed by #2107
Closed

Issue with @cdktf/provider-postgresql Grant (Add terraform-parallelism flag) #1715

Joe-Kollin opened this issue Apr 12, 2022 · 19 comments · Fixed by #2107
Assignees
Labels
cdktf-cli core-parity Better experience in Terraform Core than CDKTF enhancement New feature or request priority/important-soon High priority, to be worked on as part of our current release or the following one. size/medium estimated < 1 week

Comments

@Joe-Kollin
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

cdktf & Language Versions

"@cdktf/provider-aws": "^7.0.13"
"@cdktf/provider-postgresql": "^0.4.12"
"@cdktf/provider-random": "^0.2.12"
"cdktf": "^0.10"

"ts-node": "^10.7.0",
"typescript": "^4.6.2"

Affected Resource(s)

PostgresqlProvider Grant Resource

Debug Output

Error: could not execute revoke query: pq: tuple concurrently updated

Expected Behavior

Successfully created each role grant for each role.

Actual Behavior

Concurrency error in spite of trying both the --parallelism=0 and --parallelism=1 flags

Steps to Reproduce

roles.forEach((role) => {

     ...doStuff

      role.grants.forEach((grant) => {
        new Grant(this, `${this.deploymentPrefix}-${role.name}-${grant.objectType}-grant`, {
          role: role.name,
          database: role.database,
          objectType: grant.objectType,
          privileges: grant.privileges,
        });
      });

})

Important Factoids

I've done some research and tried the concurrency flag which doesn't seem to be fixing anything. My assumption is that either something is wrong with the flag implementation in CDKTF or the Grant object itself.

@Joe-Kollin Joe-Kollin added bug Something isn't working new Un-triaged issue labels Apr 12, 2022
@jsteinich
Copy link
Collaborator

You could try setting an environment variable as described here.
cdktf doesn't currently support passing flags to Terraform, but you can also run Terraform directly from the stack output directory.

@ansgarm
Copy link
Member

ansgarm commented Apr 13, 2022

This PR added a parallelism flag to the cdktf-cli, however that one addresses deploying multiple stacks in parallel and does not show the same behaviour as the parallelism flag of the Terraform CLI. To me it would make sense to e.g. expose a --terraform-parallelism flag or similar to allow setting this flag, when required as a workaround for underlying provider issues.

@Joe-Kollin
Copy link
Author

Thanks @jsteinich that worked for me. For anyone referencing this do:

TF_CLI_ARGS_apply="-parallelism=1" cdktf deploy <stack name>

@ansgarm having a direct flag like that would definitely be nice though

@jsteinich
Copy link
Collaborator

#734 is asking for the same flag.

@jaty613
Copy link

jaty613 commented Apr 21, 2022

Thanks @jsteinich that worked for me. For anyone referencing this do:

TF_CLI_ARGS_apply="-parallelism=1" cdktf deploy <stack name>

@ansgarm having a direct flag like that would definitely be nice though

cdktf command, Don't take effect

@ansgarm
Copy link
Member

ansgarm commented Apr 21, 2022

Hi @jaty613,
could you explain a bit more what you did that did not work? Which command did you try? What operating system are you using?

@jaty613
Copy link

jaty613 commented Apr 22, 2022

Hi @jaty613, could you explain a bit more what you did that did not work? Which command did you try? What operating system are you using?

env:
Terraform v1.1.7 on windows_386

terraform apply --auto-approve (parallelism parameters to take effect)

cdktf deploy (Don't take effect)

image

@ansgarm
Copy link
Member

ansgarm commented Apr 25, 2022

Hi @jaty613, where do you set those environment variables? Are you using an IDE, a terminal (which one?) or something else?
What do you do to confirm that parallelism does not take effect? Terraform will only run things in parallel that have no dependencies onto each other – maybe that's what you are experiencing? Could you share your CLI output in a Github Gist or send us an reproduction case?

@DanielMSchmidt DanielMSchmidt added enhancement New feature or request cdktf-cli core-parity Better experience in Terraform Core than CDKTF needs-priority Issue has not yet been prioritized; this will prompt team review size/medium estimated < 1 week and removed bug Something isn't working new Un-triaged issue labels Apr 26, 2022
@jaty613
Copy link

jaty613 commented Apr 28, 2022

Hi @jaty613, where do you set those environment variables? Are you using an IDE, a terminal (which one?) or something else? What do you do to confirm that parallelism does not take effect? Terraform will only run things in parallel that have no dependencies onto each other – maybe that's what you are experiencing? Could you share your CLI output in a Github Gist or send us an reproduction case?

In the Windows operating system, set the environment variables as system environment variables and ensure that the environment variables take effect。

@ansgarm
Copy link
Member

ansgarm commented Apr 28, 2022

@jaty613
What terminal application are you using on windows?

@jaty613
Copy link

jaty613 commented Apr 29, 2022

@jaty613 What terminal application are you using on windows?
cmd & powshell

@ansgarm
Copy link
Member

ansgarm commented Apr 29, 2022

What does running echo %TF_CLI_ARGS_apply% return?

@jaty613
Copy link

jaty613 commented Apr 29, 2022

C:\Users\root>echo %TF_CLI_ARGS_apply%
-parallelism=800

@jaty613
Copy link

jaty613 commented Apr 29, 2022

C:\Users\root>echo %TF_CLI_ARGS_apply% -parallelism=800

The actual maximum number of parallelism runs is the default value of 10

@ansgarm
Copy link
Member

ansgarm commented Apr 29, 2022

You mentioned Powershell. Is it correctly returning the -parallelism=800 in the Powershell as well?
How many resources do you apply (of which only 10 apply in parallel)?

@jaty613
Copy link

jaty613 commented Apr 29, 2022

You mentioned Powershell. Is it correctly returning the -parallelism=800 in the Powershell as well? How many resources do you apply (of which only 10 apply in parallel)?

PS C:\Users\root> $env:TF_CLI_ARGS_apply
-parallelism=800

One stack has 200 resources

@jaty613
Copy link

jaty613 commented Apr 29, 2022

The terraform apply command parallelizes the maximum number of resources, but the CDKTF deploy command does not

@ansgarm
Copy link
Member

ansgarm commented May 5, 2022

Could you try setting the CDKTF_LOG_LEVEL environment variable and see if that has an effect (it should create more output logging while running e.g. deploy or diff).

@DanielMSchmidt DanielMSchmidt changed the title Issue with @cdktf/provider-postgresql Grant Issue with @cdktf/provider-postgresql Grant (Add terraform-parallelism flag) Aug 12, 2022
@DanielMSchmidt DanielMSchmidt removed the needs-priority Issue has not yet been prioritized; this will prompt team review label Aug 12, 2022
@DanielMSchmidt DanielMSchmidt added the priority/important-soon High priority, to be worked on as part of our current release or the following one. label Aug 12, 2022
@github-actions
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cdktf-cli core-parity Better experience in Terraform Core than CDKTF enhancement New feature or request priority/important-soon High priority, to be worked on as part of our current release or the following one. size/medium estimated < 1 week
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants