Skip to content

Commit

Permalink
Merge pull request #232 from uselagoon/k8upv2-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Oct 5, 2023
2 parents 4edd130 + f22b9fd commit 0ce8052
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ spec:
- "--enable-qos"
- "--qos-max-builds=3"
- "--enable-deprecated-apis"
- "--lagoon-feature-flag-support-k8upv2"
3 changes: 3 additions & 0 deletions internal/messenger/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Messenger struct {
AdvancedTaskDeployTokenInjection bool
DeletionHandler *deletions.Deletions
EnableDebug bool
SupportK8upV2 bool
Cache *expirable.LRU[string, string]
}

Expand All @@ -51,6 +52,7 @@ func New(config mq.Config,
advancedTaskDeployTokenInjection bool,
deletionHandler *deletions.Deletions,
enableDebug bool,
supportK8upV2 bool,
cache *expirable.LRU[string, string],
) *Messenger {
return &Messenger{
Expand All @@ -65,6 +67,7 @@ func New(config mq.Config,
AdvancedTaskDeployTokenInjection: advancedTaskDeployTokenInjection,
DeletionHandler: deletionHandler,
EnableDebug: enableDebug,
SupportK8upV2: supportK8upV2,
Cache: cache,
}
}
28 changes: 18 additions & 10 deletions internal/messenger/tasks_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,28 @@ func (m *Messenger) ResticRestore(namespace string, jobSpec *lagoonv1beta1.Lagoo
k8upv1Exists = true
}
// check the version, if there is no version in the payload, assume it is k8up v2
if vers == "backup.appuio.ch/v1alpha1" {
if k8upv1alpha1Exists {
return m.createv1alpha1Restore(opLog, namespace, jobSpec)
}
} else {
if k8upv1Exists {
if err := m.createv1Restore(opLog, namespace, jobSpec); err != nil {
return err
if m.SupportK8upV2 {
if vers == "backup.appuio.ch/v1alpha1" {
if k8upv1alpha1Exists {
return m.createv1alpha1Restore(opLog, namespace, jobSpec)
}
} else {
if k8upv1alpha1Exists {
if err := m.createv1alpha1Restore(opLog, namespace, jobSpec); err != nil {
if k8upv1Exists {
if err := m.createv1Restore(opLog, namespace, jobSpec); err != nil {
return err
}
} else {
if k8upv1alpha1Exists {
if err := m.createv1alpha1Restore(opLog, namespace, jobSpec); err != nil {
return err
}
}
}
}
} else {
if k8upv1alpha1Exists {
if err := m.createv1alpha1Restore(opLog, namespace, jobSpec); err != nil {
return err
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func main() {
var taskPodsToKeep int
var lffBackupWeeklyRandom bool
var lffHarborEnabled bool
var lffSupportK8UPv2 bool
var harborURL string
var harborAPI string
var harborUsername string
Expand Down Expand Up @@ -281,6 +282,8 @@ func main() {
flag.IntVar(&taskPodsToKeep, "num-task-pods-to-keep", 1, "The number of task pods to keep per namespace.")
flag.BoolVar(&lffBackupWeeklyRandom, "lagoon-feature-flag-backup-weekly-random", false,
"Tells Lagoon whether or not to use the \"weekly-random\" schedule for k8up backups.")
flag.BoolVar(&lffSupportK8UPv2, "lagoon-feature-flag-support-k8upv2", false,
"Tells Lagoon whether or not it can support k8up v2.")

flag.BoolVar(&tlsSkipVerify, "skip-tls-verify", false, "Flag to skip tls verification for http clients (harbor).")

Expand Down Expand Up @@ -644,6 +647,7 @@ func main() {
advancedTaskDeployToken,
deletion,
enableDebug,
lffSupportK8UPv2,
cache,
)

Expand Down

0 comments on commit 0ce8052

Please sign in to comment.