Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add more support for newer active-standby switch task #235

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading