diff --git a/chaoscenter/graphql/definitions/shared/chaos_experiment.graphqls b/chaoscenter/graphql/definitions/shared/chaos_experiment.graphqls index 74ac071363b..b6003ab121b 100644 --- a/chaoscenter/graphql/definitions/shared/chaos_experiment.graphqls +++ b/chaoscenter/graphql/definitions/shared/chaos_experiment.graphqls @@ -326,27 +326,6 @@ type Weightages { weightage: Int! } - -input ExperimentRunPhaseRequest { - projectID: ID! - - """ - ID of the infra infra in which the experiment is running - """ - infraID: InfraIdentity! - - """ - ID of the experiment run which is to be queried - """ - experimentRunID: String! - - """ - notifyID is required to give an ack for non cron experiment execution - """ - notifyID: String -} - - """ Defines the details of a experiment run """ diff --git a/chaoscenter/graphql/definitions/shared/chaos_experiment_run.graphqls b/chaoscenter/graphql/definitions/shared/chaos_experiment_run.graphqls index 8e9c3ecb9d9..fb095210317 100644 --- a/chaoscenter/graphql/definitions/shared/chaos_experiment_run.graphqls +++ b/chaoscenter/graphql/definitions/shared/chaos_experiment_run.graphqls @@ -2,7 +2,7 @@ extend type Query { """ Returns experiment run based on experiment run ID """ - getExperimentRun(projectID: ID!, experimentRunID: ID, notifyID: ID): ExperimentRun! + getExperimentRun(projectID: ID!, experimentRunID: ID, notifyID: ID, infraID: InfraIdentity): ExperimentRun! """ Returns the list of experiment run based on various filter parameters @@ -16,7 +16,6 @@ extend type Query { Query to get experiment run stats """ getExperimentRunStats(projectID: ID!): GetExperimentRunStatsResponse! - getExperimentRunPhase(request: ExperimentRunPhaseRequest!): ExperimentRun! } extend type Mutation { diff --git a/chaoscenter/graphql/server/graph/chaos_experiment_run.resolvers.go b/chaoscenter/graphql/server/graph/chaos_experiment_run.resolvers.go index 551e6128ff0..e54a59f08e7 100644 --- a/chaoscenter/graphql/server/graph/chaos_experiment_run.resolvers.go +++ b/chaoscenter/graphql/server/graph/chaos_experiment_run.resolvers.go @@ -82,17 +82,33 @@ func (r *mutationResolver) StopExperimentRuns(ctx context.Context, projectID str } // GetExperimentRun is the resolver for the getExperimentRun field. -func (r *queryResolver) GetExperimentRun(ctx context.Context, projectID string, experimentRunID *string, notifyID *string) (*model.ExperimentRun, error) { +func (r *queryResolver) GetExperimentRun(ctx context.Context, projectID string, experimentRunID *string, notifyID *string, infraID *model.InfraIdentity) (*model.ExperimentRun, error) { logFields := logrus.Fields{ "projectId": projectID, "chaosExperimentRunId": experimentRunID, + "infraID": infraID, } + logrus.WithFields(logFields).Info("request received to fetch chaos experiment run") - err := authorization.ValidateRole(ctx, projectID, - authorization.MutationRbacRules[authorization.GetWorkflowRun], - model.InvitationAccepted.String()) - if err != nil { - return nil, err + + // Infrastructure validation + if infraID != nil { + _, err := r.chaosInfrastructureService.VerifyInfra(*infraID) + + if err != nil { + logrus.WithFields(logFields).Error(err) + return nil, err + } + + // Authorization validation + } else { + err := authorization.ValidateRole(ctx, projectID, + authorization.MutationRbacRules[authorization.GetWorkflowRun], + model.InvitationAccepted.String()) + + if err != nil { + return nil, err + } } expRunResponse, err := r.chaosExperimentRunHandler.GetExperimentRun(ctx, projectID, experimentRunID, notifyID) @@ -146,20 +162,3 @@ func (r *queryResolver) GetExperimentRunStats(ctx context.Context, projectID str } return uiResponse, err } - -// GetExperimentRunPhase is the resolver for the getExperimentRunPhase field. -func (r *queryResolver) GetExperimentRunPhase(ctx context.Context, request model.ExperimentRunPhaseRequest) (*model.ExperimentRun, error) { - _, err := r.chaosInfrastructureService.VerifyInfra(*request.InfraID) - - if err != nil { - logrus.Error("Validation failed : ", request.InfraID) - return nil, err - } - - expRunResponse, err := r.chaosExperimentRunHandler.GetExperimentRun(ctx, request.ProjectID, &request.ExperimentRunID, request.NotifyID) - if err != nil { - logrus.Error("failed to get chaosExpeirmentRun: ", err) - return nil, err - } - return expRunResponse, err -} diff --git a/chaoscenter/graphql/server/graph/generated/generated.go b/chaoscenter/graphql/server/graph/generated/generated.go index f5085a222e2..e6adeece438 100644 --- a/chaoscenter/graphql/server/graph/generated/generated.go +++ b/chaoscenter/graphql/server/graph/generated/generated.go @@ -607,8 +607,7 @@ type ComplexityRoot struct { GetChaosHubStats func(childComplexity int, projectID string) int GetEnvironment func(childComplexity int, projectID string, environmentID string) int GetExperiment func(childComplexity int, projectID string, experimentID string) int - GetExperimentRun func(childComplexity int, projectID string, experimentRunID *string, notifyID *string) int - GetExperimentRunPhase func(childComplexity int, request model.ExperimentRunPhaseRequest) int + GetExperimentRun func(childComplexity int, projectID string, experimentRunID *string, notifyID *string, infraID *model.InfraIdentity) int GetExperimentRunStats func(childComplexity int, projectID string) int GetExperimentStats func(childComplexity int, projectID string) int GetGitOpsDetails func(childComplexity int, projectID string) int @@ -767,10 +766,9 @@ type QueryResolver interface { GetExperiment(ctx context.Context, projectID string, experimentID string) (*model.GetExperimentResponse, error) ListExperiment(ctx context.Context, projectID string, request model.ListExperimentRequest) (*model.ListExperimentResponse, error) GetExperimentStats(ctx context.Context, projectID string) (*model.GetExperimentStatsResponse, error) - GetExperimentRun(ctx context.Context, projectID string, experimentRunID *string, notifyID *string) (*model.ExperimentRun, error) + GetExperimentRun(ctx context.Context, projectID string, experimentRunID *string, notifyID *string, infraID *model.InfraIdentity) (*model.ExperimentRun, error) ListExperimentRun(ctx context.Context, projectID string, request model.ListExperimentRunRequest) (*model.ListExperimentRunResponse, error) GetExperimentRunStats(ctx context.Context, projectID string) (*model.GetExperimentRunStatsResponse, error) - GetExperimentRunPhase(ctx context.Context, request model.ExperimentRunPhaseRequest) (*model.ExperimentRun, error) GetInfra(ctx context.Context, projectID string, infraID string) (*model.Infra, error) ListInfras(ctx context.Context, projectID string, request *model.ListInfraRequest) (*model.ListInfraResponse, error) GetInfraDetails(ctx context.Context, infraID string, projectID string) (*model.Infra, error) @@ -3731,19 +3729,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.GetExperimentRun(childComplexity, args["projectID"].(string), args["experimentRunID"].(*string), args["notifyID"].(*string)), true - - case "Query.getExperimentRunPhase": - if e.complexity.Query.GetExperimentRunPhase == nil { - break - } - - args, err := ec.field_Query_getExperimentRunPhase_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.GetExperimentRunPhase(childComplexity, args["request"].(model.ExperimentRunPhaseRequest)), true + return e.complexity.Query.GetExperimentRun(childComplexity, args["projectID"].(string), args["experimentRunID"].(*string), args["notifyID"].(*string), args["infraID"].(*model.InfraIdentity)), true case "Query.getExperimentRunStats": if e.complexity.Query.GetExperimentRunStats == nil { @@ -4437,7 +4423,6 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputExperimentFilterInput, ec.unmarshalInputExperimentRequest, ec.unmarshalInputExperimentRunFilterInput, - ec.unmarshalInputExperimentRunPhaseRequest, ec.unmarshalInputExperimentRunRequest, ec.unmarshalInputExperimentRunSortInput, ec.unmarshalInputExperimentSortInput, @@ -4919,27 +4904,6 @@ type Weightages { weightage: Int! } - -input ExperimentRunPhaseRequest { - projectID: ID! - - """ - ID of the infra infra in which the experiment is running - """ - infraID: InfraIdentity! - - """ - ID of the experiment run which is to be queried - """ - experimentRunID: String! - - """ - notifyID is required to give an ack for non cron experiment execution - """ - notifyID: String -} - - """ Defines the details of a experiment run """ @@ -5398,7 +5362,7 @@ type Mutation { """ Returns experiment run based on experiment run ID """ - getExperimentRun(projectID: ID!, experimentRunID: ID, notifyID: ID): ExperimentRun! + getExperimentRun(projectID: ID!, experimentRunID: ID, notifyID: ID, infraID: InfraIdentity): ExperimentRun! """ Returns the list of experiment run based on various filter parameters @@ -5412,7 +5376,6 @@ type Mutation { Query to get experiment run stats """ getExperimentRunStats(projectID: ID!): GetExperimentRunStatsResponse! - getExperimentRunPhase(request: ExperimentRunPhaseRequest!): ExperimentRun! } extend type Mutation { @@ -9313,21 +9276,6 @@ func (ec *executionContext) field_Query_getEnvironment_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Query_getExperimentRunPhase_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 model.ExperimentRunPhaseRequest - if tmp, ok := rawArgs["request"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("request")) - arg0, err = ec.unmarshalNExperimentRunPhaseRequest2githubᚗcomᚋlitmuschaosᚋlitmusᚋchaoscenterᚋgraphqlᚋserverᚋgraphᚋmodelᚐExperimentRunPhaseRequest(ctx, tmp) - if err != nil { - return nil, err - } - } - args["request"] = arg0 - return args, nil -} - func (ec *executionContext) field_Query_getExperimentRunStats_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -9373,6 +9321,15 @@ func (ec *executionContext) field_Query_getExperimentRun_args(ctx context.Contex } } args["notifyID"] = arg2 + var arg3 *model.InfraIdentity + if tmp, ok := rawArgs["infraID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("infraID")) + arg3, err = ec.unmarshalOInfraIdentity2ᚖgithubᚗcomᚋlitmuschaosᚋlitmusᚋchaoscenterᚋgraphqlᚋserverᚋgraphᚋmodelᚐInfraIdentity(ctx, tmp) + if err != nil { + return nil, err + } + } + args["infraID"] = arg3 return args, nil } @@ -28678,7 +28635,7 @@ func (ec *executionContext) _Query_getExperimentRun(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetExperimentRun(rctx, fc.Args["projectID"].(string), fc.Args["experimentRunID"].(*string), fc.Args["notifyID"].(*string)) + return ec.resolvers.Query().GetExperimentRun(rctx, fc.Args["projectID"].(string), fc.Args["experimentRunID"].(*string), fc.Args["notifyID"].(*string), fc.Args["infraID"].(*model.InfraIdentity)) }) if err != nil { ec.Error(ctx, err) @@ -28899,111 +28856,6 @@ func (ec *executionContext) fieldContext_Query_getExperimentRunStats(ctx context return fc, nil } -func (ec *executionContext) _Query_getExperimentRunPhase(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getExperimentRunPhase(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetExperimentRunPhase(rctx, fc.Args["request"].(model.ExperimentRunPhaseRequest)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*model.ExperimentRun) - fc.Result = res - return ec.marshalNExperimentRun2ᚖgithubᚗcomᚋlitmuschaosᚋlitmusᚋchaoscenterᚋgraphqlᚋserverᚋgraphᚋmodelᚐExperimentRun(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_getExperimentRunPhase(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "projectID": - return ec.fieldContext_ExperimentRun_projectID(ctx, field) - case "experimentRunID": - return ec.fieldContext_ExperimentRun_experimentRunID(ctx, field) - case "experimentType": - return ec.fieldContext_ExperimentRun_experimentType(ctx, field) - case "experimentID": - return ec.fieldContext_ExperimentRun_experimentID(ctx, field) - case "weightages": - return ec.fieldContext_ExperimentRun_weightages(ctx, field) - case "updatedAt": - return ec.fieldContext_ExperimentRun_updatedAt(ctx, field) - case "createdAt": - return ec.fieldContext_ExperimentRun_createdAt(ctx, field) - case "infra": - return ec.fieldContext_ExperimentRun_infra(ctx, field) - case "experimentName": - return ec.fieldContext_ExperimentRun_experimentName(ctx, field) - case "experimentManifest": - return ec.fieldContext_ExperimentRun_experimentManifest(ctx, field) - case "phase": - return ec.fieldContext_ExperimentRun_phase(ctx, field) - case "resiliencyScore": - return ec.fieldContext_ExperimentRun_resiliencyScore(ctx, field) - case "faultsPassed": - return ec.fieldContext_ExperimentRun_faultsPassed(ctx, field) - case "faultsFailed": - return ec.fieldContext_ExperimentRun_faultsFailed(ctx, field) - case "faultsAwaited": - return ec.fieldContext_ExperimentRun_faultsAwaited(ctx, field) - case "faultsStopped": - return ec.fieldContext_ExperimentRun_faultsStopped(ctx, field) - case "faultsNa": - return ec.fieldContext_ExperimentRun_faultsNa(ctx, field) - case "totalFaults": - return ec.fieldContext_ExperimentRun_totalFaults(ctx, field) - case "executionData": - return ec.fieldContext_ExperimentRun_executionData(ctx, field) - case "isRemoved": - return ec.fieldContext_ExperimentRun_isRemoved(ctx, field) - case "updatedBy": - return ec.fieldContext_ExperimentRun_updatedBy(ctx, field) - case "createdBy": - return ec.fieldContext_ExperimentRun_createdBy(ctx, field) - case "notifyID": - return ec.fieldContext_ExperimentRun_notifyID(ctx, field) - case "runSequence": - return ec.fieldContext_ExperimentRun_runSequence(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ExperimentRun", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getExperimentRunPhase_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - func (ec *executionContext) _Query_getInfra(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_getInfra(ctx, field) if err != nil { @@ -36524,54 +36376,6 @@ func (ec *executionContext) unmarshalInputExperimentRunFilterInput(ctx context.C return it, nil } -func (ec *executionContext) unmarshalInputExperimentRunPhaseRequest(ctx context.Context, obj interface{}) (model.ExperimentRunPhaseRequest, error) { - var it model.ExperimentRunPhaseRequest - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"projectID", "infraID", "experimentRunID", "notifyID"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "projectID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("projectID")) - data, err := ec.unmarshalNID2string(ctx, v) - if err != nil { - return it, err - } - it.ProjectID = data - case "infraID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("infraID")) - data, err := ec.unmarshalNInfraIdentity2ᚖgithubᚗcomᚋlitmuschaosᚋlitmusᚋchaoscenterᚋgraphqlᚋserverᚋgraphᚋmodelᚐInfraIdentity(ctx, v) - if err != nil { - return it, err - } - it.InfraID = data - case "experimentRunID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("experimentRunID")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.ExperimentRunID = data - case "notifyID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("notifyID")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NotifyID = data - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputExperimentRunRequest(ctx context.Context, obj interface{}) (model.ExperimentRunRequest, error) { var it model.ExperimentRunRequest asMap := map[string]interface{}{} @@ -42793,28 +42597,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "getExperimentRunPhase": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_getExperimentRunPhase(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "getInfra": field := field @@ -44766,11 +44548,6 @@ func (ec *executionContext) marshalNExperimentRun2ᚖgithubᚗcomᚋlitmuschaos return ec._ExperimentRun(ctx, sel, v) } -func (ec *executionContext) unmarshalNExperimentRunPhaseRequest2githubᚗcomᚋlitmuschaosᚋlitmusᚋchaoscenterᚋgraphqlᚋserverᚋgraphᚋmodelᚐExperimentRunPhaseRequest(ctx context.Context, v interface{}) (model.ExperimentRunPhaseRequest, error) { - res, err := ec.unmarshalInputExperimentRunPhaseRequest(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) unmarshalNExperimentRunRequest2githubᚗcomᚋlitmuschaosᚋlitmusᚋchaoscenterᚋgraphqlᚋserverᚋgraphᚋmodelᚐExperimentRunRequest(ctx context.Context, v interface{}) (model.ExperimentRunRequest, error) { res, err := ec.unmarshalInputExperimentRunRequest(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -46744,6 +46521,14 @@ func (ec *executionContext) unmarshalOInfraFilterInput2ᚖgithubᚗcomᚋlitmusc return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOInfraIdentity2ᚖgithubᚗcomᚋlitmuschaosᚋlitmusᚋchaoscenterᚋgraphqlᚋserverᚋgraphᚋmodelᚐInfraIdentity(ctx context.Context, v interface{}) (*model.InfraIdentity, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputInfraIdentity(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOInfrastructureType2ᚕᚖgithubᚗcomᚋlitmuschaosᚋlitmusᚋchaoscenterᚋgraphqlᚋserverᚋgraphᚋmodelᚐInfrastructureType(ctx context.Context, v interface{}) ([]*model.InfrastructureType, error) { if v == nil { return nil, nil diff --git a/chaoscenter/graphql/server/graph/model/models_gen.go b/chaoscenter/graphql/server/graph/model/models_gen.go index 217dc72e667..470b2690b1f 100644 --- a/chaoscenter/graphql/server/graph/model/models_gen.go +++ b/chaoscenter/graphql/server/graph/model/models_gen.go @@ -646,16 +646,6 @@ type ExperimentRunFilterInput struct { InfraTypes []*InfrastructureType `json:"infraTypes,omitempty"` } -type ExperimentRunPhaseRequest struct { - ProjectID string `json:"projectID"` - // ID of the infra infra in which the experiment is running - InfraID *InfraIdentity `json:"infraID"` - // ID of the experiment run which is to be queried - ExperimentRunID string `json:"experimentRunID"` - // notifyID is required to give an ack for non cron experiment execution - NotifyID *string `json:"notifyID,omitempty"` -} - // Defines the details for a experiment run type ExperimentRunRequest struct { // ID of the experiment diff --git a/chaoscenter/subscriber/pkg/graphql/operations.go b/chaoscenter/subscriber/pkg/graphql/operations.go index 50da9b90e3a..f6fa8e89a71 100644 --- a/chaoscenter/subscriber/pkg/graphql/operations.go +++ b/chaoscenter/subscriber/pkg/graphql/operations.go @@ -72,10 +72,9 @@ func (gql *subscriberGql) SendExperimentRunRuquest(infraData map[string]string, } func (gql *subscriberGql) GenerateExperimentRunPayload(cid, accessKey, version string, podLog types.PodLogRequest) ([]byte, error) { - infraID := `{infraID: \"` + cid + `\", version: \"` + version + `\", accessKey: \"` + accessKey + `\"}` - query := `{ infraID: ` + infraID + `, experimentRunID:\"` + podLog.ExperimentRunID + `\", projectID: \"` + podLog.ProjectID + `\", notifyID: \"\"}` - - var payload = []byte(`{"query":"query { getExperimentRunPhase(request:` + query + `){phase}}"}`) + infraID := `infraID: {infraID: \"` + cid + `\", version: \"` + version + `\", accessKey: \"` + accessKey + `\"}` + query := infraID + `, experimentRunID: \"` + podLog.ExperimentRunID + `\", projectID: \"` + podLog.ProjectID + `\", notifyID: \"\"` + var payload = []byte(`{"query": "query { getExperimentRun(` + query + `) { phase } }"}`) return payload, nil } diff --git a/chaoscenter/subscriber/pkg/k8s/log.go b/chaoscenter/subscriber/pkg/k8s/log.go index 015574f07af..4a8aa3dd1d2 100644 --- a/chaoscenter/subscriber/pkg/k8s/log.go +++ b/chaoscenter/subscriber/pkg/k8s/log.go @@ -117,7 +117,7 @@ func (k8s *k8sSubscriber) GetPodLogs(infraData map[string]string, podLog types.P // fetch ExperimentRun Phase from graphql experimentRun, _ := k8s.gqlSubscriberServer.SendExperimentRunRuquest(infraData, podLog) - logDetails.MainPod = k8s.categorizeLogByPhase(experimentRun.Data.ExperimentRun.Phase) + logDetails.MainPod = k8s.categorizeLogByPhase(experimentRun.Data.ExperimentRun.Phase) + " Pod name: " + podLog.PodName logrus.WithError(err).Print("Failed to get pod logs for attempting to fetch experiment run phase") @@ -140,25 +140,25 @@ func (k8s *k8sSubscriber) GetPodLogs(infraData map[string]string, podLog types.P func (k8s *k8sSubscriber) categorizeLogByPhase(phase string) string { switch phase { case "Completed": - return "Experiment pod is deleted" + return "Experiment pod was deleted." case "Stopped": - return "Stopped" + return "Experiment is stopped." case "Running": - return "Workflow Pod is initializing" + return "Experiment pod is initializing." case "Queue": - return "Queue" + return "Queue." case "NA": - return "NA" + return "NA." case "Terminated": - return "Terminated" + return "Terminated." case "Completed_With_Error": - return "Completed_With_Error" + return "Completed_With_Error." case "Timeout": - return "Timeout" + return "Timeout." case "Error": - return "it can't run experiment" + return "Experiment could not start." default: - return "Workflow Pod is initializing" + return "Experiment pod is initializing." } } diff --git a/chaoscenter/subscriber/pkg/types/graphql.go b/chaoscenter/subscriber/pkg/types/graphql.go index f5dd8fe85c7..1e1c29a7916 100644 --- a/chaoscenter/subscriber/pkg/types/graphql.go +++ b/chaoscenter/subscriber/pkg/types/graphql.go @@ -5,7 +5,7 @@ type ExperimentRunResponse struct { } type ExperimentRun struct { - ExperimentRun Phase `json:"getExperimentRunPhase"` + ExperimentRun Phase `json:"getExperimentRun"` } type Phase struct {