Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix bugs of yurctl #317

Merged
merged 1 commit into from
May 25, 2021
Merged

fix bugs of yurctl #317

merged 1 commit into from
May 25, 2021

Conversation

Peeknut
Copy link
Member

@Peeknut Peeknut commented May 23, 2021

Ⅰ. Describe what this PR does

fix bugs of yurtctl:

  • The command in servant-convert/revert-job did not run successfully, but the job status is success
  • Use of the flag --kubeadm-conf-path

Ⅱ. Does this pull request fix one issue?

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

Ⅳ. Describe how to verify it

NOTE: After yurtctl is modified, you need to recompile the yurtctl servant image and use it yourself, because the default image of servant-convert/revert-job is out of date after modify it.

Ⅴ. Special notes for reviews

@openyurt-bot openyurt-bot added the size/M size/M: 30-99 label May 23, 2021
@Peeknut Peeknut force-pushed the fix branch 2 times, most recently from 246662c to 4d7846b Compare May 24, 2021 01:31
@Peeknut
Copy link
Member Author

Peeknut commented May 24, 2021

Do the following test

1.Compile the image locally on node: mastern80
[root@n80 openyurt]# make release WHAT="yurtctl-servant" ARCH="amd64" REGION=cn

[root@n80 openyurt]# docker images | grep yurt
openyurt/yurtctl-servant                                                 v0.4.0-amd64        5ea7510d802b        22 seconds ago      36.7MB
registry.cn-hangzhou.aliyuncs.com/openyurttest/yurt-tunnel-agent         v0.4.0-amd64        a9865833621f        41 hours ago        78.1MB
registry.cn-hangzhou.aliyuncs.com/openyurttest/yurt-tunnel-server        v0.4.0-amd64        4ff647e682f2        41 hours ago        80.3MB
registry.cn-hangzhou.aliyuncs.com/openyurttest/yurtctl-servant           v0.4.0-amd64        7db90d6ef18f        41 hours ago        36.7MB
registry.cn-hangzhou.aliyuncs.com/openyurttest/yurt-controller-manager   v0.4.0-amd64        af26853ce6ba        41 hours ago        87.5MB
registry.cn-hangzhou.aliyuncs.com/openyurttest/yurthub                   v0.4.0-amd64        eef8696d0f8b        41 hours ago        87.1MB
openyurt/yurtctl-servant                                                 latest              334925093f3d        3 weeks ago         38.1MB
openyurt/yurt-tunnel-agent                                               latest              2e037570c97e        3 weeks ago         77MB
openyurt/yurt-controller-manager                                         latest              e06fd25cbaa2        4 months ago        86.5MB
2.Test yurtctl convert:
[root@master openyurt]# ./_output/bin/yurtctl convert --deploy-yurttunnel --cloud-nodes master --provider kubeadm --kubeadm-conf-path /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf --yurt-controller-manager-image="registry.cn-hangzhou.aliyuncs.com/openyurttest/yurt-controller-manager:v0.4.0-amd64" --yurt-tunnel-agent-image="registry.cn-hangzhou.aliyuncs.com/openyurttest/yurt-tunnel-agent:v0.4.0-amd64" --yurt-tunnel-server-image="registry.cn-hangzhou.aliyuncs.com/openyurttest/yurt-tunnel-server:v0.4.0-amd64" --yurtctl-servant-image="openyurt/yurtctl-servant:v0.4.0-amd64" --yurthub-image="registry.cn-hangzhou.aliyuncs.com/openyurttest/yurthub:v0.4.0-amd64"
I0524 10:41:59.839045    8522 convert.go:273] mark master as the cloud-node
I0524 10:42:01.143795    8522 convert.go:329] yurt-tunnel-server is deployed
I0524 10:42:01.215576    8522 convert.go:337] yurt-tunnel-agent is deployed
I0524 10:42:01.274380    8522 convert.go:461] kube-public/cluster-info configmap already exists, skip to prepare it
I0524 10:42:01.274427    8522 convert.go:348] deploying the yurt-hub and resetting the kubelet service...
I0524 10:42:42.196338    8522 util.go:320] servant job(yurtctl-servant-convert-n80) has succeeded
I0524 10:42:42.196400    8522 convert.go:372] the yurt-hub is deployed


