Skip to content

Commit c3eeb38

Browse files
committed
More cfgmgmt_actions diagnostics fixes
Signed-off-by: Daniel DeLeo <dan@chef.io>
1 parent 3318669 commit c3eeb38

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

components/automate-cli/pkg/diagnostics/integration/cfgmgmt_actions.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,16 @@ func CreateCfgmgmtActionsDiagnostic() diagnostics.Diagnostic {
8383
return err
8484
}
8585

86-
save.CreatedEntities = append(save.CreatedEntities, cfgmgmtActionsEntity{
86+
e := cfgmgmtActionsEntity{
8787
EntityName: entityName,
8888
RecordedAtMillis: day.UnixNano() / int64(time.Millisecond),
89-
})
89+
}
90+
save.CreatedEntities = append(save.CreatedEntities, e)
9091

9192
tstCtx.SetValue("cfgmgmt-actions", save)
9293

9394
resp, err := tstCtx.DoLBRequest(
94-
"/api/v0/events/data-collector",
95+
"/api/v0/events/data-collector?z=cfgmgmt-actions",
9596
lbrequest.WithMethod("POST"),
9697
lbrequest.WithJSONBody(buf.String()),
9798
)
@@ -123,7 +124,7 @@ func CreateCfgmgmtActionsDiagnostic() diagnostics.Diagnostic {
123124
maxTries := 5
124125

125126
for _, entity := range loaded.CreatedEntities {
126-
reqPath := fmt.Sprintf("/api/v0/eventfeed?collapse=true&page_size=100&start=%d&end=%d", entity.RecordedAtMillis-1000, entity.RecordedAtMillis+1000)
127+
reqPath := fmt.Sprintf("/api/v0/eventfeed?collapse=true&page_size=100&start=%d&end=%d", entity.RecordedAtMillis-600000, entity.RecordedAtMillis+600000)
127128
found := false
128129

129130
type eventsFeedResp struct {
@@ -163,7 +164,7 @@ func CreateCfgmgmtActionsDiagnostic() diagnostics.Diagnostic {
163164
}
164165
time.Sleep(5 * time.Duration(tries) * time.Second)
165166
}
166-
assert.True(tstCtx, found, "Could not find entity %s in GET %s; did get %+v", entity.EntityName, reqPath, respUnmarshalled)
167+
assert.True(tstCtx, found, "[%s] Could not find entity %s in GET %s; did get %+v", time.Now().UTC().String(), entity.EntityName, reqPath, respUnmarshalled)
167168
}
168169

169170
},

components/ingest-service/pipeline/message/chef_action.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ func (chefAction ChefAction) FinishProcessing(err error) {
4242
if err == nil {
4343
// Adding new metric; Time for a message to go through the pipeline
4444
log.WithFields(log.Fields{
45-
"message_id": chefAction.ID,
46-
"message": "ChefAction",
47-
"metric": "pipeline",
48-
"type": "ingest_time",
49-
"ms": chefAction.ClockProcessingTime(),
45+
"message_id": chefAction.ID,
46+
"message": "ChefAction",
47+
"metric": "pipeline",
48+
"type": "ingest_time",
49+
"ms": chefAction.ClockProcessingTime(),
50+
"entity_name": chefAction.InternalChefAction.EntityName,
51+
"entity_type": chefAction.InternalChefAction.EntityType,
52+
"entity_task": chefAction.InternalChefAction.Task,
5053
}).Info("Message ingested successfully")
5154
}
5255
}

components/ingest-service/pipeline/publisher/chef_action.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ func ChefAction(in <-chan message.ChefAction, client backend.Client, out chan<-
3434

3535
err := client.InsertAction(msg.Ctx, msg.InternalChefAction)
3636
if err != nil {
37+
log.WithError(err).WithFields(log.Fields{
38+
"publisher_id": number,
39+
"message_id": msg.ID,
40+
"buffer_size": len(out),
41+
"internal_action": msg.InternalChefAction,
42+
"entity": msg.InternalChefAction.EntityName,
43+
}).Error("Failed to insert Chef Action")
3744
msg.FinishProcessing(status.Errorf(codes.Internal, err.Error()))
3845
} else {
3946
out <- msg

components/ingest-service/server/chef.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (s *ChefIngestServer) ProcessChefRun(ctx context.Context, run *chef.Run) (*
6565
err = <-errc
6666

6767
if err != nil {
68-
log.WithError(err).Error("Message failure")
68+
log.WithError(err).Error("Chef run ingestion failure")
6969
}
7070
} else if run.GetMessageType() == "run_start" {
7171
log.WithFields(log.Fields{
@@ -95,7 +95,7 @@ func (s *ChefIngestServer) ProcessChefAction(ctx context.Context, action *chef.A
9595
err := <-errc
9696

9797
if err != nil {
98-
log.WithError(err).Error("Message failure")
98+
log.WithError(err).Error("Chef Action ingestion failure")
9999
}
100100
return &response.ProcessChefActionResponse{}, err
101101
}

0 commit comments

Comments
 (0)