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

chore: flag wrap k8upv2 support #232

Merged
merged 1 commit into from
Oct 5, 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
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