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

Improve the error message arising from missing required configs for resource providers #1097

Merged
merged 2 commits into from
Apr 4, 2018

Conversation

swgillespie
Copy link
Contributor

If the tfbridge that we are speaking to is new enough, it will send
across a list of keys and their descriptions alongside an error
indicating that the provider we are configuring is missing required
config. This commit packages up the list of missing keys into an error
that can be presented nicely to the user.

Take 2! This is the first of two PRs that implement this new error message functionality; a companion PR will be opened in pulumi-terraform that implements the server portion of these changes. Because of the way our Go dependency graph is shaped, this PR will need to be merged before the pulumi-terraform one.

The idea here is that, before tfbridge asks Terraform to validate a set of configs, it will first check the list of config keys we give it against the list of configs known to us (through the TF Schema) to be required. If tfbridge sees any keys that it does not recognize, it'll send an error response to the Configure RPC call and attach a ConfigureErrorMissingKeys detail to the error, which we as the plugin host can interpret and provide a specific error message for each missing key.

With all pieces in place (including updates to pulumi-aws and pulumi-terraform, which will come from follow-up PRs), this is the new output:

$ pulumi update
error: failed to load resource plugin aws: failed to configure pkg 'aws' resource provider: 1 error occurred:

* missing required configuration key "aws:region": The region where AWS operations will take place. Examples are us-east-1, us-west-2, etc.
Set a value using the command `pulumi config set aws:region <value>`.

For the changelog:

This change improves the error message that appears whenever a required configuration key is not provided, such as aws:region. The error message will now print out the names of all missing configuration keys as well as a description of the key's function.

@swgillespie swgillespie added kind/bug Some behavior is incorrect or out of spec impact/usability Something that impacts users' ability to use the product easily and intuitively area/providers impact/changelog labels Mar 30, 2018
@swgillespie
Copy link
Contributor Author

tfbridge component: pulumi/pulumi-terraform#136

Copy link

@lindydonna lindydonna left a comment

Choose a reason for hiding this comment

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

I only reviewed the PR description and changelog, but it looks good!

Copy link
Member

@pgavlin pgavlin left a comment

Choose a reason for hiding this comment

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

LGTM aside from a few nits

// variables, tfbridge will respond with a list of missing variables and their descriptions.
// If that is what occurred, we'll use that information here to construct a nice error message.
func createConfigureError(err *rpcerror.Error) error {
var aggregateErr error
Copy link
Member

Choose a reason for hiding this comment

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

Nit: how about renaming the parameter rpcerr and doing something like the following:

var err error = rpcerr
for _, detail := range rpcerr.Details() {
    ...
    err = multierror.Append(err, singleError)
}

return err

// ConfigureErrorMissingKeys is sent as a Detail on an error returned from `ResourceProvider.Configure`.
message ConfigureErrorMissingKeys {
message MissingKey {
string name = 1; // the Pulumi name (not the TF name!) of the missing config key.
Copy link
Member

Choose a reason for hiding this comment

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

s/TF/provider

message ConfigureErrorMissingKeys {
message MissingKey {
string name = 1; // the Pulumi name (not the TF name!) of the missing config key.
string description = 2; // a description of the missing config key, from the TF schema.
Copy link
Member

Choose a reason for hiding this comment

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

Do not mention TF here: not all providers will be TF-based

@pgavlin
Copy link
Member

pgavlin commented Mar 31, 2018

Likewise, do not mention TF/tfbridge/etc. in the commit message. Resource providers != terraform in the general case.

resource providers

If the resource provider that we are speaking to is new enough, it will send
across a list of keys and their descriptions alongside an error
indicating that the provider we are configuring is missing required
config. This commit packages up the list of missing keys into an error
that can be presented nicely to the user.
@swgillespie swgillespie merged commit a3a6101 into master Apr 4, 2018
@swgillespie
Copy link
Contributor Author

thanks for the reviews!

@pgavlin pgavlin deleted the swgillespie/config-errors-2 branch June 12, 2018 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/providers impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants