Skip to content

Commit

Permalink
Merge pull request #235 from uselagoon/active-stanby-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon authored Nov 13, 2023
2 parents 68f8f17 + 2a3bee5 commit 22597d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
21 changes: 21 additions & 0 deletions internal/messenger/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,13 @@ func (m *Messenger) Consumer(targetName string) { //error {
)
err := m.IngressRouteMigration(namespace, jobSpec)
if err != nil {
opLog.Error(err,
fmt.Sprintf(
"Route migration / activestandby switch for project %s, environment %s failed to be created",
jobSpec.Project.Name,
jobSpec.Environment.Name,
),
)
//@TODO: send msg back to lagoon and update task to failed?
message.Ack(false) // ack to remove from queue
return
Expand All @@ -378,6 +385,13 @@ func (m *Messenger) Consumer(targetName string) { //error {
)
err := m.AdvancedTask(namespace, jobSpec)
if err != nil {
opLog.Error(err,
fmt.Sprintf(
"Advanced task for project %s, environment %s failed to be created",
jobSpec.Project.Name,
jobSpec.Environment.Name,
),
)
//@TODO: send msg back to lagoon and update task to failed?
message.Ack(false) // ack to remove from queue
return
Expand All @@ -391,6 +405,13 @@ func (m *Messenger) Consumer(targetName string) { //error {
)
err := m.ActiveStandbySwitch(namespace, jobSpec)
if err != nil {
opLog.Error(err,
fmt.Sprintf(
"Active/Standby switch for project %s, environment %s failed to be created",
jobSpec.Project.Name,
jobSpec.Environment.Name,
),
)
//@TODO: send msg back to lagoon and update task to failed?
message.Ack(false) // ack to remove from queue
return
Expand Down
7 changes: 6 additions & 1 deletion internal/messenger/tasks_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package messenger

import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"sort"
Expand Down Expand Up @@ -251,7 +252,11 @@ func (m *Messenger) ActiveStandbySwitch(namespace string, jobSpec *lagoonv1beta1
jobSpec.AdvancedTask.DeployerToken = true
jobSpec.AdvancedTask.SSHKey = true
asPayload := &ActiveStandbyPayload{}
err := json.Unmarshal([]byte(jobSpec.AdvancedTask.JSONPayload), asPayload)
asPayloadDecoded, err := base64.StdEncoding.DecodeString(jobSpec.AdvancedTask.JSONPayload)
if err != nil {
return fmt.Errorf("Unable to base64 decode payload: %v", err)
}
err = json.Unmarshal([]byte(asPayloadDecoded), asPayload)
if err != nil {
return fmt.Errorf("Unable to unmarshal json payload: %v", err)
}
Expand Down

0 comments on commit 22597d2

Please sign in to comment.