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

kusion init --online failed #757

Closed
healthjyk opened this issue Jan 24, 2024 · 1 comment · Fixed by #758
Closed

kusion init --online failed #757

healthjyk opened this issue Jan 24, 2024 · 1 comment · Fixed by #758
Assignees
Labels
kind/bug Something isn't working

Comments

@healthjyk
Copy link
Contributor

healthjyk commented Jan 24, 2024

What happened?

kusion init --online failed, with error "cloning templates failed. Please try again: reference not found"
image

What did you expect to happen?

kusion init --online succeeded

How can we reproduce it (as minimally and precisely as possible)?

Run kusion init --online, and exit (you can press CTRL+C) when git clone has not get finished.
Then run kusion init --online again.

@healthjyk healthjyk added the kind/bug Something isn't working label Jan 24, 2024
@healthjyk
Copy link
Contributor Author

The reason of the bug is because:
kusion init --online calls git clone(or git pull). If you exit when the git clone has not finished, there will be a directory .git under $KUSION_HOME/templates/external, but the .git directory is semi-finished and is not valid. If you run git clone (or git pull) again, the error comes.
Kusion uses github.com/pulumi/pulumi/sdk/v3/go/common/util/gitutil#GitCloneOrPull and github.com/pulumi/pulumi/sdk/v3/go/common/workspace#RetrieveGitFolder to do the git clone/pull job. I try to find a more robust alternative, and use git-go, which is recommended by git official, but the similar error still appears (still left the annoying .git directory and the failed git clone).
So the most simple and effective way is to clear the external templates directory and do git clone again.
Fix #549 try to catch ctrl+C and then do cleanup job to fix this bug. It's not a good idea, here is the reasons:

  • not only the ctrl+C and other interrupt signals will cause the bug, program panic, calling of os.Exit may also cause the bug;
  • the realization is troublesome, you have to listen two type events: the first is the interrupt signals, the second is whether the git clone succeeded. For the former, you have to listen them in the outer cli func, and passes them layer upon layer to the internal retrieve template repo function.
  • the remove action keeps the same as the retrieveURLTemplates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant