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

core: Return an error when there's no remote state #7464

Merged
merged 1 commit into from
Jul 5, 2016
Merged

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Jul 1, 2016

When refreshing remote state, indicate when no state file was found with
an ErrRemoteStateNotFound error. This prevents us from inadvertantly
getting a nil state into a terraform.State where we assume there's
always a root module.

Fixes #7455

When refreshing remote state, indicate when no state file was found with
an ErrRemoteStateNotFound error. This prevents us from inadvertantly
getting a nil state into a terraform.State where we assume there's
always a root module.
@phinze
Copy link
Contributor

phinze commented Jul 1, 2016

Cool so this addresses the terraform_remote_state issue but also will toss a sane error if anything funky happens w/ the client. 👍

LGTM

@jbardin jbardin merged commit be2469a into master Jul 5, 2016
@jbardin jbardin deleted the jbardin/GH-7455 branch July 5, 2016 12:59
jbardin added a commit that referenced this pull request Jul 6, 2016
The error for a nil remote state was showing up in other places. While
we could check for the error on all calls to Refresh(), this restores
the previous behavior, while preventing possible nil values in the
state.

The effect here is the same, because rather than the RefreshState
switching on

     cached != nil && durable == nil

it will switch on

    durable.Serial < cached.Serial

which sets the same value to RefreshResult().
jbardin added a commit that referenced this pull request Jul 6, 2016
Take a new approach to handling a nil remote state payload. Rather than
define an error indicating a nil remote state (which would need to be
moved to an internal package in order to be imported by all packages
which could use it), we create an empty terraform.State with a Serial of
-1 to ensure it's always superseded by any other state. This restores
the previous behavior, while still preventing possible nil values in the
state.

The effect here is the same, because rather than the RefreshState
switching on

     cached != nil && durable == nil

it will switch on

    durable.Serial < cached.Serial

which sets the same value to RefreshResult().
jbardin added a commit that referenced this pull request Jul 7, 2016
Take a new approach to handling a nil remote state payload. Rather than
define an error indicating a nil remote state (which would need to be
moved to an internal package in order to be imported by all packages
which could use it), we create an empty terraform.State with a Serial of
-1 to ensure it's always superseded by any other state. This restores
the previous behavior, while still preventing possible nil values in the
state.

The effect here is the same, because rather than the RefreshState
switching on

     cached != nil && durable == nil

it will switch on

    durable.Serial < cached.Serial

which sets the same value to RefreshResult().
jbardin added a commit that referenced this pull request Jul 7, 2016
Revert back to using a nil state. The external usage of the state shoudl
always check the Empty() method.
jbardin added a commit that referenced this pull request Jul 7, 2016
@ghost
Copy link

ghost commented Apr 24, 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 24, 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.

Panic creating/reading remote state
3 participants