coolDown
(runtime *rtctrl.RuntimeInfo, logger *logs.Logger)
| 124 | |
| 125 | // coolDown |
| 126 | func (controller *Controller) coolDown(runtime *rtctrl.RuntimeInfo, logger *logs.Logger) { |
| 127 | recommend, err := controller.runtimeDispatcher.CoolDownRuntime(runtime) |
| 128 | if err != nil { |
| 129 | return |
| 130 | } |
| 131 | res := runtime.Resource.Copy() |
| 132 | used := runtime.Used |
| 133 | marked := runtime.Marked |
| 134 | |
| 135 | runtime.RebootBegin() |
| 136 | defer runtime.RebootEnd() |
| 137 | |
| 138 | if recommend != nil { |
| 139 | for _, ID := range recommend.ResetContainers { |
| 140 | info, _ := controller.runtimeDispatcher.GetRuntime(ID) |
| 141 | info.RebootBegin() |
| 142 | } |
| 143 | defer func() { |
| 144 | for _, ID := range recommend.ResetContainers { |
| 145 | info, _ := controller.runtimeDispatcher.GetRuntime(ID) |
| 146 | info.RebootEnd() |
| 147 | } |
| 148 | }() |
| 149 | } |
| 150 | |
| 151 | requestID := id.GetRequestID() |
| 152 | response, err := controller.FuncletClient.CoolDown(&api.FuncletClientCoolDownInput{ |
| 153 | ContainerID: runtime.RuntimeID, |
| 154 | RequestID: requestID, |
| 155 | ScaleDownRecommendation: recommend, |
| 156 | }) |
| 157 | logger.Infof("cool down runtime %s request id %s response %v err %v", runtime.RuntimeID, requestID, response, err) |
| 158 | if err == nil { |
| 159 | logger.V(9).Infof("[resource modify]-[decrease]: used %t, runtime %s, resource %s", used, runtime.RuntimeID, res) |
| 160 | if used { |
| 161 | if !controller.runtimeDispatcher.ReleaseUsedResource(res) { |
| 162 | logs.Errorf("cool down runtime %s release memory %d failed", runtime.RuntimeID, runtime.Resource.Memory) |
| 163 | } else { |
| 164 | runtime.SetUsed(false) |
| 165 | } |
| 166 | } |
| 167 | if marked { |
| 168 | if !controller.runtimeDispatcher.ReleaseMarkedResource(res) { |
| 169 | logger.Errorf("cool down runtime %s release memory %d failed", runtime.RuntimeID, runtime.Resource.Memory) |
| 170 | } else { |
| 171 | runtime.SetMarked(false) |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | if err != nil { |
| 176 | logger.Errorf("cool down runtime %s failed: %s", runtime.RuntimeID, err.Error()) |
| 177 | runtime.Invalidate() |
| 178 | } |
| 179 | if recommend != nil && response == nil { |
| 180 | for _, ID := range recommend.ResetContainers { |
| 181 | rt, _ := controller.runtimeDispatcher.GetRuntime(ID) |
| 182 | rt.Invalidate() |
| 183 | } |
no test coverage detected