Thread
#general
    f

    fancy-spoon-7206

    3 months ago
    I am trying to control the lifecycle of the stack and resources using golang and avoiding using the Pulumi CLI. Creating a stack works as expected, but not
    Up
    function.
    func main() {
    	ctx := context.Background()
    	//stackName := auto.FullyQualifiedStackName("dinesh", "infrax", "test")
    	workDir := filepath.Join(".")
    	s, err := auto.UpsertStackLocalSource(ctx, "sandbox", workDir)
    	if err != nil {
    		log.Fatalln(err)
    	}
    	
    	// -- pulumi up --
    	_, err = s.Up(ctx)
    	if err != nil {
    		log.Fatalln(err)
    	}
    }
    The error is about the stack being locked by another process. I am pretty sure no other process is touching the current stack. Any insights?
    ➜ infrax go run .      
    2022/06/27 00:14:15 failed to run update: exit status 255
    code: 255
    stdout: Updating (sandbox):
    
        pulumi:pulumi:Stack base-infra-sandbox  2022/06/27 00:14:15 failed to create stack: exit status 255
        pulumi:pulumi:Stack base-infra-sandbox  code: 255
        pulumi:pulumi:Stack base-infra-sandbox  stdout: 
        pulumi:pulumi:Stack base-infra-sandbox  stderr: error: could not create stack: the stack is currently locked by 1 lock(s). Either wait for the other process(es) to end or manually delete the lock file(s).
        pulumi:pulumi:Stack base-infra-sandbox    file:///Users/dinesh.auti/.pulumi/locks/sandbox/ae44c2ff-1d8c-4288-925e-a5302c5b9808.json: created by dinesh.auti@MacBook-Pro.local (pid 8398) at 2022-06-27T00:14:11-04:00
        pulumi:pulumi:Stack base-infra-sandbox  exit status 1
        pulumi:pulumi:Stack base-infra-sandbox  error: an unhandled error occurred: program exited with non-zero exit code: 1
        pulumi:pulumi:Stack base-infra-sandbox **failed** 1 error; 6 messages
     
    Diagnostics:
      pulumi:pulumi:Stack (base-infra-sandbox):
        2022/06/27 00:14:15 failed to create stack: exit status 255
        code: 255
        stdout:
        stderr: error: could not create stack: the stack is currently locked by 1 lock(s). Either wait for the other process(es) to end or manually delete the lock file(s).
          file:///Users/dinesh.auti/.pulumi/locks/sandbox/ae44c2ff-1d8c-4288-925e-a5302c5b9808.json: created by dinesh.auti@MacBook-Pro.local (pid 8398) at 2022-06-27T00:14:11-04:00
        exit status 1
     
        error: an unhandled error occurred: program exited with non-zero exit code: 1
    b

    billowy-army-68599

    3 months ago
    are you running concurrently somehow? what happens if you delete the lock and try again?
    f

    fancy-spoon-7206

    3 months ago
    I triple checked there is nothing running concurrently. The lock file seems to be deleted automatically.
    b

    billowy-army-68599

    3 months ago
    are you running inside a goroutine?
    f

    fancy-spoon-7206

    3 months ago
    Nope.
    I tried this isolated in a different projects. Same issue 😞
    b

    billowy-army-68599

    3 months ago
    have you tried using something other than the filestate backend?