From 5c2a3b275c7f17041fabbd6ca035156a396e8f6c Mon Sep 17 00:00:00 2001 From: Amit Kumar Das Date: Fri, 12 Aug 2022 15:27:28 +0530 Subject: [PATCH] Fixed issue with executed_by label in subscriber and updated upgrade agent (#3734) * Fixed executed_by issue in subscriber Signed-off-by: Amit Kumar Das * Updated upgrade agent Signed-off-by: Amit Kumar Das Signed-off-by: Amit Kumar Das --- .../cluster-agents/subscriber/pkg/events/util.go | 11 +++++++++++ .../pkg/chaos-workflow/handler/handler.go | 7 +++---- .../control-plane/versions/upgrade-manager.go | 7 ++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/litmus-portal/cluster-agents/subscriber/pkg/events/util.go b/litmus-portal/cluster-agents/subscriber/pkg/events/util.go index c76805cf653..cf5cd5b07c6 100644 --- a/litmus-portal/cluster-agents/subscriber/pkg/events/util.go +++ b/litmus-portal/cluster-agents/subscriber/pkg/events/util.go @@ -2,6 +2,7 @@ package events import ( "context" + "encoding/base64" "errors" "regexp" "strconv" @@ -156,6 +157,8 @@ func GenerateWorkflowPayload(cid, accessKey, version, completed string, wfEvent wfEvent.Nodes[id] = event } + wfEvent.ExecutedBy = URLDecodeBase64(wfEvent.ExecutedBy) + processed, err := graphql.MarshalGQLData(wfEvent) if err != nil { return nil, err @@ -164,3 +167,11 @@ func GenerateWorkflowPayload(cid, accessKey, version, completed string, wfEvent var payload = []byte(`{"query":"mutation { chaosWorkflowRun(request:` + mutation + ` )}"}`) return payload, nil } + +func URLDecodeBase64(encoded string) string { + decoded, err := base64.RawURLEncoding.DecodeString(encoded) + if err != nil { + return encoded + } + return string(decoded) +} diff --git a/litmus-portal/graphql-server/pkg/chaos-workflow/handler/handler.go b/litmus-portal/graphql-server/pkg/chaos-workflow/handler/handler.go index 8a344b5e253..19c5072f7c9 100644 --- a/litmus-portal/graphql-server/pkg/chaos-workflow/handler/handler.go +++ b/litmus-portal/graphql-server/pkg/chaos-workflow/handler/handler.go @@ -34,7 +34,6 @@ import ( dbOperationsWorkflowTemplate "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/database/mongodb/workflowtemplate" dbSchemaWorkflowTemplate "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/database/mongodb/workflowtemplate" gitOpsHandler "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/gitops/handler" - "github.com/litmuschaos/litmus/litmus-portal/graphql-server/utils" ) func CreateChaosWorkflow(ctx context.Context, request *model.ChaosWorkFlowRequest, r *store.StateData) (*model.ChaosWorkFlowResponse, error) { @@ -483,7 +482,7 @@ func ListWorkflowRuns(request model.ListWorkflowRunsRequest) (*model.ListWorkflo ClusterName: workflow.ClusterName, ClusterType: &workflow.ClusterType, IsRemoved: workflowRun.IsRemoved, - ExecutedBy: utils.URLDecodeBase64(workflowRun.ExecutedBy), + ExecutedBy: workflowRun.ExecutedBy, } result = append(result, &newWorkflowRun) } @@ -739,7 +738,7 @@ func ChaosWorkflowRun(request model.WorkflowRunRequest, r store.StateData) (stri ExecutionData: request.ExecutionData, Completed: request.Completed, IsRemoved: &isRemoved, - ExecutedBy: utils.URLDecodeBase64(request.ExecutedBy), + ExecutedBy: request.ExecutedBy, }) if err != nil { @@ -769,7 +768,7 @@ func ChaosWorkflowRun(request model.WorkflowRunRequest, r store.StateData) (stri ExecutionData: request.ExecutionData, WorkflowID: request.WorkflowID, IsRemoved: &isRemoved, - ExecutedBy: utils.URLDecodeBase64(request.ExecutedBy), + ExecutedBy: request.ExecutedBy, }, &r) return "Workflow Run Accepted", nil diff --git a/litmus-portal/upgrade-agents/control-plane/versions/upgrade-manager.go b/litmus-portal/upgrade-agents/control-plane/versions/upgrade-manager.go index 145d96a769d..206c3988fc5 100644 --- a/litmus-portal/upgrade-agents/control-plane/versions/upgrade-manager.go +++ b/litmus-portal/upgrade-agents/control-plane/versions/upgrade-manager.go @@ -98,8 +98,13 @@ func (m *UpgradeManager) getUpgradePath() map[string]UpgradeExecutor { VersionManager: nil, }, - // latest version, no more upgrades available "2.11.0": { + NextVersion: "2.12.0", + VersionManager: nil, + }, + + // latest version, no more upgrades available + "2.12.0": { NextVersion: "", VersionManager: nil, },