Skip to content

Commit

Permalink
Merge pull request #24 from jsafrane/rebase-v2.1.0
Browse files Browse the repository at this point in the history
Bug 1912237: Rebase to v2.1.0 for OCP 4.7
  • Loading branch information
openshift-merge-robot committed Jan 6, 2021
2 parents 395c064 + 5badab7 commit 1f04e70
Show file tree
Hide file tree
Showing 592 changed files with 87,918 additions and 11,755 deletions.
23 changes: 0 additions & 23 deletions CHANGELOG/CHANGELOG-2.0.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
# Release notes for v2.0.1

[Documentation](https://kubernetes-csi.github.io/docs/)

# Changelog since v2.0.0

## Changes by Kind

### Uncategorized

- Update image and tag names for Windows to have separate parameters for nanoserver and servercore ([#111](https://github.com/kubernetes-csi/node-driver-registrar/pull/111), [@jingxu97](https://github.com/jingxu97))

## Dependencies

### Added
_Nothing has changed._

### Changed
_Nothing has changed._

### Removed
_Nothing has changed._

# Release notes for v2.0

[Documentation](https://kubernetes-csi.github.io/docs/)
Expand Down
235 changes: 235 additions & 0 deletions CHANGELOG/CHANGELOG-2.1.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Dockerfile.openshift.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ WORKDIR /go/src/github.com/kubernetes-csi/node-driver-registrar
COPY . .
RUN make build

FROM registry.svc.ci.openshift.org/ocp/4.6:base
FROM registry.svc.ci.openshift.org/ocp/4.7:base
COPY --from=builder /go/src/github.com/kubernetes-csi/node-driver-registrar/bin/csi-node-driver-registrar /usr/bin/
ENTRYPOINT ["/usr/bin/csi-node-driver-registrar"]
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ There are two UNIX domain sockets used by the node-driver-registrar:

### Optional arguments

* `--health-port`: This is the port of the health check server for the node-driver-registrar,
which checks if the registration socket exists. A value <= 0 disables the server.
Server is disabled by default.
* `--http-endpoint`: "The TCP network address where the HTTP server for diagnostics, including
the health check indicating whether the registration socket exists, will listen (example:
`:8080`). The default is empty string, which means the server is disabled.

* `--health-port`: (deprecated) This is the port of the health check server for the
node-driver-registrar, which checks if the registration socket exists. A value <= 0 disables
the server. Server is disabled by default.

* `--timeout <duration>`: Timeout of all calls to CSI driver. It should be set to a value that accommodates the `GetDriverName` calls. 1 second is used by default.

### Required permissions

Expand All @@ -70,6 +76,11 @@ permissions to:
* Access the registration socket (typically in `/var/lib/kubelet/plugins_registry/`).
* Used by the `node-driver-registrar` to register the driver with kubelet.

### Health Check

If `--http-endpoint` is set, the node-driver-registrar exposes a health check endpoint at the
specified address and the path `/healthz`, indicating whether the registration socket exists.

### Example

Here is an example sidecar spec in the driver DaemonSet. `<drivername.example.com>` should be replaced by
Expand Down
32 changes: 24 additions & 8 deletions cmd/csi-node-driver-registrar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import (
"flag"
"fmt"
"os"
"strconv"
"time"

"k8s.io/klog"
"github.com/kubernetes-csi/csi-lib-utils/metrics"
"k8s.io/klog/v2"

"github.com/kubernetes-csi/csi-lib-utils/connection"
csirpc "github.com/kubernetes-csi/csi-lib-utils/rpc"
Expand All @@ -35,20 +37,19 @@ const (
// names
annotationKey = "csi.volume.kubernetes.io/nodeid"

// Default timeout of short CSI calls like GetPluginInfo
csiTimeout = time.Second

// Verify (and update, if needed) the node ID at this frequency.
sleepDuration = 2 * time.Minute
)

// Command line flags
var (
connectionTimeout = flag.Duration("connection-timeout", 0, "The --connection-timeout flag is deprecated")
operationTimeout = flag.Duration("timeout", time.Second, "Timeout for waiting for communication with driver")
csiAddress = flag.String("csi-address", "/run/csi/socket", "Path of the CSI driver socket that the node-driver-registrar will connect to.")
pluginRegistrationPath = flag.String("plugin-registration-path", "/registration", "Path to Kubernetes plugin registration directory.")
kubeletRegistrationPath = flag.String("kubelet-registration-path", "", "Path of the CSI driver socket on the Kubernetes host machine.")
healthzPort = flag.Int("health-port", 0, "TCP port for healthz requests. Set to 0 to disable the healthz server.")
healthzPort = flag.Int("health-port", 0, "(deprecated) TCP port for healthz requests. Set to 0 to disable the healthz server. Only one of `--health-port` and `--http-endpoint` can be set.")
httpEndpoint = flag.String("http-endpoint", "", "The TCP network address where the HTTP server for diagnostics, including the health check indicating whether the registration socket exists, will listen (example: `:8080`). The default is empty string, which means the server is disabled. Only one of `--health-port` and `--http-endpoint` can be set.")
showVersion = flag.Bool("version", false, "Show version.")
version = "unknown"

Expand Down Expand Up @@ -111,23 +112,37 @@ func main() {
}
klog.Infof("Version: %s", version)

if *healthzPort > 0 && *httpEndpoint != "" {
klog.Error("only one of `--health-port` and `--http-endpoint` can be set.")
os.Exit(1)
}
var addr string
if *healthzPort > 0 {
addr = ":" + strconv.Itoa(*healthzPort)
} else {
addr = *httpEndpoint
}

if *connectionTimeout != 0 {
klog.Warning("--connection-timeout is deprecated and will have no effect")
}

// Unused metrics manager, necessary for connection.Connect below
cmm := metrics.NewCSIMetricsManagerForSidecar("")

// Once https://github.com/container-storage-interface/spec/issues/159 is
// resolved, if plugin does not support PUBLISH_UNPUBLISH_VOLUME, then we
// can skip adding mapping to "csi.volume.kubernetes.io/nodeid" annotation.

klog.V(1).Infof("Attempting to open a gRPC connection with: %q", *csiAddress)
csiConn, err := connection.Connect(*csiAddress)
csiConn, err := connection.Connect(*csiAddress, cmm)
if err != nil {
klog.Errorf("error connecting to CSI driver: %v", err)
os.Exit(1)
}

klog.V(1).Infof("Calling CSI driver to discover driver name")
ctx, cancel := context.WithTimeout(context.Background(), csiTimeout)
ctx, cancel := context.WithTimeout(context.Background(), *operationTimeout)
defer cancel()

csiDriverName, err := csirpc.GetDriverName(ctx, csiConn)
Expand All @@ -137,7 +152,8 @@ func main() {
}

klog.V(2).Infof("CSI driver name: %q", csiDriverName)
cmm.SetDriverName(csiDriverName)

// Run forever
nodeRegister(csiDriverName)
nodeRegister(csiDriverName, addr)
}
19 changes: 8 additions & 11 deletions cmd/csi-node-driver-registrar/node_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ import (
"os"
"os/signal"
"runtime"
"strconv"
"syscall"

"google.golang.org/grpc"

"github.com/kubernetes-csi/node-driver-registrar/pkg/util"
"k8s.io/klog"
"k8s.io/klog/v2"
registerapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1"
)

func nodeRegister(
csiDriverName string,
) {
func nodeRegister(csiDriverName, httpEndpoint string) {
// When kubeletRegistrationPath is specified then driver-registrar ONLY acts
// as gRPC server which replies to registration requests initiated by kubelet's
// pluginswatcher infrastructure. Node labeling is done by kubelet's csi code.
Expand Down Expand Up @@ -66,7 +63,7 @@ func nodeRegister(
// Registers kubelet plugin watcher api.
registerapi.RegisterRegistrationServer(grpcServer, registrar)

go healthzServer(socketPath, *healthzPort)
go healthzServer(socketPath, httpEndpoint)
go removeRegSocket(csiDriverName)
// Starts service
if err := grpcServer.Serve(lis); err != nil {
Expand All @@ -81,12 +78,12 @@ func buildSocketPath(csiDriverName string) string {
return fmt.Sprintf("%s/%s-reg.sock", *pluginRegistrationPath, csiDriverName)
}

func healthzServer(socketPath string, port int) {
if port <= 0 {
klog.Infof("Skipping healthz server because port set to: %v", port)
func healthzServer(socketPath string, httpEndpoint string) {
if httpEndpoint == "" {
klog.Infof("Skipping healthz server because HTTP endpoint is set to: %q", httpEndpoint)
return
}
klog.Infof("Starting healthz server on port: %v\n", port)
klog.Infof("Starting healthz server at HTTP endpoint: %v\n", httpEndpoint)

http.HandleFunc("/healthz", func(w http.ResponseWriter, req *http.Request) {
socketExists, err := util.DoesSocketExist(socketPath)
Expand All @@ -105,7 +102,7 @@ func healthzServer(socketPath string, port int) {
}
})

klog.Fatal(http.ListenAndServe(":"+strconv.Itoa(port), nil))
klog.Fatal(http.ListenAndServe(httpEndpoint, nil))
}

func removeRegSocket(csiDriverName string) {
Expand Down
17 changes: 11 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ go 1.15

require (
github.com/container-storage-interface/spec v1.3.0 // indirect
github.com/kubernetes-csi/csi-lib-utils v0.4.0-rc1
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4
google.golang.org/grpc v1.27.0
k8s.io/client-go v0.19.0
k8s.io/klog v1.0.0
k8s.io/kubelet v0.19.0
github.com/go-logr/logr v0.3.0 // indirect
github.com/kubernetes-csi/csi-lib-utils v0.9.0
github.com/prometheus/client_golang v1.8.0 // indirect
github.com/prometheus/common v0.15.0 // indirect
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 // indirect
golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f
google.golang.org/genproto v0.0.0-20201211151036-40ec1c210f7a // indirect
google.golang.org/grpc v1.34.0
k8s.io/client-go v0.20.0
k8s.io/klog/v2 v2.4.0
k8s.io/kubelet v0.20.0
)
Loading

0 comments on commit 1f04e70

Please sign in to comment.