Skip to content

Commit abd60a8

Browse files
authored
Merge pull request #49 from unity-sds/boostrap_logging
Some more verbose/improved error logging for the bootstrap process.
2 parents 62c8998 + df50afb commit abd60a8

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

backend/cmd/web/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ var (
3737
}
3838
if bootstrap == true || !initialised {
3939
log.Info("Bootstrap flag set or uninitialised workdir, bootstrapping")
40-
processes.BootstrapEnv(&appConfig)
40+
err := processes.BootstrapEnv(&appConfig)
41+
if err != nil {
42+
log.Errorf("Errors were encountered during bootstrap process. Please check the errorlog for more details.")
43+
}
4144
}
4245
router := web.DefineRoutes(appConfig)
4346

backend/internal/database/operations.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ func (g GormDatastore) StoreSSMParams(p []config.SSMParameter, owner string) err
9696
model.Value = param.Value
9797
model.Owner = owner
9898

99+
log.WithFields(log.Fields{
100+
"name": param.Name,
101+
"type": param.Type,
102+
"owner": owner,
103+
}).Info("Storing SSM parameter")
104+
99105
// Use Save to insert or update the record
100106
if err := g.db.Save(&model).Error; err != nil {
101107
// Handle error for Save

backend/internal/processes/bootstrap.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/unity-sds/unity-management-console/backend/types"
1818
)
1919

20-
func BootstrapEnv(appconf *config.AppConfig) {
20+
func BootstrapEnv(appconf *config.AppConfig) error {
2121
// Print out everything in appConfig
2222
log.Infof("AppConfig contents:")
2323
log.Infof("GithubToken: %s", appconf.GithubToken)
@@ -36,94 +36,109 @@ func BootstrapEnv(appconf *config.AppConfig) {
3636
for _, item := range appconf.MarketplaceItems {
3737
log.Infof(" - Name: %s, Version: %s", item.Name, item.Version)
3838
}
39+
40+
log.Infof("Creating Local Database")
3941
store, err := database.NewGormDatastore()
4042
if err != nil {
4143
log.WithError(err).Error("Problem creating database")
4244
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
4345
if err != nil {
4446
log.WithError(err).Error("Problem writing to auditlog")
4547
}
46-
return
48+
return err
4749
}
4850

51+
log.Infof("Provisioning S3 Bucket")
4952
err = provisionS3(appconf)
5053
if err != nil {
5154
log.WithError(err).Error("Error provisioning S3 bucket")
5255
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
5356
if err != nil {
5457
log.WithError(err).Error("Problem writing to auditlog")
5558
}
56-
return
59+
return err
5760
}
61+
62+
log.Infof("Setting Up Default SSM Parameters")
5863
err = storeDefaultSSMParameters(appconf, store)
5964
if err != nil {
6065
log.WithError(err).Error("Error setting SSM Parameters")
6166
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
6267
if err != nil {
6368
log.WithError(err).Error("Problem writing to auditlog")
6469
}
65-
return
70+
return err
6671
}
72+
73+
log.Infof("Setting Up Terraform")
6774
err = initTerraform(store, appconf)
6875
if err != nil {
6976
log.WithError(err).Error("Error installing Terraform")
7077
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
7178
if err != nil {
7279
log.WithError(err).Error("Problem writing to auditlog")
7380
}
74-
return
81+
return err
7582
}
7683

7784
//r := action.ActRunnerImpl{}
7885
//err = UpdateCoreConfig(appconf, store, nil, "")
7986
//if err != nil {
8087
// log.WithError(err).Error("Problem updating ssm config")
8188
//}
89+
90+
log.Infof("Setting Up HTTPD Gateway from Marketplace")
8291
err = installGateway(store, appconf)
8392
if err != nil {
8493
log.WithError(err).Error("Error installing HTTPD Gateway")
8594
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
8695
if err != nil {
8796
log.WithError(err).Error("Problem writing to auditlog")
8897
}
89-
return
98+
return err
9099
}
91100

101+
log.Infof("Setting Up Health Status Lambda")
92102
err = installHealthStatusLambda(store, appconf)
93103
if err != nil {
94104
log.WithError(err).Error("Error installing Health Status")
95105
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
96106
if err != nil {
97107
log.WithError(err).Error("Problem writing to auditlog")
98108
}
99-
return
109+
return err
100110
}
101111

112+
log.Infof("Setting Up Basic API Gateway from Marketplace")
102113
err = installBasicAPIGateway(store, appconf)
103114
if err != nil {
104115
log.WithError(err).Error("Error installing API Gateway")
105116
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
106117
if err != nil {
107118
log.WithError(err).Error("Problem writing to auditlog")
108119
}
109-
return
120+
return err
110121
}
111122

123+
log.Infof("Setting Up Unity UI from Marketplace")
112124
err = installUnityUi(store, appconf)
113125
if err != nil {
114126
log.WithError(err).Error("Error installing unity-ui")
115127
err = store.AddToAudit(application.Bootstrap_Unsuccessful, "test")
116128
if err != nil {
117129
log.WithError(err).Error("Problem writing to auditlog")
118130
}
119-
return
131+
return err
120132
}
121133

122134
err = store.AddToAudit(application.Bootstrap_Successful, "test")
123135
if err != nil {
124136
log.WithError(err).Error("Problem writing to auditlog")
137+
return err
125138
}
126139

140+
log.Infof("Bootstrap Process Completed Succesfully")
141+
return nil
127142
}
128143

129144
func provisionS3(appConfig *config.AppConfig) error {

0 commit comments

Comments
 (0)