Update everything expect transfers & sftp to not use zap
This commit is contained in:
parent
65b1b96b06
commit
7d4a8d7f7e
|
@ -6,7 +6,6 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pterodactyl/wings/server"
|
||||
"go.uber.org/zap"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
@ -137,11 +136,7 @@ func postServerInstall(c *gin.Context) {
|
|||
|
||||
go func(serv *server.Server) {
|
||||
if err := serv.Install(); err != nil {
|
||||
zap.S().Errorw(
|
||||
"failed to execute server installation process",
|
||||
zap.String("server", serv.Uuid),
|
||||
zap.Error(err),
|
||||
)
|
||||
serv.Log().WithField("error", err).Error("failed to execute server installation process")
|
||||
}
|
||||
}(s)
|
||||
|
||||
|
@ -154,11 +149,7 @@ func postServerReinstall(c *gin.Context) {
|
|||
|
||||
go func(serv *server.Server) {
|
||||
if err := serv.Reinstall(); err != nil {
|
||||
zap.S().Errorw(
|
||||
"failed to complete server reinstall process",
|
||||
zap.String("server", serv.Uuid),
|
||||
zap.Error(err),
|
||||
)
|
||||
serv.Log().WithField("error", err).Error("failed to complete server re-install process")
|
||||
}
|
||||
}(s)
|
||||
|
||||
|
@ -176,7 +167,7 @@ func deleteServer(c *gin.Context) {
|
|||
// Delete the server's archive if it exists. We intentionally don't return
|
||||
// here, if the archive fails to delete, the server can still be removed.
|
||||
if err := s.Archiver.DeleteIfExists(); err != nil {
|
||||
zap.S().Warnw("failed to delete server archive during deletion process", zap.String("server", s.Uuid), zap.Error(err))
|
||||
s.Log().WithField("error", err).Warn("failed to delete server archive during deletion process")
|
||||
}
|
||||
|
||||
// Unsubscribe all of the event listeners.
|
||||
|
@ -197,7 +188,10 @@ func deleteServer(c *gin.Context) {
|
|||
// so we don't want to block the HTTP call while waiting on this.
|
||||
go func(p string) {
|
||||
if err := os.RemoveAll(p); err != nil {
|
||||
zap.S().Warnw("failed to remove server files during deletion process", zap.String("path", p), zap.Error(errors.WithStack(err)))
|
||||
log.WithFields(log.Fields{
|
||||
"path": p,
|
||||
"error": errors.WithStack(err),
|
||||
}).Warn("failed to remove server files during deletion process")
|
||||
}
|
||||
}(s.Filesystem.Path())
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
"github.com/pterodactyl/wings/server"
|
||||
"github.com/pterodactyl/wings/server/backup"
|
||||
"go.uber.org/zap"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -40,7 +39,7 @@ func postServerBackup(c *gin.Context) {
|
|||
|
||||
go func(b backup.BackupInterface, serv *server.Server) {
|
||||
if err := serv.Backup(b); err != nil {
|
||||
zap.S().Errorw("failed to generate backup for server", zap.Error(err))
|
||||
serv.Log().WithField("error", err).Error("failed to generate backup for server")
|
||||
}
|
||||
}(adapter, s)
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ package server
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"github.com/apex/log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pterodactyl/wings/api"
|
||||
"github.com/pterodactyl/wings/server/backup"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
@ -17,16 +17,15 @@ func (s *Server) notifyPanelOfBackup(uuid string, ad *backup.ArchiveDetails, suc
|
|||
rerr, err := r.SendBackupStatus(uuid, ad.ToRequest(successful))
|
||||
if rerr != nil || err != nil {
|
||||
if err != nil {
|
||||
zap.S().Errorw(
|
||||
"failed to notify panel of backup status due to internal code error",
|
||||
zap.String("backup", s.Uuid),
|
||||
zap.Error(err),
|
||||
)
|
||||
s.Log().WithFields(log.Fields{
|
||||
"backup": uuid,
|
||||
"error": err,
|
||||
}).Error("failed to notify panel of backup status due to internal code error")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
zap.S().Warnw(rerr.String(), zap.String("backup", uuid))
|
||||
s.Log().WithField("backup", uuid).Warn(rerr.String())
|
||||
|
||||
return errors.New(rerr.String())
|
||||
}
|
||||
|
@ -66,7 +65,7 @@ func (s *Server) GetIncludedBackupFiles(ignored []string) (*backup.IncludedFiles
|
|||
// of the server files directory, and use that to generate the backup.
|
||||
if len(ignored) == 0 {
|
||||
if i, err := s.getServerwideIgnoredFiles(); err != nil {
|
||||
zap.S().Warnw("failed to retrieve server ignored files", zap.String("server", s.Uuid), zap.Error(err))
|
||||
s.Log().WithField("error", err).Warn("failed to retrieve ignored files listing for server")
|
||||
} else {
|
||||
ignored = i
|
||||
}
|
||||
|
@ -89,7 +88,10 @@ func (s *Server) Backup(b backup.BackupInterface) error {
|
|||
ad, err := b.Generate(inc, s.Filesystem.Path())
|
||||
if err != nil {
|
||||
if notifyError := s.notifyPanelOfBackup(b.Identifier(), &backup.ArchiveDetails{}, false); notifyError != nil {
|
||||
zap.S().Warnw("failed to notify panel of failed backup state", zap.String("backup", b.Identifier()), zap.Error(err))
|
||||
s.Log().WithFields(log.Fields{
|
||||
"backup": b.Identifier(),
|
||||
"error": err,
|
||||
}).Warn("failed to notify panel of failed backup state")
|
||||
}
|
||||
|
||||
return errors.WithStack(err)
|
||||
|
|
|
@ -3,9 +3,9 @@ package backup
|
|||
import (
|
||||
"archive/tar"
|
||||
"context"
|
||||
"github.com/apex/log"
|
||||
gzip "github.com/klauspost/pgzip"
|
||||
"github.com/remeh/sizedwaitgroup"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -67,7 +67,7 @@ func (a *Archive) Create(dest string, ctx context.Context) error {
|
|||
// Attempt to remove the archive if there is an error, report that error to
|
||||
// the logger if it fails.
|
||||
if rerr := os.Remove(dest); rerr != nil && !os.IsNotExist(rerr) {
|
||||
zap.S().Warnw("failed to delete corrupted backup archive", zap.String("location", dest))
|
||||
log.WithField("location", dest).Warn("failed to delete corrupted backup archive")
|
||||
}
|
||||
|
||||
return err
|
||||
|
|
|
@ -3,10 +3,10 @@ package backup
|
|||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"github.com/apex/log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pterodactyl/wings/api"
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"go.uber.org/zap"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -121,7 +121,10 @@ func (b *Backup) Details() *ArchiveDetails {
|
|||
|
||||
resp, err := b.Checksum()
|
||||
if err != nil {
|
||||
zap.S().Errorw("failed to calculate checksum for backup", zap.String("backup", b.Uuid), zap.Error(err))
|
||||
log.WithFields(log.Fields{
|
||||
"backup": b.Identifier(),
|
||||
"error": err,
|
||||
}).Error("failed to calculate checksum for backup")
|
||||
}
|
||||
|
||||
checksum = hex.EncodeToString(resp)
|
||||
|
|
|
@ -3,7 +3,7 @@ package backup
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go.uber.org/zap"
|
||||
"github.com/apex/log"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -77,7 +77,10 @@ func (s *S3Backup) generateRemoteRequest(rc io.ReadCloser) (*http.Response, erro
|
|||
|
||||
r.Body = rc
|
||||
|
||||
zap.S().Debugw("uploading backup to remote S3 endpoint", zap.String("endpoint", s.PresignedUrl), zap.Any("headers", r.Header))
|
||||
log.WithFields(log.Fields{
|
||||
"endpoint": s.PresignedUrl,
|
||||
"headers": r.Header,
|
||||
}).Debug("uploading backup to remote S3 endpoint")
|
||||
|
||||
return http.DefaultClient.Do(r)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/pterodactyl/wings/config"
|
||||
"github.com/pterodactyl/wings/server/backup"
|
||||
ignore "github.com/sabhiram/go-gitignore"
|
||||
"go.uber.org/zap"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -134,7 +133,7 @@ func (fs *Filesystem) HasSpaceAvailable() bool {
|
|||
// the cache once we've gotten it.
|
||||
size, err := fs.DirectorySize("/")
|
||||
if err != nil {
|
||||
zap.S().Warnw("failed to determine directory size", zap.String("server", fs.Server.Uuid), zap.Error(err))
|
||||
fs.Server.Log().WithField("error", err).Warn("failed to determine root server directory size")
|
||||
}
|
||||
|
||||
// Always cache the size, even if there is an error. We want to always return that value
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"go.uber.org/zap"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -98,7 +97,7 @@ func (s *Server) SetState(state string) error {
|
|||
// to the disk should we forget to do it elsewhere.
|
||||
go func() {
|
||||
if err := saveServerStates(); err != nil {
|
||||
zap.S().Warnw("failed to write server states to disk", zap.Error(err))
|
||||
s.Log().WithField("error", err).Warn("failed to write server states to disk")
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -111,14 +110,14 @@ func (s *Server) SetState(state string) error {
|
|||
// separate thread as to not block any actions currently taking place in the flow
|
||||
// that called this function.
|
||||
if (prevState == ProcessStartingState || prevState == ProcessRunningState) && s.GetState() == ProcessOfflineState {
|
||||
zap.S().Infow("detected server as entering a potentially crashed state; running handler", zap.String("server", s.Uuid))
|
||||
s.Log().Info("detected server as entering a crashed state; running crash handler")
|
||||
|
||||
go func(server *Server) {
|
||||
if err := server.handleServerCrash(); err != nil {
|
||||
if IsTooFrequentCrashError(err) {
|
||||
zap.S().Infow("did not restart server after crash; occurred too soon after last", zap.String("server", server.Uuid))
|
||||
server.Log().Info("did not restart server after crash; occurred too soon after the last")
|
||||
} else {
|
||||
zap.S().Errorw("failed to handle server crash state", zap.String("server", server.Uuid), zap.Error(err))
|
||||
server.Log().WithField("error", err).Error("failed to handle server crash")
|
||||
}
|
||||
}
|
||||
}(s)
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"github.com/buger/jsonparser"
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Merges data passed through in JSON form into the existing server object.
|
||||
|
@ -101,14 +100,10 @@ func (s *Server) runBackgroundActions() {
|
|||
// yet, do it immediately.
|
||||
go func(server *Server) {
|
||||
if server.Suspended && server.GetState() != ProcessOfflineState {
|
||||
zap.S().Infow("server suspended with running process state, terminating now", zap.String("server", server.Uuid))
|
||||
server.Log().Info("server suspended with running process state, terminating now")
|
||||
|
||||
if err := server.Environment.WaitForStop(10, true); err != nil {
|
||||
zap.S().Warnw(
|
||||
"failed to stop server environment after seeing suspension",
|
||||
zap.String("server", server.Uuid),
|
||||
zap.Error(err),
|
||||
)
|
||||
server.Log().WithField("error", err).Warn("failed to terminate server environment after suspension")
|
||||
}
|
||||
}
|
||||
}(s)
|
||||
|
|
Loading…
Reference in New Issue
Block a user