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: more manageable shadow error output #10276

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions command/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"strconv"
"time"

"github.com/hashicorp/errwrap"
"github.com/hashicorp/go-getter"
Expand Down Expand Up @@ -496,6 +498,14 @@ func (m *Meta) outputShadowError(err error, output bool) bool {
return false
}

// Write the shadow error output to a file
path := fmt.Sprintf("terraform-error-%d.log", time.Now().UTC().Unix())
if err := ioutil.WriteFile(path, []byte(err.Error()), 0644); err != nil {
// If there is an error writing it, just let it go
log.Printf("[ERROR] Error writing shadow error: %s", err)
return false
}

// Output!
m.Ui.Output(m.Colorize().Color(fmt.Sprintf(
"[reset][bold][yellow]\nExperimental feature failure! Please report a bug.\n\n"+
Expand All @@ -505,14 +515,13 @@ func (m *Meta) outputShadowError(err error, output bool) bool {
"background. These features cannot affect real state and never touch\n"+
"real infrastructure. If the features work properly, you see nothing.\n"+
"If the features fail, this message appears.\n\n"+
"The following failures happened while running experimental features.\n"+
"Please report a Terraform bug so that future Terraform versions that\n"+
"enable these features can be improved!\n\n"+
"You can report an issue at: https://github.com/hashicorp/terraform/issues\n\n"+
"%s\n\n"+
"The failure was written to %q. Please\n"+
"double check this file contains no sensitive information and report\n"+
"it with your issue.\n\n"+
"This is not an error. Your terraform operation completed successfully\n"+
"and your real infrastructure is unaffected by this message.",
err,
path,
)))

return true
Expand Down