[root@master openyurt]# kubectl get pod -A
NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
kube-system   coredns-58cc8c89f4-c2z88                   1/1     Running   2          83d
kube-system   coredns-58cc8c89f4-m6v2b                   1/1     Running   2          83d
kube-system   etcd-master                                1/1     Running   2          122d
kube-system   kube-apiserver-master                      1/1     Running   2          122d
kube-system   kube-controller-manager-master             1/1     Running   3          122d
kube-system   kube-flannel-ds-79ckt                      1/1     Running   2          122d
kube-system   kube-flannel-ds-q886f                      1/1     Running   0          2d
kube-system   kube-proxy-44cfx                           1/1     Running   0          2d
kube-system   kube-proxy-rk49h                           1/1     Running   2          122d
kube-system   kube-scheduler-master                      1/1     Running   2          122d
kube-system   yurt-controller-manager-5b67549d9b-cxgtk   1/1     Running   0          107s
kube-system   yurt-hub-n80                               1/1     Running   0          104s
kube-system   yurt-tunnel-agent-9vzh9                    1/1     Running   0          104s
kube-system   yurt-tunnel-server-d84666f6c-c28mh         1/1     Running   0          106s
3.Test yurtctl revert
[root@master openyurt]# ./_output/bin/yurtctl revert --kubeadm-conf-path /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf --yurtctl-servant-image="openyurt/yurtctl-servant:v0.4.0-amd64"
I0524 10:44:31.294400   18272 revert.go:162] label openyurt.io/is-edge-worker is removed
I0524 10:44:31.536043   18272 revert.go:172] yurt controller manager is removed
I0524 10:44:31.609675   18272 revert.go:182] serviceaccount for yurt controller manager is removed
I0524 10:44:31.681935   18272 revert.go:192] clusterrole for yurt controller manager is removed
I0524 10:44:31.689847   18272 revert.go:202] clusterrolebinding for yurt controller manager is removed
I0524 10:44:32.723875   18272 revert.go:239] clusterrolebinding system:controller:node-controller is created
I0524 10:45:03.138720   18272 util.go:320] servant job(yurtctl-servant-revert-n80) has succeeded
I0524 10:45:03.138833   18272 revert.go:253] yurt-hub is removed, kubelet service is reset
4.Test yurtctl convert edgenode :
[root@master openyurt]# ./_output/bin/yurtctl convert edgenode -e n80\
>  --kubeadm-conf-path /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf\
>  --yurtctl-servant-image="openyurt/yurtctl-servant:v0.4.0-amd64"\
>  --yurthub-image="registry.cn-hangzhou.aliyuncs.com/openyurttest/yurthub:v0.4.0-amd64"
I0524 10:53:55.829713   19754 util.go:320] servant job(yurtctl-servant-convert-n80) has succeeded

[root@n80 ljw]# kubectl get pod -A
NAMESPACE     NAME                             READY   STATUS    RESTARTS   AGE
kube-system   coredns-58cc8c89f4-c2z88         1/1     Running   2          83d
kube-system   coredns-58cc8c89f4-m6v2b         1/1     Running   2          83d
kube-system   etcd-master                      1/1     Running   2          122d
kube-system   kube-apiserver-master            1/1     Running   2          122d
kube-system   kube-controller-manager-master   1/1     Running   3          122d
kube-system   kube-flannel-ds-79ckt            1/1     Running   2          122d
kube-system   kube-flannel-ds-q886f            1/1     Running   0          2d
kube-system   kube-proxy-44cfx                 1/1     Running   0          2d
kube-system   kube-proxy-rk49h                 1/1     Running   2          122d
kube-system   kube-scheduler-master            1/1     Running   2          122d
kube-system   yurt-hub-n80                     1/1     Running   1          39s
5.Test yurtctl revert edgenode
[root@master openyurt]# ./_output/bin/yurtctl revert edgenode -e n80 --kubeadm-conf-path /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf --yurtctl-servant-image="openyurt/yurtctl-servant:v0.4.0-amd64"
I0524 10:56:56.963130   31872 util.go:320] servant job(yurtctl-servant-revert-n80) has succeeded

@Peeknut Peeknut force-pushed the fix branch 2 times, most recently from e50871c to 1aaf167 Compare May 24, 2021 13:52
@@ -242,7 +240,8 @@ func (c *ConvertEdgeNodeOptions) RunConvertEdgeNode() (err error) {
klog.Errorf("fail to run ServantJobs: %s", err)
return err
}
} else {
} else if len(c.EdgeNodes) == 0 || (len(c.EdgeNodes) == 1 && c.EdgeNodes[0] == nodeName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about add nodeName != "" for len(c.EdgeNodes) == 0 condition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -269,22 +266,44 @@ func (c *ConvertEdgeNodeOptions) RunConvertEdgeNode() (err error) {
if err != nil {
Copy link
Member

@rambohe-ch rambohe-ch May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about move c.KubeadmConfPath and c.PodMainfestPath parameter check and joinToken creation before LabelNode? so convert can fail fast if any error happened

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea.

@@ -193,7 +193,8 @@ func (r *RevertEdgeNodeOptions) RunRevertEdgeNode() (err error) {
klog.Errorf("fail to revert edge node: %s", err)
return err
}
} else {
} else if len(r.EdgeNodes) == 0 || (len(r.EdgeNodes) == 1 && r.EdgeNodes[0] == nodeName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about add nodeName != "" for len(c.EdgeNodes) == 0 condition?

}
klog.Info("label openyurt.io/is-edge-worker is removed")
defer func() {
Copy link
Member

@rambohe-ch rambohe-ch May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about move remove edge label routine to the end of RunRevertEdgeNode func and after RevertKubelet and RemoveYurthub . because we should try to keep the reverse order of RunConvertEdgeNode. at the same time, rollback routine will not be needed.

@kadisi
Copy link
Member

kadisi commented May 25, 2021

/kind bug

@openyurt-bot openyurt-bot added the kind/bug kind/bug label May 25, 2021
@openyurt-bot openyurt-bot added size/L size/L: 100-499 and removed size/M size/M: 30-99 labels May 25, 2021
@rambohe-ch
Copy link
Member

/lgtm

@rambohe-ch
Copy link
Member

/approve

@openyurt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Peeknut, rambohe-ch

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openyurt-bot openyurt-bot added the approved approved label May 25, 2021
@openyurt-bot openyurt-bot merged commit d23036b into openyurtio:master May 25, 2021
MrGirl pushed a commit to MrGirl/openyurt that referenced this pull request Mar 29, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
approved approved kind/bug kind/bug lgtm lgtm size/L size/L: 100-499
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants