(getRuntimeFn func(client.Client) (base.RuntimeInterface, error), fuseDsNamespacedName types.NamespacedName)
| 36 | ) |
| 37 | |
| 38 | func (e *Helper) CheckAndSyncFuseStatus(getRuntimeFn func(client.Client) (base.RuntimeInterface, error), fuseDsNamespacedName types.NamespacedName) (ready bool, err error) { |
| 39 | fuseDs, err := kubeclient.GetDaemonset(e.client, fuseDsNamespacedName.Name, fuseDsNamespacedName.Namespace) |
| 40 | if err != nil { |
| 41 | return |
| 42 | } |
| 43 | |
| 44 | err = retry.RetryOnConflict(retry.DefaultBackoff, func() error { |
| 45 | runtime, err := getRuntimeFn(e.client) |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | |
| 50 | oldStatus := runtime.GetStatus().DeepCopy() |
| 51 | statusToUpdate := runtime.GetStatus() |
| 52 | |
| 53 | statusToUpdate.DesiredFuseNumberScheduled = fuseDs.Status.DesiredNumberScheduled |
| 54 | statusToUpdate.CurrentFuseNumberScheduled = fuseDs.Status.CurrentNumberScheduled |
| 55 | statusToUpdate.FuseNumberReady = fuseDs.Status.NumberReady |
| 56 | statusToUpdate.FuseNumberAvailable = fuseDs.Status.NumberAvailable |
| 57 | statusToUpdate.FuseNumberUnavailable = fuseDs.Status.NumberUnavailable |
| 58 | |
| 59 | // fluid assumes fuse components are always ready |
| 60 | statusToUpdate.FusePhase = datav1alpha1.RuntimePhaseReady |
| 61 | ready = true |
| 62 | |
| 63 | if len(statusToUpdate.Conditions) == 0 { |
| 64 | statusToUpdate.Conditions = []datav1alpha1.RuntimeCondition{} |
| 65 | } |
| 66 | cond := utils.NewRuntimeCondition(datav1alpha1.RuntimeFusesReady, datav1alpha1.RuntimeFusesReadyReason, "The fuses are ready.", corev1.ConditionTrue) |
| 67 | statusToUpdate.FuseReason = cond.Reason |
| 68 | statusToUpdate.Conditions = utils.UpdateRuntimeCondition(statusToUpdate.Conditions, cond) |
| 69 | |
| 70 | if !reflect.DeepEqual(oldStatus, statusToUpdate) { |
| 71 | return e.client.Status().Update(context.TODO(), runtime) |
| 72 | } |
| 73 | |
| 74 | return nil |
| 75 | }) |
| 76 | |
| 77 | if err != nil { |
| 78 | return false, errors.Wrapf(err, "failed to update fuse ready status in runtime status") |
| 79 | } |
| 80 | |
| 81 | return ready, nil |
| 82 | } |
| 83 | |
| 84 | // CleanUpFuse will cleanup node label for Fuse. |
| 85 | func (e *Helper) CleanUpFuse() (count int, err error) { |
no test coverage detected