run executes the barman-cloud-backup command and updates the status This method will take long time and is supposed to run inside a dedicated goroutine.
(ctx context.Context)
| 144 | // This method will take long time and is supposed to run inside a dedicated |
| 145 | // goroutine. |
| 146 | func (b *BackupCommand) run(ctx context.Context) { |
| 147 | ctx = log.IntoContext( |
| 148 | ctx, |
| 149 | log.FromContext(ctx). |
| 150 | WithValues( |
| 151 | "backupName", b.Backup.Name, |
| 152 | "backupNamespace", b.Backup.Namespace, |
| 153 | ), |
| 154 | ) |
| 155 | |
| 156 | if err := b.takeBackup(ctx); err != nil { |
| 157 | // record the failure |
| 158 | b.Log.Error(err, "Backup failed") |
| 159 | b.Recorder.Event(b.Backup, "Normal", "Failed", "Backup failed") |
| 160 | |
| 161 | _ = status.FlagBackupAsFailed(ctx, b.Client, b.Backup, b.Cluster, err) |
| 162 | } |
| 163 | |
| 164 | b.backupMaintenance(ctx) |
| 165 | } |
| 166 | |
| 167 | func (b *BackupCommand) takeBackup(ctx context.Context) error { |
| 168 | backupStatus := b.Backup.GetStatus() |
no test coverage detected