Skip to content

Commit

Permalink
Merge pull request #49 from unity-sds/boostrap_logging
Browse files Browse the repository at this point in the history
Some more verbose/improved error logging for the bootstrap process.
  • Loading branch information
galenatjpl authored Jan 14, 2025
2 parents 62c8998 + df50afb commit abd60a8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
5 changes: 4 additions & 1 deletion backend/cmd/web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ var (
}
if bootstrap == true || !initialised {
log.Info("Bootstrap flag set or uninitialised workdir, bootstrapping")
processes.BootstrapEnv(&appConfig)
err := processes.BootstrapEnv(&appConfig)
if err != nil {
log.Errorf("Errors were encountered during bootstrap process. Please check the errorlog for more details.")
}
}
router := web.DefineRoutes(appConfig)

Expand Down
6 changes: 6 additions & 0 deletions backend/internal/database/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func (g GormDatastore) StoreSSMParams(p []config.SSMParameter, owner string) err
model.Value = param.Value
model.Owner = owner

log.WithFields(log.Fields{
"name": param.Name,
"type": param.Type,
"owner": owner,
}).Info("Storing SSM parameter")

// Use Save to insert or update the record
if err := g.db.Save(&model).Error; err != nil {
// Handle error for Save
Expand Down
33 changes: 24 additions & 9 deletions backend/internal/processes/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/unity-sds/unity-management-console/backend/types"
)

func BootstrapEnv(appconf *config.AppConfig) {
func BootstrapEnv(appconf *config.AppConfig) error {
// Print out everything in appConfig
log.Infof("AppConfig contents:")
log.Infof("GithubToken: %s", appconf.GithubToken)
Expand All @@ -36,94 +36,109 @@ func BootstrapEnv(appconf *config.AppConfig) {
for _, item := range appconf.MarketplaceItems {
log.Infof(" - Name: %s, Version: %s", item.Name, item.Version)
}

log.Infof("Creating Local Database")
store, err := database.NewGormDatastore()
if err != nil {
log.WithError(err).Error("Problem creating database")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
return err
}

log.Infof("Provisioning S3 Bucket")
err = provisionS3(appconf)
if err != nil {
log.WithError(err).Error("Error provisioning S3 bucket")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
return err
}

log.Infof("Setting Up Default SSM Parameters")
err = storeDefaultSSMParameters(appconf, store)
if err != nil {
log.WithError(err).Error("Error setting SSM Parameters")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
return err
}

log.Infof("Setting Up Terraform")
err = initTerraform(store, appconf)
if err != nil {
log.WithError(err).Error("Error installing Terraform")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
return err
}

//r := action.ActRunnerImpl{}
//err = UpdateCoreConfig(appconf, store, nil, "")
//if err != nil {
// log.WithError(err).Error("Problem updating ssm config")
//}

log.Infof("Setting Up HTTPD Gateway from Marketplace")
err = installGateway(store, appconf)
if err != nil {
log.WithError(err).Error("Error installing HTTPD Gateway")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
return err
}

log.Infof("Setting Up Health Status Lambda")
err = installHealthStatusLambda(store, appconf)
if err != nil {
log.WithError(err).Error("Error installing Health Status")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
return err
}

log.Infof("Setting Up Basic API Gateway from Marketplace")
err = installBasicAPIGateway(store, appconf)
if err != nil {
log.WithError(err).Error("Error installing API Gateway")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
return err
}

log.Infof("Setting Up Unity UI from Marketplace")
err = installUnityUi(store, appconf)
if err != nil {
log.WithError(err).Error("Error installing unity-ui")
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
}
return
return err
}

err = store.AddToAudit(application.Bootstrap_Successful, "test")
if err != nil {
log.WithError(err).Error("Problem writing to auditlog")
return err
}

log.Infof("Bootstrap Process Completed Succesfully")
return nil
}

func provisionS3(appConfig *config.AppConfig) error {
Expand Down

0 comments on commit abd60a8

Please sign in to comment.