Skip to content

Commit

Permalink
Merge pull request #47 from ddebroy/windows1
Browse files Browse the repository at this point in the history
Build Node Driver Registrar for Windows nodes
  • Loading branch information
k8s-ci-robot authored Sep 5, 2019
2 parents 27b5d2c + 216c2aa commit 21825d3
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Dockerfile.Windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/windows/servercore:1809 as core

FROM mcr.microsoft.com/windows/nanoserver:1809
LABEL description="CSI Node driver registrar"

COPY ./bin/csi-node-driver-registrar.exe /csi-node-driver-registrar.exe
COPY --from=core /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll
USER ContainerAdministrator
ENTRYPOINT ["/csi-node-driver-registrar.exe"]
14 changes: 10 additions & 4 deletions cmd/csi-node-driver-registrar/node_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"fmt"
"net"
"os"
"runtime"

"google.golang.org/grpc"

"golang.org/x/sys/unix"
"k8s.io/klog"
registerapi "k8s.io/kubernetes/pkg/kubelet/apis/pluginregistration/v1alpha1"
)
Expand All @@ -48,16 +48,22 @@ func nodeRegister(
klog.Errorf("failed to stat the socket %s with error: %+v", socketPath, err)
os.Exit(1)
}
// Default to only user accessible socket, caller can open up later if desired
oldmask := unix.Umask(0077)

var oldmask int
if runtime.GOOS == "linux" {
// Default to only user accessible socket, caller can open up later if desired
oldmask, _ = umask(0077)
}

klog.Infof("Starting Registration Server at: %s\n", socketPath)
lis, err := net.Listen("unix", socketPath)
if err != nil {
klog.Errorf("failed to listen on socket: %s with error: %+v", socketPath, err)
os.Exit(1)
}
unix.Umask(oldmask)
if runtime.GOOS == "linux" {
umask(oldmask)
}
klog.Infof("Registration Server started at: %s\n", socketPath)
grpcServer := grpc.NewServer()
// Registers kubelet plugin watcher api.
Expand Down
27 changes: 27 additions & 0 deletions cmd/csi-node-driver-registrar/util_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// +build linux

/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"golang.org/x/sys/unix"
)

func umask(mask int) (int, error) {
return unix.Umask(mask), nil
}
27 changes: 27 additions & 0 deletions cmd/csi-node-driver-registrar/util_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// +build windows

/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"errors"
)

func umask(mask int) (int, error) {
return -1, errors.New("umask not supported in Windows")
}

0 comments on commit 21825d3

Please sign in to comment.