Sync server state with Panel before performing installation to ensure information is up to date

This commit is contained in:
Dane Everitt 2020-06-30 20:56:55 -07:00
parent 79a582a5f2
commit ea2630946a
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 14 additions and 4 deletions

View File

@ -135,7 +135,7 @@ func postServerInstall(c *gin.Context) {
s := GetServer(c.Param("server"))
go func(serv *server.Server) {
if err := serv.Install(); err != nil {
if err := serv.Install(true); err != nil {
serv.Log().WithField("error", err).Error("failed to execute server installation process")
}
}(s)

View File

@ -59,7 +59,7 @@ func postCreateServer(c *gin.Context) {
go func(i *installer.Installer) {
i.Execute()
if err := i.Server().Install(); err != nil {
if err := i.Server().Install(false); err != nil {
log.WithFields(log.Fields{"server": i.Uuid(), "error": err}).Error("failed to run install process for server")
}
}(install)

View File

@ -25,7 +25,17 @@ import (
// Executes the installation stack for a server process. Bubbles any errors up to the calling
// function which should handle contacting the panel to notify it of the server state.
func (s *Server) Install() error {
//
// Pass true as the first arugment in order to execute a server sync before the process to
// ensure the latest information is used.
func (s *Server) Install(sync bool) error {
if sync {
s.Log().Info("syncing server state with remote source before executing installation process")
if err := s.Sync(); err != nil {
return err
}
}
err := s.internalInstall()
s.Log().Debug("notifying panel of server install state")
@ -55,7 +65,7 @@ func (s *Server) Reinstall() error {
}
}
return s.Install()
return s.Install(true)
}
// Internal installation function used to simplify reporting back to the Panel.