TP-47360 : Created service for uploading slack conversations to s3 and send request to maverick for generating RCA (#290)
* TP-47360| created services to upload slack conversation to cloud and send urls to generate RCA * created rca input repository * TP-47360| enabled generating rca service on resolution * resolved merge conflicts * TP-47360| added migration script for creating rca input table * changed json response structure according to contract * added unit tests * removed api to make gen ai call * made changes in message format posted in slack * changed entity struct and adding flag to enable rca generation * attaching title, description and replies related to incident status block * made design changes in message format
This commit is contained in:
committed by
GitHub
parent
a1d3d0dc39
commit
2dd4d710e5
@@ -2,13 +2,14 @@ package action
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/viper"
|
||||
"houston/common/util"
|
||||
"houston/logger"
|
||||
"houston/model/incident"
|
||||
"houston/model/severity"
|
||||
"houston/model/tag"
|
||||
"houston/model/team"
|
||||
"strings"
|
||||
"houston/service/rca"
|
||||
"time"
|
||||
|
||||
"github.com/slack-go/slack"
|
||||
@@ -22,15 +23,17 @@ type ResolveIncidentAction struct {
|
||||
tagService *tag.Repository
|
||||
teamRepository *team.Repository
|
||||
severityRepository *severity.Repository
|
||||
rcaService *rca.RcaService
|
||||
}
|
||||
|
||||
func NewIncidentResolveProcessor(client *socketmode.Client, incidentService *incident.Repository, tagService *tag.Repository, teamRepository *team.Repository, severityRepository *severity.Repository) *ResolveIncidentAction {
|
||||
func NewIncidentResolveProcessor(client *socketmode.Client, incidentService *incident.Repository, tagService *tag.Repository, teamRepository *team.Repository, severityRepository *severity.Repository, rcaService *rca.RcaService) *ResolveIncidentAction {
|
||||
return &ResolveIncidentAction{
|
||||
client: client,
|
||||
incidentService: incidentService,
|
||||
tagService: tagService,
|
||||
teamRepository: teamRepository,
|
||||
severityRepository: severityRepository,
|
||||
rcaService: rcaService,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,16 +97,6 @@ func (irp *ResolveIncidentAction) IncidentResolveProcess(callback slack.Interact
|
||||
return
|
||||
}
|
||||
|
||||
// check if resolution text is set
|
||||
if strings.TrimSpace(incidentEntity.RCA) == "" {
|
||||
msgOption := slack.MsgOptionText(fmt.Sprintf("`RCA is not written`"), false)
|
||||
_, errMessage := irp.client.PostEphemeral(callback.Channel.ID, callback.User.ID, msgOption)
|
||||
if errMessage != nil {
|
||||
logger.Error("post response failed for set RCA", zap.Error(errMessage))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("successfully resolved the incident",
|
||||
zap.String("channel", channelId),
|
||||
zap.String("user_id", callback.User.ID))
|
||||
@@ -125,6 +118,21 @@ func (irp *ResolveIncidentAction) IncidentResolveProcess(callback slack.Interact
|
||||
logger.Error("failed to post archiving time to incident channel", zap.String("channel id", channelId), zap.Error(err))
|
||||
}
|
||||
}
|
||||
if viper.GetBool("RCA_GENERATION_ENABLED") {
|
||||
err = irp.rcaService.SendConversationDataForGeneratingRCA(incidentEntity.ID, channelId)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("failed to generate rca for incident id: %d of channel id: %s", incidentEntity.ID, channelId), zap.Error(err))
|
||||
_, _, errMessage := irp.client.PostMessage(channelId, slack.MsgOptionText("`Some issue occurred while generating RCA`", false))
|
||||
if errMessage != nil {
|
||||
logger.Error("post response failed for rca failure message", zap.Error(errMessage))
|
||||
}
|
||||
} else {
|
||||
_, _, errMessage := irp.client.PostMessage(channelId, slack.MsgOptionText("System RCA generation is in progress and might take 2 to 4 minutes.", false))
|
||||
if errMessage != nil {
|
||||
logger.Error("post response failed for rca generated message", zap.Error(errMessage))
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
msgOption := slack.MsgOptionText(fmt.Sprintf("`Please set tag value`"), false)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"houston/model/team"
|
||||
"houston/pkg/slackbot"
|
||||
incidentService "houston/service/incident"
|
||||
"houston/service/rca"
|
||||
slack2 "houston/service/slack"
|
||||
|
||||
"github.com/slack-go/slack"
|
||||
@@ -52,6 +53,7 @@ func NewBlockActionProcessor(
|
||||
slackbotClient *slackbot.Client,
|
||||
incidentServiceV2 *incidentService.IncidentServiceV2,
|
||||
slackService *slack2.SlackService,
|
||||
rcaService *rca.RcaService,
|
||||
) *BlockActionProcessor {
|
||||
|
||||
return &BlockActionProcessor{
|
||||
@@ -61,7 +63,7 @@ func NewBlockActionProcessor(
|
||||
showIncidentsAction: action.ShowIncidentsBlockAction(socketModeClient, teamService),
|
||||
assignIncidentAction: action.NewAssignIncidentAction(socketModeClient, incidentRepository),
|
||||
incidentResolveAction: action.NewIncidentResolveProcessor(socketModeClient, incidentRepository,
|
||||
tagService, teamService, severityService),
|
||||
tagService, teamService, severityService, rcaService),
|
||||
incidentUpdateAction: action.NewIncidentUpdateAction(socketModeClient, incidentRepository,
|
||||
tagService, teamService, severityService),
|
||||
incidentUpdateTypeAction: action.NewIncidentUpdateTypeAction(socketModeClient, incidentRepository,
|
||||
|
||||
Reference in New Issue
Block a user