(logger *logs.Logger)
| 66 | } |
| 67 | |
| 68 | func (controller *Controller) resourceTask(logger *logs.Logger) { |
| 69 | logger.Info("start resource task") |
| 70 | nodeInfo, err := controller.FuncletClient.NodeInfo(&api.FuncletClientListNodeInput{RequestID: id.GetRequestID()}) |
| 71 | if err != nil { |
| 72 | logger.Errorf("sync resource info from funclet failed: %s", err) |
| 73 | return |
| 74 | } |
| 75 | if nodeInfo.Resource != nil { |
| 76 | if !controller.runtimeDispatcher.SyncResource(nodeInfo.Resource) { |
| 77 | logger.Errorf("sync resource info failed: %s", err) |
| 78 | return |
| 79 | } |
| 80 | } |
| 81 | list, err := controller.FuncletClient.List(&api.FuncletClientListContainersInput{RequestID: id.GetRequestID()}) |
| 82 | if err != nil { |
| 83 | logger.Errorf("get container list from funclet failed: %s", err) |
| 84 | return |
| 85 | } |
| 86 | var wg sync.WaitGroup |
| 87 | for _, rt := range *list { |
| 88 | wg.Add(1) |
| 89 | go func(runtime *api.ContainerInfo) { |
| 90 | if syncResult, err := controller.runtimeDispatcher.SyncRuntimeResource(runtime.ContainerID, runtime.Resource); !syncResult { |
| 91 | if err != nil { |
| 92 | inUse := rtctrl.RuntimeSyncError{RuntimeID: runtime.ContainerID, Reason: "runtime in used"}.Error() |
| 93 | if err.Error() != inUse { |
| 94 | logs.Errorf("sync runtime %s resource failed: resource %s", runtime.ContainerID, runtime.Resource) |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | wg.Done() |
| 99 | }(rt) |
| 100 | } |
| 101 | wg.Wait() |
| 102 | logger.Info("finish resource task") |
| 103 | } |
| 104 | |
| 105 | func (controller *Controller) runtimeTask(logger *logs.Logger) { |
| 106 | logger.Info("start runtime task") |
no test coverage detected