TP-51651 | Implemented delete event (#335)
* TP-38709 | Merging the changes to master on the logfix * TP-51651 | Added implementation for deleting event on incident resolve and duplicate status updates * TP-51651 | Added delete event as go routine * TP-51651 | Added go routine in resolve action as well * TP-51651 | Fixed naming conventions * TP-51651 | Fixed naming conventions
This commit is contained in:
@@ -10,10 +10,12 @@ import (
|
||||
"houston/model/tag"
|
||||
"houston/model/team"
|
||||
"houston/model/user"
|
||||
conferenceActions "houston/pkg/conference"
|
||||
"houston/pkg/postgres"
|
||||
"houston/pkg/rest"
|
||||
rcaRepository "houston/repository/rca/impl"
|
||||
"houston/repository/rcaInput"
|
||||
"houston/service/conference"
|
||||
"houston/service/documentService"
|
||||
incidentService "houston/service/incident"
|
||||
"houston/service/rca"
|
||||
@@ -37,6 +39,7 @@ type houstonServices struct {
|
||||
rcaInputRepository *rcaInput.Repository
|
||||
userRepository *user.Repository
|
||||
rcaService *rca.RcaService
|
||||
calendarService *conference.CalendarService
|
||||
}
|
||||
|
||||
var appContext *applicationContext
|
||||
@@ -65,6 +68,7 @@ func InitializeServices() {
|
||||
rcaInputRepository: initRCAInputRepo(),
|
||||
userRepository: initUserRepo(),
|
||||
rcaService: initRCAService(),
|
||||
calendarService: initCalendarService(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +135,16 @@ func initDocumentService() *documentService.ActionsImpl {
|
||||
return documentService.NewActionsImpl(getRestClient())
|
||||
}
|
||||
|
||||
func initCalendarService() *conference.CalendarService {
|
||||
calendarActions := conferenceActions.GetCalendarActions()
|
||||
calendarService := conference.NewCalendarService(calendarActions)
|
||||
return calendarService
|
||||
}
|
||||
|
||||
func GetCalendarService() *conference.CalendarService {
|
||||
return services.calendarService
|
||||
}
|
||||
|
||||
func GetDocumentService() *documentService.ActionsImpl {
|
||||
return initDocumentService()
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/slack-go/slack"
|
||||
"github.com/slack-go/slack/socketmode"
|
||||
"go.uber.org/zap"
|
||||
"houston/appcontext"
|
||||
"houston/common/util"
|
||||
"houston/internal/processor/action/view"
|
||||
"houston/logger"
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
"houston/model/severity"
|
||||
"houston/model/tag"
|
||||
"houston/model/team"
|
||||
"houston/service/conference"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -22,6 +24,7 @@ type DuplicateIncidentAction struct {
|
||||
tagService *tag.Repository
|
||||
teamRepository *team.Repository
|
||||
severityRepository *severity.Repository
|
||||
calendarService conference.ICalendarService
|
||||
}
|
||||
|
||||
func NewDuplicateIncidentProcessor(
|
||||
@@ -37,6 +40,7 @@ func NewDuplicateIncidentProcessor(
|
||||
tagService: tagService,
|
||||
teamRepository: teamRepository,
|
||||
severityRepository: severityRepository,
|
||||
calendarService: appcontext.GetCalendarService(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +92,6 @@ func (dip *DuplicateIncidentAction) DuplicateIncidentProcess(callback slack.Inte
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if isRcaSet {
|
||||
now := time.Now()
|
||||
incidentEntity.Status = 5
|
||||
@@ -130,7 +133,12 @@ func (dip *DuplicateIncidentAction) DuplicateIncidentProcess(callback slack.Inte
|
||||
}
|
||||
}
|
||||
}()
|
||||
//ToDo() Delete Conference event if exists and if incident is duplicated
|
||||
go func() {
|
||||
err := dip.calendarService.DeleteEvent(incidentEntity.ConferenceId)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Unable to delete conference for incident id: %d", incidentEntity.ID), zap.Error(err))
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
msgOption := slack.MsgOptionText(fmt.Sprintf("`Submitted incident id: %s is not a valid open incident. Check and resubmit`", incidentRca), false)
|
||||
_, errMessage := dip.client.PostEphemeral(channelId, user.ID, msgOption)
|
||||
@@ -139,7 +147,6 @@ func (dip *DuplicateIncidentAction) DuplicateIncidentProcess(callback slack.Inte
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var payload interface{}
|
||||
dip.client.Ack(*request, payload)
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func (action *IncidentRCASectionAction) PerformShowRCADetailsAction(callback sla
|
||||
func (action *IncidentRCASectionAction) performPostUpdateActions(requesterType util.ViewSubmissionType, callback slack.InteractionCallback, request *socketmode.Request) {
|
||||
switch requesterType {
|
||||
case util.IncidentResolveSubmit:
|
||||
resolveAction := ResolveIncidentAction{action.client, action.incidentRepository, action.tagRepository, action.teamRepository, action.severityRepository, action.rcaService}
|
||||
resolveAction := NewIncidentResolveProcessor(action.client, action.incidentRepository, action.tagRepository, action.teamRepository, action.severityRepository, action.rcaService)
|
||||
resolveAction.IncidentResolveProcess(callback, request)
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ package action
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/viper"
|
||||
"houston/appcontext"
|
||||
"houston/common/util"
|
||||
"houston/logger"
|
||||
"houston/model/incident"
|
||||
"houston/model/severity"
|
||||
"houston/model/tag"
|
||||
"houston/model/team"
|
||||
"houston/service/conference"
|
||||
"houston/service/rca"
|
||||
"time"
|
||||
|
||||
@@ -24,6 +26,7 @@ type ResolveIncidentAction struct {
|
||||
teamRepository *team.Repository
|
||||
severityRepository *severity.Repository
|
||||
rcaService *rca.RcaService
|
||||
calendarService conference.ICalendarService
|
||||
}
|
||||
|
||||
func NewIncidentResolveProcessor(client *socketmode.Client, incidentService *incident.Repository, tagService *tag.Repository, teamRepository *team.Repository, severityRepository *severity.Repository, rcaService *rca.RcaService) *ResolveIncidentAction {
|
||||
@@ -34,6 +37,7 @@ func NewIncidentResolveProcessor(client *socketmode.Client, incidentService *inc
|
||||
teamRepository: teamRepository,
|
||||
severityRepository: severityRepository,
|
||||
rcaService: rcaService,
|
||||
calendarService: appcontext.GetCalendarService(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +103,12 @@ func (irp *ResolveIncidentAction) IncidentResolveProcess(callback slack.Interact
|
||||
}
|
||||
msgUpdate := NewIncidentChannelMessageUpdateAction(irp.client, irp.incidentService, irp.teamRepository, irp.severityRepository)
|
||||
msgUpdate.ProcessAction(incidentEntity.SlackChannel)
|
||||
//ToDo() Delete Conference event if exists and if incident is resolved
|
||||
|
||||
go func() {
|
||||
err := irp.calendarService.DeleteEvent(incidentEntity.ConferenceId)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Unable to delete conference for incident id: %d", incidentEntity.ID), zap.Error(err))
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
if incidentEntity.SeverityId != incident.Sev0Id && incidentEntity.SeverityId != incident.Sev1Id {
|
||||
postErr := util.PostArchivingTimeToIncidentChannel(channelId, incident.Resolved, irp.client)
|
||||
|
||||
10
service/conference/ICalendarService.go
Normal file
10
service/conference/ICalendarService.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package conference
|
||||
|
||||
import "houston/pkg/conference"
|
||||
|
||||
type ICalendarService interface {
|
||||
CreateEvent(eventName string) (conference.EventData, error)
|
||||
DeleteEvent(eventId string) error
|
||||
GetEvent(eventId string) (conference.EventData, error)
|
||||
GetConferenceTitle() string
|
||||
}
|
||||
@@ -14,16 +14,16 @@ import (
|
||||
"houston/logger"
|
||||
"houston/model/incident"
|
||||
"houston/model/incident_channel"
|
||||
incident_jira2 "houston/model/incident_jira"
|
||||
incidentJiraModel "houston/model/incident_jira"
|
||||
"houston/model/log"
|
||||
"houston/model/severity"
|
||||
"houston/model/team"
|
||||
"houston/model/user"
|
||||
"houston/pkg/atlassian"
|
||||
"houston/pkg/atlassian/dto/response"
|
||||
conference2 "houston/pkg/conference"
|
||||
"houston/pkg/conference"
|
||||
"houston/pkg/rest"
|
||||
service2 "houston/service/conference"
|
||||
conferenceService "houston/service/conference"
|
||||
incidentChannel "houston/service/incident_channel"
|
||||
"houston/service/incident_jira"
|
||||
"houston/service/krakatoa"
|
||||
@@ -49,6 +49,7 @@ type IncidentServiceV2 struct {
|
||||
incidentRepository incident.IIncidentRepository
|
||||
userRepository user.IUserRepository
|
||||
krakatoaService krakatoa.IKrakatoaService
|
||||
calendarService conferenceService.ICalendarService
|
||||
incidentJiraService incident_jira.IncidentJiraService
|
||||
}
|
||||
|
||||
@@ -66,6 +67,8 @@ func NewIncidentServiceV2(db *gorm.DB) *IncidentServiceV2 {
|
||||
)
|
||||
incidentChannelService := incidentChannel.NewIncidentChannelService(db)
|
||||
krakatoaService := krakatoa.NewKrakatoaService()
|
||||
calendarActions := conference.GetCalendarActions()
|
||||
calendarService := conferenceService.NewCalendarService(calendarActions)
|
||||
return &IncidentServiceV2{
|
||||
db: db,
|
||||
slackService: slackService,
|
||||
@@ -75,7 +78,8 @@ func NewIncidentServiceV2(db *gorm.DB) *IncidentServiceV2 {
|
||||
userRepository: userRepository,
|
||||
incidentChannelService: incidentChannelService,
|
||||
krakatoaService: krakatoaService,
|
||||
incidentJiraService: incident_jira.NewIncidentJiraService(incident_jira2.NewIncidentJiraRepo(db)),
|
||||
calendarService: calendarService,
|
||||
incidentJiraService: incident_jira.NewIncidentJiraService(incidentJiraModel.NewIncidentJiraRepo(db)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +310,7 @@ func (i *IncidentServiceV2) GetJiraStatuses(incidentName string, pageNumber, pag
|
||||
}
|
||||
|
||||
func getHoustonJiraStatuses(
|
||||
incidentJiraLinksDTOs *[]incident_jira2.IncidentJiraLinksDTO,
|
||||
incidentJiraLinksDTOs *[]incidentJiraModel.IncidentJiraLinksDTO,
|
||||
jiraKeyToJiraFieldsMap *map[string]response.Fields,
|
||||
incidentName string,
|
||||
) (*[]service.HoustonJiraStatus, error) {
|
||||
@@ -1455,6 +1459,9 @@ func (i *IncidentServiceV2) UpdateStatus(
|
||||
logger.Error(fmt.Sprintf("%s error in update status workflow", updateLogTag), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
if incidentEntity.Status == incident.ResolvedId || incidentEntity.Status == incident.DuplicateId {
|
||||
i.deleteConferenceEvent(incidentEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -1788,7 +1795,7 @@ func (i *IncidentServiceV2) createConferenceAndPostMessageInSlack(incidentEntity
|
||||
incidentName := incidentEntity.IncidentName
|
||||
if viper.GetBool("ENABLE_CONFERENCE") {
|
||||
if incidentEntity.SeverityId != incident.Sev3Id && incidentEntity.ConferenceId == "" {
|
||||
calendarEvent, err := createConferenceEvent(incidentName)
|
||||
calendarEvent, err := i.calendarService.CreateEvent(incidentName)
|
||||
conferenceLink := calendarEvent.ConferenceLink
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("%s [%s] Error while creating conference", logTag, incidentName), zap.Error(err))
|
||||
@@ -1812,11 +1819,15 @@ func (i *IncidentServiceV2) createConferenceAndPostMessageInSlack(incidentEntity
|
||||
}
|
||||
}
|
||||
|
||||
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) deleteConferenceEvent(incidentEntity *incident.IncidentEntity) {
|
||||
if incidentEntity.ConferenceId != "" {
|
||||
err := i.calendarService.DeleteEvent(incidentEntity.ConferenceId)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("%s Error while deleting conference for incident %s", logTag, incidentEntity.IncidentName), zap.Error(err))
|
||||
}
|
||||
} else {
|
||||
logger.Info(fmt.Sprintf("%s Conference Id is empty for incident %s", logTag, incidentEntity.IncidentName))
|
||||
}
|
||||
}
|
||||
|
||||
func (i *IncidentServiceV2) addBookMarkAndPostMessageInSlack(incidentName string, conferenceLink string, slackChannel string) {
|
||||
|
||||
Reference in New Issue
Block a user