INFRA-3699 : Don't skip other independent flows on any failure in create incident (#454)
This commit is contained in:
@@ -635,6 +635,7 @@ func createIncidentWorkflow(
|
||||
return err
|
||||
}
|
||||
}
|
||||
var workflowErrors []string
|
||||
_, err = postIncidentSummary(
|
||||
channel.ID,
|
||||
incidentEntity,
|
||||
@@ -651,7 +652,7 @@ func createIncidentWorkflow(
|
||||
fmt.Sprintf("%s [%s] Error in posting incident summary to slack channel", logTag, incidentName),
|
||||
zap.Error(err),
|
||||
)
|
||||
return err
|
||||
workflowErrors = append(workflowErrors, err.Error())
|
||||
}
|
||||
logger.Info(fmt.Sprintf("%s [%s] Incident summary posted", logTag, incidentName))
|
||||
|
||||
@@ -670,12 +671,19 @@ func createIncidentWorkflow(
|
||||
logTag, incidentName, incidentEntity.CreatedBy, incidentEntity.SlackChannel,
|
||||
),
|
||||
)
|
||||
return err
|
||||
workflowErrors = append(workflowErrors, err.Error())
|
||||
}
|
||||
logger.Info(fmt.Sprintf("%s [%s] Incident creator is added to the slack channel", logTag, incidentName))
|
||||
}
|
||||
// Call addMembersToIncident(), provide channel, team name and severity
|
||||
err = addMembersToIncident(channel, i, reportingTeam, responderTeam, severityEntity, incidentName)
|
||||
if err != nil {
|
||||
logger.Error(
|
||||
fmt.Sprintf("%s [%s] Failed to add members to the incident", logTag, incidentName),
|
||||
zap.Error(err),
|
||||
)
|
||||
workflowErrors = append(workflowErrors, err.Error())
|
||||
}
|
||||
|
||||
// Tag oncall
|
||||
// Call slack service to tag the oncall, provide incident id and slack id to be tagged
|
||||
@@ -697,7 +705,7 @@ func createIncidentWorkflow(
|
||||
fmt.Sprintf("%s [%s] Failed to assign responder to the incident", logTag, incidentName),
|
||||
zap.Error(err),
|
||||
)
|
||||
return err
|
||||
workflowErrors = append(workflowErrors, err.Error())
|
||||
}
|
||||
logger.Info(fmt.Sprintf("%s [%s] Responder is assigned to the incident", logTag, incidentName))
|
||||
|
||||
@@ -705,13 +713,17 @@ func createIncidentWorkflow(
|
||||
err = incidentService.PostIncidentSLAMessageToChannel(incidentEntity, i.severityRepository, i.slackService.GetSocketModeClient())
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("%s [%s] Failed to post SLA information to the slack channel", logTag, incidentName), zap.Error(err))
|
||||
return err
|
||||
workflowErrors = append(workflowErrors, err.Error())
|
||||
}
|
||||
i.createConferenceAndPostMessageInSlack(incidentEntity)
|
||||
|
||||
err = i.addIncidentTeam(incidentEntity.ID, incidentEntity.TeamId)
|
||||
if err != nil {
|
||||
return err
|
||||
workflowErrors = append(workflowErrors, err.Error())
|
||||
}
|
||||
|
||||
if len(workflowErrors) > 0 {
|
||||
return fmt.Errorf(strings.Join(workflowErrors, ", "))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -287,11 +287,13 @@ func (s *SlackService) InviteUsersToConversation(channelId string, userIds ...st
|
||||
for _, userId := range userIds {
|
||||
userInfo, err := s.GetUserBySlackID(userId)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("%s failed to get user info for userId: %s : %v", logTag, userId, err))
|
||||
failedToAddUsers = append(failedToAddUsers, userId)
|
||||
} else {
|
||||
allUserNames = append(allUserNames, userInfo.Profile.RealName)
|
||||
_, err := s.SocketModeClientWrapper.InviteUsersToConversation(channelId, userInfo.ID)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("%s failed to invite user to conversation. userId: %s : %v", logTag, userId, err))
|
||||
failedToAddUsers = append(failedToAddUsers, userInfo.ID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user