CheckAndUpdateRuntimeStatus checks the related runtime status and updates it.
()
| 31 | |
| 32 | // CheckAndUpdateRuntimeStatus checks the related runtime status and updates it. |
| 33 | func (e *EFCEngine) CheckAndUpdateRuntimeStatus() (ready bool, err error) { |
| 34 | var ( |
| 35 | masterReady, workerReady bool |
| 36 | masterName string = e.getMasterName() |
| 37 | workerName string = e.getWorkerName() |
| 38 | namespace string = e.namespace |
| 39 | ) |
| 40 | |
| 41 | // 1. Master should be ready |
| 42 | master, err := kubeclient.GetStatefulSet(e.Client, masterName, namespace) |
| 43 | if err != nil { |
| 44 | return ready, err |
| 45 | } |
| 46 | |
| 47 | // 2. Worker should be ready |
| 48 | workers, err := ctrl.GetWorkersAsStatefulset(e.Client, |
| 49 | types.NamespacedName{Namespace: e.namespace, Name: workerName}) |
| 50 | if err != nil { |
| 51 | return ready, err |
| 52 | } |
| 53 | |
| 54 | err = retry.RetryOnConflict(retry.DefaultBackoff, func() error { |
| 55 | runtime, err := e.getRuntime() |
| 56 | if err != nil { |
| 57 | return err |
| 58 | } |
| 59 | |
| 60 | runtimeToUpdate := runtime.DeepCopy() |
| 61 | |
| 62 | states, err := e.queryCacheStatus() |
| 63 | if err != nil { |
| 64 | return err |
| 65 | } |
| 66 | |
| 67 | if len(runtime.Status.CacheStates) == 0 { |
| 68 | runtimeToUpdate.Status.CacheStates = map[common.CacheStateName]string{} |
| 69 | } |
| 70 | |
| 71 | runtimeToUpdate.Status.CacheStates[common.CacheCapacity] = states.cacheCapacity |
| 72 | runtimeToUpdate.Status.CacheStates[common.CachedPercentage] = states.cachedPercentage |
| 73 | runtimeToUpdate.Status.CacheStates[common.Cached] = states.cached |
| 74 | // update cache hit ratio |
| 75 | runtimeToUpdate.Status.CacheStates[common.CacheHitRatio] = states.cacheHitStates.cacheHitRatio |
| 76 | runtimeToUpdate.Status.CacheStates[common.LocalHitRatio] = states.cacheHitStates.localHitRatio |
| 77 | runtimeToUpdate.Status.CacheStates[common.RemoteHitRatio] = states.cacheHitStates.remoteHitRatio |
| 78 | // update cache throughput ratio |
| 79 | runtimeToUpdate.Status.CacheStates[common.LocalThroughputRatio] = states.cacheHitStates.localThroughputRatio |
| 80 | runtimeToUpdate.Status.CacheStates[common.RemoteThroughputRatio] = states.cacheHitStates.remoteThroughputRatio |
| 81 | runtimeToUpdate.Status.CacheStates[common.CacheThroughputRatio] = states.cacheHitStates.cacheThroughputRatio |
| 82 | |
| 83 | if *master.Spec.Replicas == master.Status.ReadyReplicas { |
| 84 | masterReady = true |
| 85 | } |
| 86 | |
| 87 | if runtime.Replicas() == 0 || workers.Status.ReadyReplicas > 0 { |
| 88 | workerReady = true |
| 89 | } |
| 90 |
nothing calls this directly
no test coverage detected