Skip to content

Commit d004148

Browse files
0x2b3bfa0casperdcl
andauthored
Log “experience” changes (#483)
* Log “experience” changes * Apply suggestions from code review Co-authored-by: Casper da Costa-Luis <[email protected]> * Apply suggestions from code review Co-authored-by: Casper da Costa-Luis <[email protected]> Co-authored-by: Casper da Costa-Luis <[email protected]>
1 parent 5bb0688 commit d004148

File tree

5 files changed

+125
-129
lines changed

5 files changed

+125
-129
lines changed

iterative/utils/logger.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ func (f *tpiFormatter) Format(entry *logrus.Entry) ([]byte, error) {
7070
if message == "status" {
7171
status := d.Get("status").(map[string]interface{})
7272

73-
message = fmt.Sprintf("\x1b[%dmStatus: queued 🔵\x1b[0m", colors["DEBUG"])
73+
message = fmt.Sprintf("\x1b[%dmStatus: queued \x1b[1m•\x1b[0m", colors["DEBUG"])
7474

7575
if status["succeeded"] != nil && status["succeeded"].(int) >= d.Get("parallelism").(int) {
76-
message = fmt.Sprintf("\x1b[%dmStatus: completed succesfully 🟢\x1b[0m", colors["SUCCESS"])
76+
message = fmt.Sprintf("\x1b[%dmStatus: completed succesfully \x1b[1m•\x1b[0m", colors["SUCCESS"])
7777
}
7878
if status["failed"] != nil && status["failed"].(int) > 0 {
79-
message = fmt.Sprintf("\x1b[%dmStatus: completed with errors 🔴\x1b[0m", colors["ERROR"])
79+
message = fmt.Sprintf("\x1b[%dmStatus: completed with errors \x1b[1m•\x1b[0m", colors["ERROR"])
8080
}
8181
if status["running"] != nil && status["running"].(int) >= d.Get("parallelism").(int) {
82-
message = fmt.Sprintf("\x1b[%dmStatus: running 🟡\x1b[0m", colors["WARNING"])
82+
message = fmt.Sprintf("\x1b[%dmStatus: running \x1b[1m•\x1b[0m", colors["WARNING"])
8383
}
8484
}
8585

task/aws/task.go

+31-35
Original file line numberDiff line numberDiff line change
@@ -93,145 +93,141 @@ type Task struct {
9393
}
9494

9595
func (t *Task) Create(ctx context.Context) error {
96-
logrus.Info("Creating DefaultVPC...")
96+
logrus.Info("[1/11] Importing DefaultVPC...")
9797
if err := t.DataSources.DefaultVPC.Read(ctx); err != nil {
9898
return err
9999
}
100-
logrus.Info("Creating DefaultVPCSubnet...")
100+
logrus.Info("[2/11] Importing DefaultVPCSubnet...")
101101
if err := t.DataSources.DefaultVPCSubnet.Read(ctx); err != nil {
102102
return err
103103
}
104-
logrus.Info("Creating Image...")
104+
logrus.Info("[3/11] Reading Image...")
105105
if err := t.DataSources.Image.Read(ctx); err != nil {
106106
return err
107107
}
108-
logrus.Info("Creating Bucket...")
108+
logrus.Info("[4/11] Creating Bucket...")
109109
if err := t.Resources.Bucket.Create(ctx); err != nil {
110110
return err
111111
}
112-
logrus.Info("Creating SecurityGroup...")
112+
logrus.Info("[5/11] Creating SecurityGroup...")
113113
if err := t.Resources.SecurityGroup.Create(ctx); err != nil {
114114
return err
115115
}
116-
logrus.Info("Creating KeyPair...")
116+
logrus.Info("[6/11] Creating KeyPair...")
117117
if err := t.Resources.KeyPair.Create(ctx); err != nil {
118118
return err
119119
}
120-
logrus.Info("Creating Credentials...")
120+
logrus.Info("[7/11] Reading Credentials...")
121121
if err := t.DataSources.Credentials.Read(ctx); err != nil {
122122
return err
123123
}
124-
logrus.Info("Creating LaunchTemplate...")
124+
logrus.Info("[8/11] Creating LaunchTemplate...")
125125
if err := t.Resources.LaunchTemplate.Create(ctx); err != nil {
126126
return err
127127
}
128-
logrus.Info("Creating AutoScalingGroup...")
128+
logrus.Info("[9/11] Creating AutoScalingGroup...")
129129
if err := t.Resources.AutoScalingGroup.Create(ctx); err != nil {
130130
return err
131131
}
132-
logrus.Info("Uploading Directory...")
132+
logrus.Info("[10/11] Uploading Directory...")
133133
if t.Attributes.Environment.Directory != "" {
134134
if err := t.Push(ctx, t.Attributes.Environment.Directory); err != nil {
135135
return err
136136
}
137137
}
138-
logrus.Info("Starting task...")
138+
logrus.Info("[11/11] Starting task...")
139139
if err := t.Start(ctx); err != nil {
140140
return err
141141
}
142-
logrus.Info("Done!")
142+
logrus.Info("Creation completed")
143143
t.Attributes.Addresses = t.Resources.AutoScalingGroup.Attributes.Addresses
144144
t.Attributes.Status = t.Resources.AutoScalingGroup.Attributes.Status
145145
t.Attributes.Events = t.Resources.AutoScalingGroup.Attributes.Events
146146
return nil
147147
}
148148

149149
func (t *Task) Read(ctx context.Context) error {
150-
logrus.Info("Reading DefaultVPC...")
150+
logrus.Info("[1/9] Reading DefaultVPC...")
151151
if err := t.DataSources.DefaultVPC.Read(ctx); err != nil {
152152
return err
153153
}
154-
logrus.Info("Reading DefaultVPCSubnet...")
154+
logrus.Info("[2/9] Reading DefaultVPCSubnet...")
155155
if err := t.DataSources.DefaultVPCSubnet.Read(ctx); err != nil {
156156
return err
157157
}
158-
logrus.Info("Reading Image...")
158+
logrus.Info("[3/9] Reading Image...")
159159
if err := t.DataSources.Image.Read(ctx); err != nil {
160160
return err
161161
}
162-
logrus.Info("Reading Bucket...")
162+
logrus.Info("[4/9] Reading Bucket...")
163163
if err := t.Resources.Bucket.Read(ctx); err != nil {
164164
return err
165165
}
166-
logrus.Info("Reading Credentials...")
167-
if err := t.DataSources.Credentials.Read(ctx); err != nil {
168-
return err
169-
}
170-
logrus.Info("Reading SecurityGroup...")
166+
logrus.Info("[5/9] Reading SecurityGroup...")
171167
if err := t.Resources.SecurityGroup.Read(ctx); err != nil {
172168
return err
173169
}
174-
logrus.Info("Reading KeyPair...")
170+
logrus.Info("[6/9] Reading KeyPair...")
175171
if err := t.Resources.KeyPair.Read(ctx); err != nil {
176172
return err
177173
}
178-
logrus.Info("Reading Credentials...")
174+
logrus.Info("[7/9] Reading Credentials...")
179175
if err := t.DataSources.Credentials.Read(ctx); err != nil {
180176
return err
181177
}
182-
logrus.Info("Reading LaunchTemplate...")
178+
logrus.Info("[8/9] Reading LaunchTemplate...")
183179
if err := t.Resources.LaunchTemplate.Read(ctx); err != nil {
184180
return err
185181
}
186-
logrus.Info("Reading AutoScalingGroup...")
182+
logrus.Info("[9/9] Reading AutoScalingGroup...")
187183
if err := t.Resources.AutoScalingGroup.Read(ctx); err != nil {
188184
return err
189185
}
190-
logrus.Info("Done!")
186+
logrus.Info("Read completed")
191187
t.Attributes.Addresses = t.Resources.AutoScalingGroup.Attributes.Addresses
192188
t.Attributes.Status = t.Resources.AutoScalingGroup.Attributes.Status
193189
t.Attributes.Events = t.Resources.AutoScalingGroup.Attributes.Events
194190
return nil
195191
}
196192

197193
func (t *Task) Delete(ctx context.Context) error {
198-
logrus.Info("Downloading Directory...")
194+
logrus.Info("[1/8] Downloading Directory...")
199195
if t.Read(ctx) == nil {
200196
if t.Attributes.Environment.DirectoryOut != "" {
201197
if err := t.Pull(ctx, t.Attributes.Environment.Directory, t.Attributes.Environment.DirectoryOut); err != nil && err != common.NotFoundError {
202198
return err
203199
}
204200
}
205-
logrus.Info("Emptying Bucket...")
201+
logrus.Info("[2/8] Emptying Bucket...")
206202
if err := machine.Delete(ctx, (*t.DataSources.Credentials.Resource)["RCLONE_REMOTE"]); err != nil && err != common.NotFoundError {
207203
return err
208204
}
209205
}
210-
logrus.Info("Deleting AutoScalingGroup...")
206+
logrus.Info("[3/8] Deleting AutoScalingGroup...")
211207
if err := t.Resources.AutoScalingGroup.Delete(ctx); err != nil {
212208
return err
213209
}
214-
logrus.Info("Deleting LaunchTemplate...")
210+
logrus.Info("[4/8] Deleting LaunchTemplate...")
215211
if err := t.Resources.LaunchTemplate.Delete(ctx); err != nil {
216212
return err
217213
}
218-
logrus.Info("Deleting KeyPair...")
214+
logrus.Info("[5/8] Deleting KeyPair...")
219215
if err := t.Resources.KeyPair.Delete(ctx); err != nil {
220216
return err
221217
}
222-
logrus.Info("Deleting SecurityGroup...")
218+
logrus.Info("[6/8] Deleting SecurityGroup...")
223219
if err := t.Resources.SecurityGroup.Delete(ctx); err != nil {
224220
return err
225221
}
226-
logrus.Info("Deleting Credentials...")
222+
logrus.Info("[7/8] Reading Credentials...")
227223
if err := t.DataSources.Credentials.Read(ctx); err != nil {
228224
return err
229225
}
230-
logrus.Info("Deleting Bucket...")
226+
logrus.Info("[8/8] Deleting Bucket...")
231227
if err := t.Resources.Bucket.Delete(ctx); err != nil {
232228
return err
233229
}
234-
logrus.Info("Done!")
230+
logrus.Info("Deletion completed")
235231
return nil
236232
}
237233

task/az/task.go

+30-30
Original file line numberDiff line numberDiff line change
@@ -94,137 +94,137 @@ type Task struct {
9494
}
9595

9696
func (t *Task) Create(ctx context.Context) error {
97-
logrus.Info("Creating ResourceGroup...")
97+
logrus.Info("[1/10] Creating ResourceGroup...")
9898
if err := t.Resources.ResourceGroup.Create(ctx); err != nil {
9999
return err
100100
}
101-
logrus.Info("Creating StorageAccount...")
101+
logrus.Info("[2/10] Creating StorageAccount...")
102102
if err := t.Resources.StorageAccount.Create(ctx); err != nil {
103103
return err
104104
}
105-
logrus.Info("Creating BlobContainer...")
105+
logrus.Info("[3/10] Creating BlobContainer...")
106106
if err := t.Resources.BlobContainer.Create(ctx); err != nil {
107107
return err
108108
}
109-
logrus.Info("Creating Credentials...")
109+
logrus.Info("[4/10] Creating Credentials...")
110110
if err := t.DataSources.Credentials.Read(ctx); err != nil {
111111
return err
112112
}
113-
logrus.Info("Creating VirtualNetwork...")
113+
logrus.Info("[5/10] Creating VirtualNetwork...")
114114
if err := t.Resources.VirtualNetwork.Create(ctx); err != nil {
115115
return err
116116
}
117-
logrus.Info("Creating SecurityGroup...")
117+
logrus.Info("[6/10] Creating SecurityGroup...")
118118
if err := t.Resources.SecurityGroup.Create(ctx); err != nil {
119119
return err
120120
}
121-
logrus.Info("Creating Subnet...")
121+
logrus.Info("[7/10] Creating Subnet...")
122122
if err := t.Resources.Subnet.Create(ctx); err != nil {
123123
return err
124124
}
125-
logrus.Info("Creating VirtualMachineScaleSet...")
125+
logrus.Info("[8/10] Creating VirtualMachineScaleSet...")
126126
if err := t.Resources.VirtualMachineScaleSet.Create(ctx); err != nil {
127127
return err
128128
}
129-
logrus.Info("Uploading Directory...")
129+
logrus.Info("[9/10] Uploading Directory...")
130130
if t.Attributes.Environment.Directory != "" {
131131
if err := t.Push(ctx, t.Attributes.Environment.Directory); err != nil {
132132
return err
133133
}
134134
}
135-
logrus.Info("Starting task...")
135+
logrus.Info("[10/10] Starting task...")
136136
if err := t.Start(ctx); err != nil {
137137
return err
138138
}
139-
logrus.Info("Done!")
139+
logrus.Info("Creation completed")
140140
t.Attributes.Addresses = t.Resources.VirtualMachineScaleSet.Attributes.Addresses
141141
t.Attributes.Status = t.Resources.VirtualMachineScaleSet.Attributes.Status
142142
t.Attributes.Events = t.Resources.VirtualMachineScaleSet.Attributes.Events
143143
return nil
144144
}
145145

146146
func (t *Task) Read(ctx context.Context) error {
147-
logrus.Info("Reading ResourceGroup...")
147+
logrus.Info("[1/8] Reading ResourceGroup...")
148148
if err := t.Resources.ResourceGroup.Read(ctx); err != nil {
149149
return err
150150
}
151-
logrus.Info("Reading StorageAccount...")
151+
logrus.Info("[2/8] Reading StorageAccount...")
152152
if err := t.Resources.StorageAccount.Read(ctx); err != nil {
153153
return err
154154
}
155-
logrus.Info("Reading BlobContainer...")
155+
logrus.Info("[3/8] Reading BlobContainer...")
156156
if err := t.Resources.BlobContainer.Read(ctx); err != nil {
157157
return err
158158
}
159-
logrus.Info("Reading Credentials...")
159+
logrus.Info("[4/8] Reading Credentials...")
160160
if err := t.DataSources.Credentials.Read(ctx); err != nil {
161161
return err
162162
}
163-
logrus.Info("Reading VirtualNetwork...")
163+
logrus.Info("[5/8] Reading VirtualNetwork...")
164164
if err := t.Resources.VirtualNetwork.Read(ctx); err != nil {
165165
return err
166166
}
167-
logrus.Info("Reading SecurityGroup...")
167+
logrus.Info("[6/8] Reading SecurityGroup...")
168168
if err := t.Resources.SecurityGroup.Read(ctx); err != nil {
169169
return err
170170
}
171-
logrus.Info("Reading Subnet...")
171+
logrus.Info("[7/8] Reading Subnet...")
172172
if err := t.Resources.Subnet.Read(ctx); err != nil {
173173
return err
174174
}
175-
logrus.Info("Reading VirtualMachineScaleSet...")
175+
logrus.Info("[8/8] Reading VirtualMachineScaleSet...")
176176
if err := t.Resources.VirtualMachineScaleSet.Read(ctx); err != nil {
177177
return err
178178
}
179-
logrus.Info("Done!")
179+
logrus.Info("Read completed")
180180
t.Attributes.Addresses = t.Resources.VirtualMachineScaleSet.Attributes.Addresses
181181
t.Attributes.Status = t.Resources.VirtualMachineScaleSet.Attributes.Status
182182
t.Attributes.Events = t.Resources.VirtualMachineScaleSet.Attributes.Events
183183
return nil
184184
}
185185

186186
func (t *Task) Delete(ctx context.Context) error {
187-
logrus.Info("Downloading Directory...")
187+
logrus.Info("[1/9] Downloading Directory...")
188188
if t.Read(ctx) == nil {
189189
if t.Attributes.Environment.DirectoryOut != "" {
190190
if err := t.Pull(ctx, t.Attributes.Environment.Directory, t.Attributes.Environment.DirectoryOut); err != nil && err != common.NotFoundError {
191191
return err
192192
}
193193
}
194-
logrus.Info("Emptying Bucket...")
194+
logrus.Info("[2/9] Emptying Bucket...")
195195
if err := machine.Delete(ctx, (*t.DataSources.Credentials.Resource)["RCLONE_REMOTE"]); err != nil && err != common.NotFoundError {
196196
return err
197197
}
198198
}
199-
logrus.Info("Deleting VirtualMachineScaleSet...")
199+
logrus.Info("[3/9] Deleting VirtualMachineScaleSet...")
200200
if err := t.Resources.VirtualMachineScaleSet.Delete(ctx); err != nil {
201201
return err
202202
}
203-
logrus.Info("Deleting Subnet...")
203+
logrus.Info("[4/9] Deleting Subnet...")
204204
if err := t.Resources.Subnet.Delete(ctx); err != nil {
205205
return err
206206
}
207-
logrus.Info("Deleting SecurityGroup...")
207+
logrus.Info("[5/9] Deleting SecurityGroup...")
208208
if err := t.Resources.SecurityGroup.Delete(ctx); err != nil {
209209
return err
210210
}
211-
logrus.Info("Deleting VirtualNetwork...")
211+
logrus.Info("[6/9] Deleting VirtualNetwork...")
212212
if err := t.Resources.VirtualNetwork.Delete(ctx); err != nil {
213213
return err
214214
}
215-
logrus.Info("Deleting BlobContainer...")
215+
logrus.Info("[7/9] Deleting BlobContainer...")
216216
if err := t.Resources.BlobContainer.Delete(ctx); err != nil {
217217
return err
218218
}
219-
logrus.Info("Deleting StorageAccount...")
219+
logrus.Info("[8/9] Deleting StorageAccount...")
220220
if err := t.Resources.StorageAccount.Delete(ctx); err != nil {
221221
return err
222222
}
223-
logrus.Info("Deleting ResourceGroup...")
223+
logrus.Info("[9/9] Deleting ResourceGroup...")
224224
if err := t.Resources.ResourceGroup.Delete(ctx); err != nil {
225225
return err
226226
}
227-
logrus.Info("Done!")
227+
logrus.Info("Deletion completed")
228228
return nil
229229
}
230230

0 commit comments

Comments
 (0)