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

command: Display state ID in PreApply+PostApply #12261

Merged
merged 1 commit into from
Mar 1, 2017
Merged

command: Display state ID in PreApply+PostApply #12261

merged 1 commit into from
Mar 1, 2017

Conversation

radeksimko
Copy link
Member

I noticed when working with many resources that take time to create, destroy or modify it's often difficult to tell what exactly is happening only from the config references.

I think the messages should include the state ID, not only the reference name from the config, which would make it useful especially when folks use count and some fields are generated.

Examples

$ terraform apply
kubernetes_namespace.n.1: Creating...
...
kubernetes_namespace.n.0: Creating...
...
kubernetes_namespace.n.0: Creation complete (ID: gen-pgt6q)
kubernetes_namespace.n.1: Creation complete (ID: gen-jbw57)
$ terraform apply
kubernetes_namespace.n.1: Refreshing state... (ID: gen-jbw57)
kubernetes_namespace.n.0: Refreshing state... (ID: gen-pgt6q)
kubernetes_namespace.n.1: Modifying... (ID: gen-jbw57)
  metadata.0.annotations.name: "old" => "new"
kubernetes_namespace.n.0: Modifying... (ID: gen-pgt6q)
  metadata.0.annotations.name: "old" => "new"
kubernetes_namespace.n.1: Modifications complete (ID: gen-jbw57)
kubernetes_namespace.n.0: Modifications complete (ID: gen-pgt6q)
$ terraform destroy
kubernetes_namespace.n.1: Refreshing state... (ID: gen-jbw57)
kubernetes_namespace.n.0: Refreshing state... (ID: gen-pgt6q)
kubernetes_namespace.n.0: Destroying... (ID: gen-pgt6q)
kubernetes_namespace.n.1: Destroying... (ID: gen-jbw57)
kubernetes_namespace.n.1: Still destroying... (ID: gen-jbw57, 10s elapsed)
kubernetes_namespace.n.0: Still destroying... (ID: gen-pgt6q, 10s elapsed)
kubernetes_namespace.n.1: Destruction complete
kubernetes_namespace.n.0: Destruction complete

Eventually I think we could go even further and display state IDs in the plan output, but that's for a separate PR potentially.

@mitchellh
Copy link
Contributor

This looks good but can we do a quick modification here where if the ID is longer than let's just say... 20 characters that we truncate and "..." it? I think we have some IDs in use in some providers that are huge and want to avoid those polluting the output too much.

@radeksimko
Copy link
Member Author

Ah, long IDs, that's a very good point, I'll have a look into that tomorrow.

@radeksimko
Copy link
Member Author

@mitchellh I decided to shorten the middle part as often it's the end of the ID that's making it unique and I'm not sure if shortening from the left makes sense, but I'm open for suggestions.

Also we're now truncating the ID which is already part of PreRefresh.

Examples

kubernetes_namespace.n.0: Creating...
...
kubernetes_namespace.n.1: Creating...
...
kubernetes_namespace.n.1: Creation complete (ID: gengengen...gen7jssq)
kubernetes_namespace.n.0: Creation complete (ID: gengengen...gend0cwn)
kubernetes_namespace.n.0: Refreshing state... (ID: gengengen...gend0cwn)
kubernetes_namespace.n.1: Refreshing state... (ID: gengengen...gen7jssq)
kubernetes_namespace.n.1: Modifying... (ID: gengengen...gen7jssq)
  metadata.0.annotations.name: "one" => "two"
kubernetes_namespace.n.0: Modifying... (ID: gengengen...gend0cwn)
  metadata.0.annotations.name: "one" => "two"
kubernetes_namespace.n.0: Modifications complete (ID: gengengen...gend0cwn)
kubernetes_namespace.n.1: Modifications complete (ID: gengengen...gen7jssq)
kubernetes_namespace.n.0: Refreshing state... (ID: gengengen...gend0cwn)
kubernetes_namespace.n.1: Refreshing state... (ID: gengengen...gen7jssq)
kubernetes_namespace.n.1: Destroying... (ID: gengengen...gen7jssq)
kubernetes_namespace.n.0: Destroying... (ID: gengengen...gend0cwn)
kubernetes_namespace.n.0: Destruction complete
kubernetes_namespace.n.1: Destruction complete

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. MERGE! 🚢

@radeksimko radeksimko merged commit 2e2b868 into hashicorp:master Mar 1, 2017
@radeksimko radeksimko deleted the f-hook-state-id branch March 1, 2017 22:17
yanndegat pushed a commit to yanndegat/terraform that referenced this pull request Mar 13, 2017
minamijoyo added a commit to minamijoyo/terraform that referenced this pull request Sep 9, 2018
Fixes hashicorp#18822

The `tuncatedId` function had been introduced in hashicorp#12261 and increased the
`maxIdLen` to 80 in hashicorp#13317. Since the number of bytes itself seems to be
unimportant, the ID should be truncated to 80 characters, not 80 bytes.
minamijoyo added a commit to minamijoyo/terraform that referenced this pull request Dec 13, 2018
Fixes hashicorp#18822

The `tuncatedId` function had been introduced in hashicorp#12261 and increased the
`maxIdLen` to 80 in hashicorp#13317. Since the number of bytes itself seems to be
unimportant, the ID should be truncated to 80 characters, not 80 bytes.
@ghost
Copy link

ghost commented Apr 16, 2020

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 have 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.

@ghost ghost locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants