TP-51655 | Implementation for creating conference event when severity is updated to other than sev3 (#334)

* TP-38709 | Merging the changes to master on the logfix

* TP-51652 | Added condition to not create conference events for sev3 severity incidents

* TP-51653 | Added condition to skip krakatoa workflow for sev 3 incidents

* TP-51655 | Added implementation to create google meet when severity is changed from sev3

* TP-51655 | Updated wait group count

* TP-51655 | Removed service as a param
This commit is contained in:
Ajay Devarakonda
2023-12-19 18:17:39 +05:30
committed by GitHub
parent 2f77715af2
commit 1750ac3c18
4 changed files with 55 additions and 28 deletions

View File

@@ -90,7 +90,8 @@ func (isp *IncidentUpdateSevertityAction) IncidentUpdateSeverity(callback slack.
logger.Error(fmt.Sprintf("error in fetching entities for incident with id: %d %v", incidentEntity.ID, err))
return
}
var payload interface{}
isp.client.Ack(*request, payload)
if err := isp.incidentServiceV2.UpdateSeverityId(
service.UpdateIncidentRequest{
Id: incidentEntity.ID,
@@ -105,8 +106,6 @@ func (isp *IncidentUpdateSevertityAction) IncidentUpdateSeverity(callback slack.
); err != nil {
logger.Error(fmt.Sprintf("error in updating severity: %v", err))
}
var payload interface{}
isp.client.Ack(*request, payload)
return
}

View File

@@ -71,7 +71,7 @@ func NewIncidentServiceV2(db *gorm.DB) *IncidentServiceV2 {
const logTag = "[create-incident-v2]"
const updateLogTag = "[update-incident-v2]"
const updateSeveritySlackActionCount = 5
const updateSeveritySlackActionCount = 6
const updateStatusSlackActionCount = 2
const updateTeamSlackActionCount = 5
@@ -425,25 +425,7 @@ func createIncidentWorkflow(
logger.Error(fmt.Sprintf("%s [%s] Failed to post SLA information to the slack channel", logTag, incidentName), zap.Error(err))
return err
}
if viper.GetBool("ENABLE_CONFERENCE") {
calendarActions := conference2.GetCalendarActions()
calendarService := service2.NewCalendarService(calendarActions)
calendarEvent, err := calendarService.CreateEvent(channel.Name)
conferenceLink := calendarEvent.ConferenceLink
if err != nil {
logger.Error(fmt.Sprintf("%s [%s] Error while creating conference", logTag, incidentName), zap.Error(err))
} else {
util.UpdateIncidentWithConferenceDetails(incidentEntity, calendarEvent, i.incidentRepository)
//ToDo Update the summary in slack channel with Conference link. To be done post update incident refactoring
i.slackService.AddBookmark(conferenceLink, channel, calendarService.GetConferenceTitle())
_, err := i.slackService.PostMessage(fmt.Sprintf(util.ConferenceMessage, conferenceLink), false, channel)
if err != nil {
logger.Error(fmt.Sprintf("%s [%s] Failed to post Conference link: %s", logTag, incidentName, conferenceLink))
}
logger.Info(fmt.Sprintf("%s [%s] Conference link posted to the channel %s", logTag, incidentName, conferenceLink))
}
}
i.createConferenceAndPostMessageInSlack(incidentEntity)
return nil
}
@@ -1242,7 +1224,9 @@ func (i *IncidentServiceV2) UpdateSeverityWorkflow(
slackErrors = append(slackErrors, err)
}
})
go util.ExecuteConcurrentAction(&waitGroup, func() {
i.createConferenceAndPostMessageInSlack(incidentEntity)
})
waitGroup.Wait()
if slackErrors != nil && len(slackErrors) != 0 {
return slackErrors[0]
@@ -1624,3 +1608,47 @@ func (i *IncidentServiceV2) addDefaultUsersToIncident(
return nil
}
func (i *IncidentServiceV2) createConferenceAndPostMessageInSlack(incidentEntity *incident.IncidentEntity) {
incidentName := incidentEntity.IncidentName
if viper.GetBool("ENABLE_CONFERENCE") {
if incidentEntity.SeverityId != incident.Sev3Id && incidentEntity.ConferenceId == "" {
calendarEvent, err := createConferenceEvent(incidentName)
conferenceLink := calendarEvent.ConferenceLink
if err != nil {
logger.Error(fmt.Sprintf("%s [%s] Error while creating conference", logTag, incidentName), zap.Error(err))
} else {
{
util.UpdateIncidentWithConferenceDetails(incidentEntity, calendarEvent, i.incidentRepository)
teamEntity, severityEntity, incidentStatusEntity, incidentChannels, err :=
i.FetchAllEntitiesForIncident(incidentEntity)
if err != nil {
logger.Error(fmt.Sprintf("%s Failed to fetch entities for inident: %s", logTag, incidentName))
}
processUpdateMessage(incidentEntity, teamEntity, severityEntity, incidentStatusEntity, incidentChannels, i)
i.addBookMarkAndPostMessageInSlack(incidentName, conferenceLink, incidentEntity.SlackChannel)
}
}
} else {
logger.Info(fmt.Sprintf("%s Condition required to create conference has not been satisfied for the incident %s", logTag, incidentEntity.IncidentName))
}
} else {
logger.Info(fmt.Sprintf("%s Unable to create conference as conference flag is false %s", logTag, incidentEntity.IncidentName))
}
}
func createConferenceEvent(incidentName string) (conference2.EventData, error) {
calendarActions := conference2.GetCalendarActions()
calendarService := service2.NewCalendarService(calendarActions)
calendarEvent, err := calendarService.CreateEvent(incidentName)
return calendarEvent, err
}
func (i *IncidentServiceV2) addBookMarkAndPostMessageInSlack(incidentName string, conferenceLink string, slackChannel string) {
i.slackService.AddBookmark(conferenceLink, slackChannel, "Google Meet")
_, err := i.slackService.PostMessageByChannelID(fmt.Sprintf(util.ConferenceMessage, conferenceLink), false, slackChannel)
if err != nil {
logger.Error(fmt.Sprintf("%s [%s] Failed to post Conference link: %s", logTag, incidentName, conferenceLink))
}
logger.Info(fmt.Sprintf("%s [%s] Conference link posted to the incidentChannel %s", logTag, incidentName, conferenceLink))
}

View File

@@ -89,11 +89,11 @@ func (s *SlackService) UploadFileByPath(filePath string, channel string) (file *
return file, nil
}
func (s *SlackService) AddBookmark(bookmark string, channel *slack.Channel, title string) {
func (s *SlackService) AddBookmark(bookmark string, channelId string, title string) {
bookmarkParam := slack.AddBookmarkParameters{Link: bookmark, Title: title}
_, err := s.SocketModeClientWrapper.AddBookmark(channel.ID, bookmarkParam)
_, err := s.SocketModeClientWrapper.AddBookmark(channelId, bookmarkParam)
if err != nil {
e := fmt.Sprintf("%s Failed to add book mark into channel: %s", logTag, channel.Name)
e := fmt.Sprintf("%s Failed to add book mark into channel: %s", logTag, channelId)
logger.Error(e, zap.Error(err))
}
}

View File

@@ -13,7 +13,7 @@ type ISlackService interface {
GetSocketModeClient() *socketmode.Client
SendDM(recipientID string, messageText string) error
PostMessage(message string, escape bool, channel *slack.Channel) (string, error)
AddBookmark(bookmark string, channel *slack.Channel, title string)
AddBookmark(bookmark string, channelId string, title string)
PostMessageOption(channelID string, messageOption slack.MsgOption) (string, error)
PostMessageByChannelID(message string, escape bool, channelID string) (string, error)
PostEphemeralByChannelID(message string, userID string, escape bool, channelID string) error