https://pulumi.com logo
#automation-api
Title
# automation-api
e

eager-vase-43200

10/04/2021, 1:44 AM
hi, i am using automation-api(golang) to and I started seeing this error all of a sudden. anyone ran into this before when running preview? i skip preview and proceed with
up
it work fine.
Copy code
2021/10/03 18:42:04 Error in Watcher Error channel: fdopendir /private/var/folders/1t/xtppny2s3b53fzxhkmq7qhw40000gp/T/automation-logs-preview-3543494026: no such file or directory
FATA[0020] failed. err: failed to run infra automation for shared: failed to run pulumi: failed to run preview: failed to get preview summary
code: -2
b

billowy-army-68599

10/04/2021, 1:54 AM
could you share your code?
e

eager-vase-43200

10/04/2021, 1:25 PM
hi @billowy-army-68599 here..
Copy code
func runPulumi(ctx context.Context, project, stack, workspaceDir string, program pulumi.RunFunc) error {
	s, err := auto.NewStackInlineSource(ctx, stack, project, program, auto.WorkDir(workspaceDir))
	if err != nil && !auto.IsCreateStack409Error(err) {
		return errors.Wrap(err, "failed to get stack")
	}
	if _, err := s.Refresh(ctx, optrefresh.ProgressStreams(os.Stdout)); err != nil {
		return errors.Wrap(err, "failed to run up")
	}
	if _, err = s.Preview(ctx, optpreview.ProgressStreams(os.Stdout)); err != nil {
		return errors.Wrap(err, "failed to run preview")
	}
	if _, err := s.Up(ctx, optup.ProgressStreams(os.Stdout)); err != nil {
		return errors.Wrap(err, "failed to run up")
	}
	return nil
}
b

billowy-army-68599

10/04/2021, 2:59 PM
how are you initiating your stack?
e

eager-vase-43200

10/04/2021, 5:23 PM
that is the only code that i have been using to setup stack ever since i got started with pulumi this past weeked. it worked on saturday and started throwing that error on sunday..
there is no directory with the name that pulumi is looking for under
/private/var/folders/1t/xtppny2s3b53fzxhkmq7qhw40000gp
not really sure if there is some configuration that I am missing to ensure that pulumi is looking in the right place.
hi @billowy-army-68599 did you get a chance to look into this issue? this is not a blocker for me. just wanted to understand the root cause.
b

billowy-army-68599

10/06/2021, 4:56 PM
I didn't get a chance, I'm afraid. I think it's related to the way you're setting your workdir:
auto.WorkDir(workspaceDir)
by default, it'll use a temporary directory:
Similarly, unless a WorkDir option is specified, the working directory will default to a new temporary directory provided by the OS.
but you're specifying a
workspaceDir
variable, which isn't included in your code
so you'll need to examine how you're creating workspaces
e

eager-vase-43200

10/07/2021, 2:27 AM
hmm i see the same behavior when I remove the workspaceDir option too.. here is the full code.
Copy code
//GetStackFqdn acctName can be a pulumi org name or an individual user account name
func GetStackFqdn(acctName, projectName, stackName string) string {
	return fmt.Sprintf("%s/%s/%s", acctName, projectName, stackName)
}

func Run(pulumiAcct, pulumiProject, pulumiStack string, isApply bool, program pulumi.RunFunc, plugins map[string]string) error {
	ctx := context.Background()
	homeDir, err := os.UserHomeDir()
	if err != nil {
		return errors.Wrap(err, "failed to get home dir")
	}
	stackFqdn := GetStackFqdn(pulumiAcct, pulumiProject, pulumiStack)
	//workspaceDir = ${HOME}/.pws/stackFqdn
	workspaceDir := filepath.Join(homeDir, ".pws", stackFqdn)
	if err := os.MkdirAll(workspaceDir, os.ModePerm); err != nil {
		return errors.Wrapf(err, "failed to ensure %s dir", workspaceDir)
	}
	log.Infof("running %s stack", stackFqdn)
	if err := runPulumi(ctx, pulumiProject, GetStackFqdn(pulumiAcct, pulumiProject, pulumiStack), workspaceDir, isApply, program, plugins); err != nil {
		return errors.Wrap(err, "failed to run pulumi")
	}
	return nil
}

func runPulumi(ctx context.Context, project, stack, workspaceDir string, isApply bool, program pulumi.RunFunc, plugins map[string]string) error {
	s, err := auto.NewStackInlineSource(ctx, stack, project, program)
	if err != nil && !auto.IsCreateStack409Error(err) {
		return errors.Wrap(err, "failed to get stack")
	}
	if err := installPlugins(ctx, s.Workspace(), plugins); err != nil {
		return errors.Wrap(err, "failed to install plugins")
	}
	if _, err := s.Refresh(ctx, optrefresh.ProgressStreams(os.Stdout)); err != nil {
		return errors.Wrap(err, "failed to run up")
	}
	if !isApply {
		if _, err = s.Preview(ctx, optpreview.ProgressStreams(os.Stdout)); err != nil {
			return errors.Wrap(err, "failed to run preview")
		}
	}
	if !isApply {
		return nil
	}
	if _, err := s.Up(ctx, optup.ProgressStreams(os.Stdout)); err != nil {
		return errors.Wrap(err, "failed to run up")
	}
	return nil
}
4 Views