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

account for deposed in terraform show #22149

Merged
merged 1 commit into from
Jul 29, 2019
Merged

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Jul 19, 2019

Account for deposed instances in show command.
Prevent crash if the current instance is missing.

Besides preventing the panic, this will also add (N deposed) to the resource address line, similar to other state outputs.

Fixes #21770

@jbardin jbardin requested a review from a team July 19, 2019 20:41
@apparentlymart
Copy link
Contributor

Hmm... I thought we'd already fixed this but I guess that was for the plan rendering rather than for the state rendering.

I believe in the plan we render each object separately rather than rolling up the deposed objects to just be a count in the header, since otherwise there's no way for the user to see the attributes of the deposed objects. For consistency, I'd lean towards making the output be shaped more like this, if that isn't a lot of extra work:

# test_resource.baz[0]
resource "test_resource" "baz" {
    woozles = "confuzles"
     nested {
        value = "42"
    }
}

# test_resource.baz[0] deposed object abcd1234
resource "test_resource" "baz" {
    woozles = "confuzles"
     nested {
        value = "42"
    }
}

I don't remember if that's exactly how we annotated the deposed objects in the plan; if you can find that then my intent here was to output here in the same format.

(There's an open issue somewhere else to explain better what "deposed" means, but we don't need to solve that here; we already have mentions like this in the UI, so this won't make it any worse.)


As an aside... I had no idea there was a special case in terraform taint to reject tainting when there's a deposed object present. How long has that been there? 🤔

@jbardin
Copy link
Member Author

jbardin commented Jul 19, 2019

I actually reduced the output to match the old count notation, but If we both agree that listing deposed instances completely is favorable, I'll go ahead and refactor this.

@apparentlymart
Copy link
Contributor

We do still use the "(n deposed)" notation internally in the tests because it's mimicking the old test string generator for compatibility with the old tests, but since the deposed objects now have unique ids associated we started showing them explicitly and in full in the UI when relevant so that users would be able to correlate the deposed objects they see in different contexts.

@jbardin
Copy link
Member Author

jbardin commented Jul 22, 2019

Updated the output to include all deposed objects individually, annotated as so:

# test_resource.baz[0]:
resource "test_resource" "baz" {
    woozles = "confuzles"

    nested {
        value = "42"
    }
}

# test_resource.baz[0]: (deposed object 1234)
resource "test_resource" "baz" {
    woozles = "confuzles"

    nested {
        value = "42"
    }
}

Copy link
Contributor

@pselle pselle left a comment

Choose a reason for hiding this comment

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

A couple comments, LGTM!

command/format/state.go Show resolved Hide resolved
command/format/state.go Show resolved Hide resolved
each deposed instance.
Prevent crash if the current instance is missing.
@jbardin jbardin force-pushed the jbardin/state-show-deposed branch from 98713b8 to 345dfac Compare July 29, 2019 21:03
@jbardin jbardin merged commit 8b2646c into master Jul 29, 2019
@jbardin jbardin deleted the jbardin/state-show-deposed branch July 29, 2019 21:25
@ghost
Copy link

ghost commented Aug 29, 2019

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 Aug 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic: runtime error: invalid memory address or nil pointer dereference
3 participants