MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / resourceTask

Method resourceTask

pkg/controller/task.go:68–103  ·  view source on GitHub ↗
(logger *logs.Logger)

Source from the content-addressed store, hash-verified

66}
67
68func (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
105func (controller *Controller) runtimeTask(logger *logs.Logger) {
106 logger.Info("start runtime task")

Callers 1

cronTaskMethod · 0.95

Calls 12

GetRequestIDFunction · 0.92
ErrorfFunction · 0.92
ErrorfMethod · 0.80
DoneMethod · 0.80
InfoMethod · 0.65
NodeInfoMethod · 0.65
SyncResourceMethod · 0.65
ListMethod · 0.65
SyncRuntimeResourceMethod · 0.65
WaitMethod · 0.65
AddMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected