Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[WIP]fix windows node register failure issue #149

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion cmd/csi-node-driver-registrar/node_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import (
"os/signal"
"runtime"
"syscall"
"time"

"google.golang.org/grpc"

"github.com/kubernetes-csi/node-driver-registrar/pkg/util"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"
registerapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1"
)
Expand Down Expand Up @@ -60,8 +62,25 @@ func nodeRegister(csiDriverName, httpEndpoint string) {
}
klog.Infof("Registration Server started at: %s\n", socketPath)
grpcServer := grpc.NewServer()

// Registers kubelet plugin watcher api.
registerapi.RegisterRegistrationServer(grpcServer, registrar)
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure that this is the line where it hangs? I checked the kubelet & gRPC codebase and I see that it's just setting some properties in the server but it's not making any calls:

https://github.com/kubernetes/kubelet/blob/v0.21.1/pkg/apis/pluginregistration/v1/api.pb.go#L213-L215

https://github.com/grpc/grpc-go/blob/0257c8657362b76f24e7a8cfb61df48d4cb735d3/server.go#L625-L661

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

got it, thanks Jing, so it looks like after registration the kubelet doesn't call node-driver-registrar back (which could be because the request never got to the Kubelet or the kubelet acknowledged the request and didn't reply back), I think that if this is reproducible we should check the kubelet logs

Copy link
Member Author

Choose a reason for hiding this comment

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

@mauriciopoppe I am not quite familiar with node-driver-registrar, is there any way to fail when node-driver-registrar did not receive ack from kubelet? There could be many issues that kubelet does not respond, if node-driver-registrar could fail, then it would retry, I think that would fix this issue.

This PR does not fix the issue actully.

Copy link
Member

Choose a reason for hiding this comment

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

I'll add some comments to #143

if runtime.GOOS == "windows" {
for true {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of retrying forever, do we want to return fatalf?

Copy link
Member Author

Choose a reason for hiding this comment

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

try a few times(e.g. 10 times) is also an option, I am ok with that.

// try register on Windows node in a loop, detailed issue:
// https://github.com/kubernetes-csi/node-driver-registrar/issues/143
err := wait.PollImmediate(1*time.Second, 30*time.Second, func() (bool, error) {
registerapi.RegisterRegistrationServer(grpcServer, registrar)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The issue description says that this call hangs forever. I don't think this Poll method is going to ever return in that case. I think you'll need to run the call in a go routine and wait for the result or timeout that way.

Copy link
Member Author

@andyzhangx andyzhangx May 26, 2021

Choose a reason for hiding this comment

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

I think that's a wrong fix, do you know is there any way to restart node-driver-registrar automatically if register is not succeeded within a few seconds? The registration issue happens on both Azure & GKE Windows node now. When we hit the issue, restart node driver always works.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think returning a fatal error is the main way to cause node-driver-registrar to restart.

Copy link
Contributor

Choose a reason for hiding this comment

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

From the log you showed that the hang happened after this registration process. So will loop here help?

Copy link
Member Author

Choose a reason for hiding this comment

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

This PR won't work, after registerapi.RegisterRegistrationServer, it just wait for following GetInfo invoked, while sometimes on Windows node, it never happens.

// GetInfo is the RPC invoked by plugin watcher
func (e registrationServer) GetInfo(ctx context.Context, req *registerapi.InfoRequest) (*registerapi.PluginInfo, error) {
klog.Infof("Received GetInfo call: %+v", req)

return true, nil
})
if err == nil {
break
} else if err == wait.ErrWaitTimeout {
klog.Errorf("RegisterRegistrationServer timeout, try again")
}
}
} else {
registerapi.RegisterRegistrationServer(grpcServer, registrar)
}

go healthzServer(socketPath, httpEndpoint)
go removeRegSocket(csiDriverName)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20210317182105-75c7a8546eb9 // indirect
google.golang.org/grpc v1.36.0
k8s.io/apimachinery v0.21.0
k8s.io/client-go v0.21.0
k8s.io/klog/v2 v2.8.0
k8s.io/kubelet v0.21.0
Expand Down
Loading