Conversation
main.go
Outdated
| defer logs.FlushLogs() | ||
|
|
||
| if err := cmds.NewCmdStash(Version).Execute(); err != nil { | ||
| log.Infoln("Error in Stash Main:", err) |
There was a problem hiding this comment.
Use log.Fatalln() instead of 2 commands
pkg/check/check.go
Outdated
| type Controller struct { | ||
| k8sClient kubernetes.Interface | ||
| stashClient cs.StashV1alpha1Interface | ||
| namespace string |
There was a problem hiding this comment.
Create an Options struct for the string variables
| return | ||
| } | ||
|
|
||
| defer func() { |
pkg/cmds/backup.go
Outdated
| ctrl.ElectLeader(stopBackup) | ||
| default: | ||
| ctrl.SetupAndRun(stopBackup) | ||
| if opt.RunOffline { |
| func (c *StashController) initJobWatcher() { | ||
| lw := &cache.ListWatch{ // TODO @ Dipta: only watch stash jobs | ||
| ListFunc: func(options metav1.ListOptions) (rt.Object, error) { | ||
| return c.k8sClient.BatchV1().Jobs(core.NamespaceAll).List(options) |
There was a problem hiding this comment.
pkg/controller/jobs.go
Outdated
| job := obj.(*batch.Job) | ||
| fmt.Printf("Sync/Add/Update for Job %s\n", job.GetName()) | ||
|
|
||
| if job.Labels["app"] == util.AppLabelStash && job.Status.Succeeded > 0 { |
| d := obj.(*api.Restic) | ||
| fmt.Printf("Sync/Add/Update for Restic %s\n", d.GetName()) | ||
|
|
||
| if d.Spec.Type == api.BackupOffline { |
There was a problem hiding this comment.
I think this should be done at the start of operator and we should check that the image exists and exit if the image is missing. To check image existence use,
https://github.com/k8sdb/apimachinery/blob/3f92c150ed3bedd0d2d19bcc3856360937d06033/pkg/docker/checks.go#L13
pkg/util/kubernetes.go
Outdated
| if c.Name == StashContainer { | ||
| found = true | ||
| break | ||
| if offline { |
There was a problem hiding this comment.
Instead of offline bool, I think we should pass the backupType
| return container | ||
| } | ||
|
|
||
| func CreateSidecarContainer(r *api.Restic, tag string, workload api.LocalTypedReference) core.Container { |
There was a problem hiding this comment.
Where is serviceAccountName created
There was a problem hiding this comment.
InitContainer and Sidecar use the same service account as the workload?
|
|
||
| err = c.resticCLI.Check() | ||
| if err != nil { | ||
| c.recorder.Eventf(resource.ObjectReference(), core.EventTypeWarning, eventer.EventReasonFailedToCheck, "Repository check failed for workload %s %s/%s. Reason: %v", c.opt.Workload.Kind, c.opt.Namespace, c.opt.Workload.Name, err) |
There was a problem hiding this comment.
When the line is this long, move each parameter to a separate line. Makes it more readable.
Fixes #225 #216
Changes:
scheduletobackupand addofflineflagcheckcommandapp=stash, set annotationrestic-name,stash-operationapp=stash, delete completed jobs/pods for backup/check/recoveryIssues:
kutil