Support offline-operations of data surface resources#5901
Conversation
wbc6080
left a comment
There was a problem hiding this comment.
Need to make verify CI check pass. You can refer to https://kubeedge.io/docs/developer/make_verify
| "github.com/kubeedge/kubeedge/edge/pkg/edged/config" | ||
| "github.com/kubeedge/kubeedge/edge/pkg/metamanager/metaserver/common" |
There was a problem hiding this comment.
Sort the import. Packages starting with github.com/kubeedge should be placed in the third part
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/common" | ||
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/ctl/client" | ||
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/util" | ||
| "github.com/spf13/cobra" |
There was a problem hiding this comment.
remove github.com/spf13/cobra to the second part
| if device.Spec.NodeName == nodeName { | ||
| deviceListFilter.Items = append(deviceListFilter.Items, *device) | ||
| } else { | ||
| fmt.Printf("can't query device: \"%s\" for node: \"%s\"\n", device.Name, device.Spec.NodeName) |
There was a problem hiding this comment.
Use klog instead of fmt. Please check the rest of the code as well
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/common" | ||
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/ctl/client" | ||
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/util" | ||
| "github.com/spf13/cobra" |
| "github.com/moby/term" | ||
| "github.com/spf13/cobra" |
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/ctl/client" | ||
| "github.com/spf13/cobra" |
|
These interfaces need to add tests |
Thank you for your suggestion. I will sort the import and run |
2ce68e4 to
7092f6b
Compare
|
I pushed the latest commit with the following major changes:
|
7092f6b to
408146a
Compare
| ls.Factory.Delete().ServeHTTP(w, req) | ||
| case reqInfo.Verb == "update": | ||
| ls.Factory.Update(reqInfo).ServeHTTP(w, req) | ||
| if reqInfo.Resource == "devices" { |
There was a problem hiding this comment.
Device is a type of CRD, and K8S APIServer has a unified API interface. It is not appropriate to exhaustively list specific CRD types in this way.
| } | ||
|
|
||
| if err := scanner.Err(); err != nil { | ||
| http.Error(w, fmt.Sprintf("Error reading logs: %v", err), http.StatusInternalServerError) |
There was a problem hiding this comment.
Here err != nil, don't it need a return?
| Stdin bool | ||
| Stdout bool | ||
| Stderr bool | ||
| TTY bool |
There was a problem hiding this comment.
What is TTY? Please add code comments.
|
|
||
| exec, err := remotecommand.NewSPDYExecutor(config, "POST", req.URL()) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("fail to create executor: %v", err) |
There was a problem hiding this comment.
| return nil, fmt.Errorf("fail to create executor: %v", err) | |
| return nil, fmt.Errorf("failed to create executor: %v", err) |
| if cases.isGetLogsFail { | ||
| return &types.LogsResponse{ | ||
| LogMessages: []string{}, | ||
| ErrMessages: []string{"fail to get logs for container"}, |
There was a problem hiding this comment.
| ErrMessages: []string{"fail to get logs for container"}, | |
| ErrMessages: []string{"failed to get logs for container"}, |
| return req | ||
| } | ||
|
|
||
| func disableEcho(fd uintptr) (func(), error) { |
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/util" | ||
| ) | ||
|
|
||
| var edgeDescribeDeviceShortDescription = `Describe devices in edge node` |
There was a problem hiding this comment.
| var edgeDescribeDeviceShortDescription = `Describe devices in edge node` | |
| var edgeDescribeDeviceShortDescription = `Describe device in edge node` |
| "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/util" | ||
| ) | ||
|
|
||
| var edgeDescribePodShortDescription = `Describe pods in edge node` |
There was a problem hiding this comment.
| var edgeDescribePodShortDescription = `Describe pods in edge node` | |
| var edgeDescribePodShortDescription = `Describe pod in edge node` |
| } | ||
| pod, err := podRequest.GetPod(ctx) | ||
| if err != nil { | ||
| klog.Info(err.Error()) |
There was a problem hiding this comment.
Why klog.Info() ,not klog.Error() ?
| err := json.Unmarshal(body, &logsResponse) | ||
| assert.NoError(t, err) | ||
| expectedResponse := types.LogsResponse{} | ||
| json.Unmarshal([]byte(tt.expectedBody), &expectedResponse) |
There was a problem hiding this comment.
| json.Unmarshal([]byte(tt.expectedBody), &expectedResponse) | |
| err := json.Unmarshal([]byte(tt.expectedBody), &expectedResponse) | |
| .... |
Please add error handling.
| stderrStr := queryparams.Get("stderr") | ||
| ttyStr := queryparams.Get("tty") | ||
|
|
||
| stdin := (stdinStr == trueStr) |
There was a problem hiding this comment.
| stdin := (stdinStr == trueStr) | |
| stdin := stdinStr == trueStr |
| ttyStr := queryparams.Get("tty") | ||
|
|
||
| stdin := (stdinStr == trueStr) | ||
| stdout := (stdoutStr == trueStr) |
There was a problem hiding this comment.
| stdout := (stdoutStr == trueStr) | |
| stdout := stdoutStr == trueStr |
|
|
||
| stdin := (stdinStr == trueStr) | ||
| stdout := (stdoutStr == trueStr) | ||
| stderr := (stderrStr == trueStr) |
There was a problem hiding this comment.
| stderr := (stderrStr == trueStr) | |
| stderr := stderrStr == trueStr |
| stdin := (stdinStr == trueStr) | ||
| stdout := (stdoutStr == trueStr) | ||
| stderr := (stderrStr == trueStr) | ||
| tty := (ttyStr == trueStr) |
There was a problem hiding this comment.
| tty := (ttyStr == trueStr) | |
| tty := ttyStr == trueStr |
| CoreAPIPrefix = "api" | ||
| CoreAPIGroupVersion = schema.GroupVersion{Group: "", Version: "v1"} | ||
| Prefix = "apis" | ||
| ) |
There was a problem hiding this comment.
Delete these unused constants.
| package restful | ||
|
|
||
| const ( | ||
| CONTAINERLOGS string = "/containerLogs" |
There was a problem hiding this comment.
Suggest deleting this file:
edge/pkg/metamanager/metaserver/kubernetes/storage/restful/constants.go,Put CONTAINERLOGS string = "/containerLogs" into edge/pkg/metamanager/metaserver/kubernetes/storage/restful/request.go.
408146a to
a65cf88
Compare
| Timestamps string `query:"timestamps"` | ||
| } | ||
|
|
||
| type ExecInfo struct { |
There was a problem hiding this comment.
Why param. in ExecInfo don't need the format query:"xxx" like LogsInfo?
There was a problem hiding this comment.
The logs is run on the edged restful API, these tags is used to generate query parameters. exec calls the remoteRuntimeService methods (ExecSync and Exec) without generating query parameters.
| @@ -0,0 +1,286 @@ | |||
| package handlerfactory | |||
There was a problem hiding this comment.
Please add copyright for new file
| @@ -0,0 +1,96 @@ | |||
| /* | |||
There was a problem hiding this comment.
Please djust the copyright format, like adding blank line between L5-6 and L6-7
| case cloudmodules.PolicyControllerModuleName: | ||
| resp := message.NewRespByMessage(&message, OK) | ||
| sendToCloud(resp) | ||
| case modules.MetaManagerModuleName: |
There was a problem hiding this comment.
It may cause confused using metamanager module here because we already have a module named meta. How about name this module metaserver because it seems the request are from metaserver? but metaserver is not an independent module, I'm not sure if metaserver is suitable. @fisherxu @luomengY @WillardHu @wbc6080
There was a problem hiding this comment.
It may cause confused using
metamanagermodule here because we already have a module namedmeta. How about name this modulemetaserverbecause it seems the request are from metaserver? but metaserver is not an independent module, I'm not sure if metaserver is suitable. @fisherxu @luomengY @WillardHu @wbc6080
I think using a metaserver is possible, as the source here comes from the metaserver.
There was a problem hiding this comment.
It may cause confused using
metamanagermodule here because we already have a module namedmeta. How about name this modulemetaserverbecause it seems the request are from metaserver? but metaserver is not an independent module, I'm not sure if metaserver is suitable. @fisherxu @luomengY @WillardHu @wbc6080
There was a problem hiding this comment.
I think using a
metaserveris possible, as the source here comes from themetaserver.
+1
There was a problem hiding this comment.
OK, I added and registered metaserver module, and set the msgsource to metaserver.
| if device.Spec.NodeName == nodeName { | ||
| deviceListFilter.Items = append(deviceListFilter.Items, *device) | ||
| } else { | ||
| klog.Infof("can't query device: \"%s\" for node: \"%s\"", device.Name, device.Spec.NodeName) |
There was a problem hiding this comment.
| klog.Infof("can't query device: \"%s\" for node: \"%s\"", device.Name, device.Spec.NodeName) | |
| klog.Errof("can't query device: \"%s\" for node: \"%s\"", device.Name, device.Spec.NodeName) |
| return fmt.Errorf("unable to find describer for %v", m) | ||
| } | ||
|
|
||
| first := true |
There was a problem hiding this comment.
What's the actual effect of first?
There was a problem hiding this comment.
describe supports printing information about multiple resources. If the first is false, blank lines is printed to separate resources.
| if pod.Spec.NodeName == nodeName { | ||
| var apiPod api.Pod | ||
| if err := k8s_v1_api.Convert_v1_Pod_To_core_Pod(pod, &apiPod, nil); err != nil { | ||
| klog.Infof("failed to convert pod with err:%v\n", err) |
There was a problem hiding this comment.
| klog.Infof("failed to convert pod with err:%v\n", err) | |
| klog.Errof("failed to convert pod with err:%v\n", err) |
There are several other places using Infof but not Errof. What's the consideration?
|
@dcdc831 integration test error is not introduced by this PR. You can ignore it. |
Signed-off-by: YulinLi <1826549123@qq.com>
3ddcad0 to
63ed57c
Compare
|
I undo the changes to |
Shelley-BaoYue
left a comment
There was a problem hiding this comment.
/lgtm
CIFuzz error can be ignored in this PR, the viaduct migration caused this error.
|
/assign @fisherxu @WillardHu @luomengY |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fisherxu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |


What type of PR is this?
/kind feature
What this PR does / why we need it:
In edge computing scenarios, edge nodes are usually under different networks from the cloud and are often offline due to network fluctuations and other issues. If the edge node is offline, users can only wait for the edge node to come online to perform operations from the cloud if they find any abnormality in the pod or device.
However, the data related to pods and devices are stored locally on the edge nodes, and due to the existence of edged, it is feasible in principle to obtain the data and operate the resources on the edge nodes. The support of this feature will reduce the network resource consumption of the edge node for debugging and resource adjustment, and avoid the situation that some functions of the KubeEdge platform are not available when the edge node is offline.
Which issue(s) this PR fixes:
Fixes #5587
Special notes for your reviewer:
Does this PR introduce a user-facing change?: