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 workdir cleanup logic #195

Merged
merged 3 commits into from
Sep 15, 2021
Merged

Improve workdir cleanup logic #195

merged 3 commits into from
Sep 15, 2021

Conversation

viveklak
Copy link
Contributor

@viveklak viveklak commented Sep 14, 2021

Fixes #104.

Manually verified that the work directory is deleted on failure while retaining existing behavior on success.

@@ -656,7 +672,7 @@ func (sess *reconcileStackSession) SetupPulumiWorkdir(gitAuth *auto.GitAuth) err
return errors.Wrap(err, "installing project dependencies")
}

return nil
return err
Copy link
Member

Choose a reason for hiding this comment

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

I can't quite grasp this change...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't quite grasp this change...

Its actually unnecessary. Removed.

}()

var w auto.Workspace
w, err = auto.NewLocalWorkspace(context.Background(), auto.WorkDir(dir), auto.Repo(repo), secretsProvider)
Copy link
Member

Choose a reason for hiding this comment

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

What's the default behavior of our automation API before this change? Does it create a temporary folder internally but does not clean it up correctly? What is our advice to 3rd party users of automation API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the default behavior of our automation API before this change? Does it create a temporary folder internally but does not clean it up correctly? What is our advice to 3rd party users of automation API?

Yes it creates a temporary directory internally. We tried to handle cleanup through the sess.CleanupPulumiWorkdir() call elsewhere but we do many operations as part of the stack setup which may fail independently and we leak the work dir on failure.
This seems to be more a function of the way the operator is currently written than anything specific to the automation API.

@@ -633,7 +648,8 @@ func (sess *reconcileStackSession) SetupPulumiWorkdir(gitAuth *auto.GitAuth) err
sess.autoStack = &a
sess.logger.Debug("Setting autostack", "autostack", sess.autoStack)

c, err := sess.autoStack.GetAllConfig(ctx)
var c auto.ConfigMap
c, err = sess.autoStack.GetAllConfig(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed?

@viveklak viveklak merged commit 55213bb into master Sep 15, 2021
@viveklak viveklak deleted the vl/FixCleanup branch September 15, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ever growing collection of stack and ssh directories in /tmp
3 participants