(runtime *rtctrl.RuntimeInfo, logger *logs.Logger)
| 193 | } |
| 194 | |
| 195 | func (controller *Controller) reborn(runtime *rtctrl.RuntimeInfo, logger *logs.Logger) { |
| 196 | recommend, err := controller.runtimeDispatcher.ResetRuntime(runtime) |
| 197 | if err != nil { |
| 198 | return |
| 199 | } |
| 200 | res := runtime.Resource.Copy() |
| 201 | used := runtime.Used |
| 202 | marked := runtime.Marked |
| 203 | |
| 204 | runtime.RebootBegin() |
| 205 | defer runtime.RebootEnd() |
| 206 | |
| 207 | if recommend != nil { |
| 208 | for _, ID := range recommend.ResetContainers { |
| 209 | info, _ := controller.runtimeDispatcher.GetRuntime(ID) |
| 210 | info.RebootBegin() |
| 211 | } |
| 212 | defer func() { |
| 213 | for _, ID := range recommend.ResetContainers { |
| 214 | info, _ := controller.runtimeDispatcher.GetRuntime(ID) |
| 215 | info.RebootEnd() |
| 216 | } |
| 217 | }() |
| 218 | } |
| 219 | |
| 220 | requestID := id.GetRequestID() |
| 221 | response, err := controller.FuncletClient.Reborn(&api.FuncletClientRebornInput{ |
| 222 | ContainerID: runtime.RuntimeID, |
| 223 | RequestID: requestID, |
| 224 | ScaleDownRecommendation: recommend, |
| 225 | }) |
| 226 | logger.Infof("reborn runtime %s request id %s response %v err %v", runtime.RuntimeID, requestID, response, err) |
| 227 | if err == nil { |
| 228 | logs.V(9).Infof("[resource modify]-[decrease]: used %t, runtime %s, resource %s", used, runtime.RuntimeID, res) |
| 229 | if used { |
| 230 | if !controller.runtimeDispatcher.ReleaseUsedResource(res) { |
| 231 | logs.Errorf("cool down runtime %s release memory %d failed", runtime.RuntimeID, runtime.Resource.Memory) |
| 232 | } else { |
| 233 | runtime.SetUsed(false) |
| 234 | } |
| 235 | } |
| 236 | if marked { |
| 237 | if !controller.runtimeDispatcher.ReleaseMarkedResource(res) { |
| 238 | logs.Errorf("cool down runtime %s release memory %d failed", runtime.RuntimeID, runtime.Resource.Memory) |
| 239 | } else { |
| 240 | runtime.SetMarked(false) |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | if err != nil { |
| 245 | logger.Errorf("reborn runtime %s failed: %s", runtime.RuntimeID, err.Error()) |
| 246 | } |
| 247 | if recommend != nil && response == nil { |
| 248 | for _, ID := range recommend.ResetContainers { |
| 249 | rt, _ := controller.runtimeDispatcher.GetRuntime(ID) |
| 250 | rt.Invalidate() |
| 251 | } |
| 252 | logger.Errorf("scale down runtime %s failed: %v", runtime.RuntimeID, recommend.ResetContainers) |
no test coverage detected