contoller/restore-operator: report restore status
@@ -73,7 +73,22 @@ func (r *Restore) processItem(key string) error {
clusterName := er.Spec.BackupSpec.ClusterName
r.clusterNames.Store(key, clusterName)
r.restoreCRs.Store(clusterName, er)
- return createSeedPod(r.kubecli, er.Spec.ClusterSpec, er.AsOwner(), r.namespace, er.Spec.ClusterSpec.Version, r.mySvcAddr, clusterName)
+ err = createSeedPod(r.kubecli, er.Spec.ClusterSpec, er.AsOwner(), r.namespace, er.Spec.ClusterSpec.Version, r.mySvcAddr, clusterName)
+ r.reportStatus(err, er)
+ return err
+}
+
+func (r *Restore) reportStatus(err error, er *api.EtcdRestore) {
+ if err != nil {
+ er.Status.Succeeded = false
+ er.Status.Reason = err.Error()
+ } else {
+ er.Status.Succeeded = true
+ }
+ _, err = r.restoreCRCli.EtcdV1beta2().EtcdRestores(r.namespace).Update(er)
+ if err != nil {
+ r.logger.Warningf("failed to update status of restore CR %v : (%v)", er.Name, err)
+ }
}
func createSeedPod(kubecli kubernetes.Interface, cs api.ClusterSpec, owner metav1.OwnerReference, namespace, etcdVersion, svcAddr, clusterName string) error {
