From 041a5c2dc2e749819aba8d03448a25394cfde385 Mon Sep 17 00:00:00 2001 From: Amarnath Valluri Date: Tue, 12 Feb 2019 15:54:23 +0200 Subject: [PATCH 1/2] Removed csi-common package dependency csi-common package is part of kuberntes-csi/drivers which is deprecated and unmaintained. The main parts used from csi-common are default {node,identity,controller}server implementations and NonBlockingGRPCServer. Default server implementations can be integrated to hostpath driver code, this makes the driver code simple and clean. Lifted over the NonBlockingGRPCServer code and simplified as per the driver needs. Signed-off-by: Amarnath Valluri --- Gopkg.lock | 10 +- cmd/hostpathplugin/main.go | 9 +- pkg/hostpath/controllerserver.go | 78 ++++++- pkg/hostpath/hostpath.go | 68 +++--- pkg/hostpath/identityserver.go | 52 ++++- pkg/hostpath/nodeserver.go | 36 +++- .../pkg/csi-common => pkg/hostpath}/server.go | 47 ++-- .../github.com/kubernetes-csi/drivers/LICENSE | 201 ------------------ .../csi-common/controllerserver-default.go | 79 ------- .../drivers/pkg/csi-common/driver.go | 102 --------- .../pkg/csi-common/identityserver-default.go | 65 ------ .../pkg/csi-common/nodeserver-default.go | 65 ------ .../drivers/pkg/csi-common/utils.go | 105 --------- 13 files changed, 217 insertions(+), 700 deletions(-) rename {vendor/github.com/kubernetes-csi/drivers/pkg/csi-common => pkg/hostpath}/server.go (69%) delete mode 100644 vendor/github.com/kubernetes-csi/drivers/LICENSE delete mode 100644 vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/controllerserver-default.go delete mode 100644 vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/driver.go delete mode 100644 vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/identityserver-default.go delete mode 100644 vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/nodeserver-default.go delete mode 100644 vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/utils.go diff --git a/Gopkg.lock b/Gopkg.lock index bf1e960de..2c542c6e0 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -41,14 +41,6 @@ revision = "d460ce9f8df2e77fb1ba55ca87fafed96c607494" version = "v1.0.0" -[[projects]] - digest = "1:596505ce72821ef663980f7ce826984a30da406f9356a92c10ac8b44012d549c" - name = "github.com/kubernetes-csi/drivers" - packages = ["pkg/csi-common"] - pruneopts = "UT" - revision = "df8026fe9418ed9d7d59837b468f5be40e719ab1" - version = "v1.0.0" - [[projects]] digest = "1:e5d0bd87abc2781d14e274807a470acd180f0499f8bf5bb18606e9ec22ad9de9" name = "github.com/pborman/uuid" @@ -184,9 +176,9 @@ "github.com/golang/glog", "github.com/golang/protobuf/ptypes", "github.com/golang/protobuf/ptypes/timestamp", - "github.com/kubernetes-csi/drivers/pkg/csi-common", "github.com/pborman/uuid", "golang.org/x/net/context", + "google.golang.org/grpc", "google.golang.org/grpc/codes", "google.golang.org/grpc/status", "k8s.io/kubernetes/pkg/util/mount", diff --git a/cmd/hostpathplugin/main.go b/cmd/hostpathplugin/main.go index 18771314f..d4f443f79 100644 --- a/cmd/hostpathplugin/main.go +++ b/cmd/hostpathplugin/main.go @@ -18,6 +18,7 @@ package main import ( "flag" + "fmt" "os" "github.com/kubernetes-csi/csi-driver-host-path/pkg/hostpath" @@ -41,6 +42,10 @@ func main() { } func handle() { - driver := hostpath.GetHostPathDriver() - driver.Run(*driverName, *nodeID, *endpoint) + driver, err := hostpath.NewHostPathDriver(*driverName, *nodeID, *endpoint) + if err != nil { + fmt.Printf("Failed to initialize driver: %s", err.Error()) + os.Exit(1) + } + driver.Run() } diff --git a/pkg/hostpath/controllerserver.go b/pkg/hostpath/controllerserver.go index 2bd8d7024..cb8ab0836 100644 --- a/pkg/hostpath/controllerserver.go +++ b/pkg/hostpath/controllerserver.go @@ -32,7 +32,6 @@ import ( "google.golang.org/grpc/status" "github.com/container-storage-interface/spec/lib/go/csi" - "github.com/kubernetes-csi/drivers/pkg/csi-common" utilexec "k8s.io/utils/exec" ) @@ -44,11 +43,22 @@ const ( ) type controllerServer struct { - *csicommon.DefaultControllerServer + caps []*csi.ControllerServiceCapability +} + +func NewControllerServer() *controllerServer { + return &controllerServer{ + caps: getControllerServiceCapabilities( + []csi.ControllerServiceCapability_RPC_Type{ + csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, + csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, + csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS, + }), + } } func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { - if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil { + if err := cs.validateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil { glog.V(3).Infof("invalid create volume req: %v", req) return nil, err } @@ -134,7 +144,7 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request") } - if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil { + if err := cs.validateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil { glog.V(3).Infof("invalid delete volume req: %v", req) return nil, err } @@ -146,14 +156,36 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol return &csi.DeleteVolumeResponse{}, nil } +func (cs *controllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) { + return &csi.ControllerGetCapabilitiesResponse{ + Capabilities: cs.caps, + }, nil +} + func (cs *controllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { - return cs.DefaultControllerServer.ValidateVolumeCapabilities(ctx, req) + return nil, status.Error(codes.Unimplemented, "") +} + +func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) { + return nil, status.Error(codes.Unimplemented, "") +} + +func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) { + return nil, status.Error(codes.Unimplemented, "") +} + +func (cs *controllerServer) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) { + return nil, status.Error(codes.Unimplemented, "") +} + +func (cs *controllerServer) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) { + return nil, status.Error(codes.Unimplemented, "") } // CreateSnapshot uses tar command to create snapshot for hostpath volume. The tar command can quickly create // archives of entire directories. The host image must have "tar" binaries in /bin, /usr/sbin, or /usr/bin. func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) { - if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil { + if err := cs.validateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil { glog.V(3).Infof("invalid create snapshot req: %v", req) return nil, err } @@ -232,7 +264,7 @@ func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS return nil, status.Error(codes.InvalidArgument, "Snapshot ID missing in request") } - if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil { + if err := cs.validateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil { glog.V(3).Infof("invalid delete snapshot req: %v", req) return nil, err } @@ -245,7 +277,7 @@ func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS } func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) { - if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS); err != nil { + if err := cs.validateControllerServiceRequest(csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS); err != nil { glog.V(3).Infof("invalid list snapshot req: %v", req) return nil, err } @@ -365,3 +397,33 @@ func convertSnapshot(snap hostPathSnapshot) *csi.ListSnapshotsResponse { return rsp } + +func (cs *controllerServer) validateControllerServiceRequest(c csi.ControllerServiceCapability_RPC_Type) error { + if c == csi.ControllerServiceCapability_RPC_UNKNOWN { + return nil + } + + for _, cap := range cs.caps { + if c == cap.GetRpc().GetType() { + return nil + } + } + return status.Error(codes.InvalidArgument, fmt.Sprintf("%s", c)) +} + +func getControllerServiceCapabilities(cl []csi.ControllerServiceCapability_RPC_Type) []*csi.ControllerServiceCapability { + var csc []*csi.ControllerServiceCapability + + for _, cap := range cl { + glog.Infof("Enabling controller service capability: %v", cap.String()) + csc = append(csc, &csi.ControllerServiceCapability{ + Type: &csi.ControllerServiceCapability_Rpc{ + Rpc: &csi.ControllerServiceCapability_RPC{ + Type: cap, + }, + }, + }) + } + + return csc +} diff --git a/pkg/hostpath/hostpath.go b/pkg/hostpath/hostpath.go index 68cad52ba..299ac4b97 100644 --- a/pkg/hostpath/hostpath.go +++ b/pkg/hostpath/hostpath.go @@ -19,11 +19,9 @@ package hostpath import ( "fmt" - "github.com/container-storage-interface/spec/lib/go/csi" "github.com/golang/glog" timestamp "github.com/golang/protobuf/ptypes/timestamp" - "github.com/kubernetes-csi/drivers/pkg/csi-common" ) const ( @@ -36,14 +34,14 @@ const ( ) type hostPath struct { - driver *csicommon.CSIDriver + name string + nodeID string + version string + endpoint string ids *identityServer ns *nodeServer cs *controllerServer - - cap []*csi.VolumeCapability_AccessMode - cscap []*csi.ControllerServiceCapability } type hostPathVolume struct { @@ -67,8 +65,7 @@ var hostPathVolumes map[string]hostPathVolume var hostPathVolumeSnapshots map[string]hostPathSnapshot var ( - hostPathDriver *hostPath - vendorVersion = "dev" + vendorVersion = "dev" ) func init() { @@ -76,52 +73,39 @@ func init() { hostPathVolumeSnapshots = map[string]hostPathSnapshot{} } -func GetHostPathDriver() *hostPath { - return &hostPath{} -} - -func NewIdentityServer(d *csicommon.CSIDriver) *identityServer { - return &identityServer{ - DefaultIdentityServer: csicommon.NewDefaultIdentityServer(d), +func NewHostPathDriver(driverName, nodeID, endpoint string) (*hostPath, error) { + if driverName == "" { + return nil, fmt.Errorf("No driver name provided") } -} -func NewControllerServer(d *csicommon.CSIDriver) *controllerServer { - return &controllerServer{ - DefaultControllerServer: csicommon.NewDefaultControllerServer(d), + if nodeID == "" { + return nil, fmt.Errorf("No node id provided") } -} -func NewNodeServer(d *csicommon.CSIDriver) *nodeServer { - return &nodeServer{ - DefaultNodeServer: csicommon.NewDefaultNodeServer(d), + if endpoint == "" { + return nil, fmt.Errorf("No driver endpoint provided") } -} -func (hp *hostPath) Run(driverName, nodeID, endpoint string) { glog.Infof("Driver: %v ", driverName) glog.Infof("Version: %s", vendorVersion) - // Initialize default library driver - hp.driver = csicommon.NewCSIDriver(driverName, vendorVersion, nodeID) - if hp.driver == nil { - glog.Fatalln("Failed to initialize CSI Driver.") - } - hp.driver.AddControllerServiceCapabilities( - []csi.ControllerServiceCapability_RPC_Type{ - csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, - csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, - csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS, - }) - hp.driver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER}) + return &hostPath{ + name: driverName, + version: vendorVersion, + nodeID: nodeID, + endpoint: endpoint, + }, nil +} + +func (hp *hostPath) Run() { // Create GRPC servers - hp.ids = NewIdentityServer(hp.driver) - hp.ns = NewNodeServer(hp.driver) - hp.cs = NewControllerServer(hp.driver) + hp.ids = NewIdentityServer(hp.name, hp.version) + hp.ns = NewNodeServer(hp.nodeID) + hp.cs = NewControllerServer() - s := csicommon.NewNonBlockingGRPCServer() - s.Start(endpoint, hp.ids, hp.cs, hp.ns) + s := NewNonBlockingGRPCServer() + s.Start(hp.endpoint, hp.ids, hp.cs, hp.ns) s.Wait() } diff --git a/pkg/hostpath/identityserver.go b/pkg/hostpath/identityserver.go index 0f980f30b..24da768b6 100644 --- a/pkg/hostpath/identityserver.go +++ b/pkg/hostpath/identityserver.go @@ -17,9 +17,57 @@ limitations under the License. package hostpath import ( - "github.com/kubernetes-csi/drivers/pkg/csi-common" + "github.com/container-storage-interface/spec/lib/go/csi" + "github.com/golang/glog" + "golang.org/x/net/context" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) type identityServer struct { - *csicommon.DefaultIdentityServer + name string + version string +} + +func NewIdentityServer(name, version string) *identityServer { + return &identityServer{ + name: name, + version: version, + } +} + +func (ids *identityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { + glog.V(5).Infof("Using default GetPluginInfo") + + if ids.name == "" { + return nil, status.Error(codes.Unavailable, "Driver name not configured") + } + + if ids.version == "" { + return nil, status.Error(codes.Unavailable, "Driver is missing version") + } + + return &csi.GetPluginInfoResponse{ + Name: ids.name, + VendorVersion: ids.version, + }, nil +} + +func (ids *identityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { + return &csi.ProbeResponse{}, nil +} + +func (ids *identityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { + glog.V(5).Infof("Using default capabilities") + return &csi.GetPluginCapabilitiesResponse{ + Capabilities: []*csi.PluginCapability{ + { + Type: &csi.PluginCapability_Service_{ + Service: &csi.PluginCapability_Service{ + Type: csi.PluginCapability_Service_CONTROLLER_SERVICE, + }, + }, + }, + }, + }, nil } diff --git a/pkg/hostpath/nodeserver.go b/pkg/hostpath/nodeserver.go index 5e577d446..fbc8eb978 100644 --- a/pkg/hostpath/nodeserver.go +++ b/pkg/hostpath/nodeserver.go @@ -26,12 +26,16 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "k8s.io/kubernetes/pkg/util/mount" - - "github.com/kubernetes-csi/drivers/pkg/csi-common" ) type nodeServer struct { - *csicommon.DefaultNodeServer + nodeID string +} + +func NewNodeServer(nodeId string) *nodeServer { + return &nodeServer{ + nodeID: nodeId, + } } func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { @@ -139,3 +143,29 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag return &csi.NodeUnstageVolumeResponse{}, nil } + +func (ns *nodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { + + return &csi.NodeGetInfoResponse{ + NodeId: ns.nodeID, + }, nil +} + +func (ns *nodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { + + return &csi.NodeGetCapabilitiesResponse{ + Capabilities: []*csi.NodeServiceCapability{ + { + Type: &csi.NodeServiceCapability_Rpc{ + Rpc: &csi.NodeServiceCapability_RPC{ + Type: csi.NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME, + }, + }, + }, + }, + }, nil +} + +func (ns *nodeServer) NodeGetVolumeStats(ctx context.Context, in *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) { + return nil, status.Error(codes.Unimplemented, "") +} diff --git a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/server.go b/pkg/hostpath/server.go similarity index 69% rename from vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/server.go rename to pkg/hostpath/server.go index 9d3c99523..a7690551d 100644 --- a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/server.go +++ b/pkg/hostpath/server.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +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. @@ -14,32 +14,23 @@ See the License for the specific language governing permissions and limitations under the License. */ -package csicommon +package hostpath import ( + "fmt" "net" "os" + "strings" "sync" "github.com/golang/glog" + "golang.org/x/net/context" "google.golang.org/grpc" "github.com/container-storage-interface/spec/lib/go/csi" ) -// Defines Non blocking GRPC server interfaces -type NonBlockingGRPCServer interface { - // Start services at the endpoint - Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) - // Waits for the service to stop - Wait() - // Stops the service gracefully - Stop() - // Stops the service forcefully - ForceStop() -} - -func NewNonBlockingGRPCServer() NonBlockingGRPCServer { +func NewNonBlockingGRPCServer() *nonBlockingGRPCServer { return &nonBlockingGRPCServer{} } @@ -72,14 +63,14 @@ func (s *nonBlockingGRPCServer) ForceStop() { func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) { - proto, addr, err := ParseEndpoint(endpoint) + proto, addr, err := parseEndpoint(endpoint) if err != nil { glog.Fatal(err.Error()) } if proto == "unix" { addr = "/" + addr - if err := os.Remove(addr); err != nil && !os.IsNotExist(err) { + if err := os.Remove(addr); err != nil && !os.IsNotExist(err) { //nolint: vetshadow glog.Fatalf("Failed to remove %s, error: %s", addr, err.Error()) } } @@ -110,3 +101,25 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c server.Serve(listener) } + +func parseEndpoint(ep string) (string, string, error) { + if strings.HasPrefix(strings.ToLower(ep), "unix://") || strings.HasPrefix(strings.ToLower(ep), "tcp://") { + s := strings.SplitN(ep, "://", 2) + if s[1] != "" { + return s[0], s[1], nil + } + } + return "", "", fmt.Errorf("Invalid endpoint: %v", ep) +} + +func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + glog.V(3).Infof("GRPC call: %s", info.FullMethod) + glog.V(5).Infof("GRPC request: %+v", req) + resp, err := handler(ctx, req) + if err != nil { + glog.Errorf("GRPC error: %v", err) + } else { + glog.V(5).Infof("GRPC response: %+v", resp) + } + return resp, err +} diff --git a/vendor/github.com/kubernetes-csi/drivers/LICENSE b/vendor/github.com/kubernetes-csi/drivers/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/vendor/github.com/kubernetes-csi/drivers/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/controllerserver-default.go b/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/controllerserver-default.go deleted file mode 100644 index db72dc2e9..000000000 --- a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/controllerserver-default.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright 2017 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 csicommon - -import ( - "github.com/container-storage-interface/spec/lib/go/csi" - "github.com/golang/glog" - "golang.org/x/net/context" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -type DefaultControllerServer struct { - Driver *CSIDriver -} - -func (cs *DefaultControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (cs *DefaultControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (cs *DefaultControllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (cs *DefaultControllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (cs *DefaultControllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (cs *DefaultControllerServer) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (cs *DefaultControllerServer) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -// ControllerGetCapabilities implements the default GRPC callout. -// Default supports all capabilities -func (cs *DefaultControllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) { - glog.V(5).Infof("Using default ControllerGetCapabilities") - - return &csi.ControllerGetCapabilitiesResponse{ - Capabilities: cs.Driver.cap, - }, nil -} - -func (cs *DefaultControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (cs *DefaultControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (cs *DefaultControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} diff --git a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/driver.go b/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/driver.go deleted file mode 100644 index d20c6c808..000000000 --- a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/driver.go +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright 2017 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 csicommon - -import ( - "fmt" - - "github.com/golang/glog" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/container-storage-interface/spec/lib/go/csi" -) - -type CSIDriver struct { - name string - nodeID string - version string - cap []*csi.ControllerServiceCapability - vc []*csi.VolumeCapability_AccessMode -} - -// Creates a NewCSIDriver object. Assumes vendor version is equal to driver version & -// does not support optional driver plugin info manifest field. Refer to CSI spec for more details. -func NewCSIDriver(name string, v string, nodeID string) *CSIDriver { - if name == "" { - glog.Errorf("Driver name missing") - return nil - } - - if nodeID == "" { - glog.Errorf("NodeID missing") - return nil - } - // TODO version format and validation - if len(v) == 0 { - glog.Errorf("Version argument missing") - return nil - } - - driver := CSIDriver{ - name: name, - version: v, - nodeID: nodeID, - } - - return &driver -} - -func (d *CSIDriver) ValidateControllerServiceRequest(c csi.ControllerServiceCapability_RPC_Type) error { - if c == csi.ControllerServiceCapability_RPC_UNKNOWN { - return nil - } - - for _, cap := range d.cap { - if c == cap.GetRpc().GetType() { - return nil - } - } - return status.Error(codes.InvalidArgument, fmt.Sprintf("%s", c)) -} - -func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceCapability_RPC_Type) { - var csc []*csi.ControllerServiceCapability - - for _, c := range cl { - glog.Infof("Enabling controller service capability: %v", c.String()) - csc = append(csc, NewControllerServiceCapability(c)) - } - - d.cap = csc - - return -} - -func (d *CSIDriver) AddVolumeCapabilityAccessModes(vc []csi.VolumeCapability_AccessMode_Mode) []*csi.VolumeCapability_AccessMode { - var vca []*csi.VolumeCapability_AccessMode - for _, c := range vc { - glog.Infof("Enabling volume access mode: %v", c.String()) - vca = append(vca, NewVolumeCapabilityAccessMode(c)) - } - d.vc = vca - return vca -} - -func (d *CSIDriver) GetVolumeCapabilityAccessModes() []*csi.VolumeCapability_AccessMode { - return d.vc -} diff --git a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/identityserver-default.go b/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/identityserver-default.go deleted file mode 100644 index b16b67c09..000000000 --- a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/identityserver-default.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2017 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 csicommon - -import ( - "github.com/container-storage-interface/spec/lib/go/csi" - "github.com/golang/glog" - "golang.org/x/net/context" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -type DefaultIdentityServer struct { - Driver *CSIDriver -} - -func (ids *DefaultIdentityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { - glog.V(5).Infof("Using default GetPluginInfo") - - if ids.Driver.name == "" { - return nil, status.Error(codes.Unavailable, "Driver name not configured") - } - - if ids.Driver.version == "" { - return nil, status.Error(codes.Unavailable, "Driver is missing version") - } - - return &csi.GetPluginInfoResponse{ - Name: ids.Driver.name, - VendorVersion: ids.Driver.version, - }, nil -} - -func (ids *DefaultIdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { - return &csi.ProbeResponse{}, nil -} - -func (ids *DefaultIdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { - glog.V(5).Infof("Using default capabilities") - return &csi.GetPluginCapabilitiesResponse{ - Capabilities: []*csi.PluginCapability{ - { - Type: &csi.PluginCapability_Service_{ - Service: &csi.PluginCapability_Service{ - Type: csi.PluginCapability_Service_CONTROLLER_SERVICE, - }, - }, - }, - }, - }, nil -} diff --git a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/nodeserver-default.go b/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/nodeserver-default.go deleted file mode 100644 index cd2355bf2..000000000 --- a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/nodeserver-default.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2017 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 csicommon - -import ( - "github.com/container-storage-interface/spec/lib/go/csi" - "github.com/golang/glog" - "golang.org/x/net/context" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -type DefaultNodeServer struct { - Driver *CSIDriver -} - -func (ns *DefaultNodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (ns *DefaultNodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} - -func (ns *DefaultNodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { - glog.V(5).Infof("Using default NodeGetInfo") - - return &csi.NodeGetInfoResponse{ - NodeId: ns.Driver.nodeID, - }, nil -} - -func (ns *DefaultNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { - glog.V(5).Infof("Using default NodeGetCapabilities") - - return &csi.NodeGetCapabilitiesResponse{ - Capabilities: []*csi.NodeServiceCapability{ - { - Type: &csi.NodeServiceCapability_Rpc{ - Rpc: &csi.NodeServiceCapability_RPC{ - Type: csi.NodeServiceCapability_RPC_UNKNOWN, - }, - }, - }, - }, - }, nil -} - -func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, in *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) { - return nil, status.Error(codes.Unimplemented, "") -} diff --git a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/utils.go b/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/utils.go deleted file mode 100644 index 382e81cdc..000000000 --- a/vendor/github.com/kubernetes-csi/drivers/pkg/csi-common/utils.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright 2017 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 csicommon - -import ( - "fmt" - "strings" - - "github.com/container-storage-interface/spec/lib/go/csi" - "github.com/golang/glog" - "golang.org/x/net/context" - "google.golang.org/grpc" -) - -func ParseEndpoint(ep string) (string, string, error) { - if strings.HasPrefix(strings.ToLower(ep), "unix://") || strings.HasPrefix(strings.ToLower(ep), "tcp://") { - s := strings.SplitN(ep, "://", 2) - if s[1] != "" { - return s[0], s[1], nil - } - } - return "", "", fmt.Errorf("Invalid endpoint: %v", ep) -} - -func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode { - return &csi.VolumeCapability_AccessMode{Mode: mode} -} - -func NewDefaultNodeServer(d *CSIDriver) *DefaultNodeServer { - return &DefaultNodeServer{ - Driver: d, - } -} - -func NewDefaultIdentityServer(d *CSIDriver) *DefaultIdentityServer { - return &DefaultIdentityServer{ - Driver: d, - } -} - -func NewDefaultControllerServer(d *CSIDriver) *DefaultControllerServer { - return &DefaultControllerServer{ - Driver: d, - } -} - -func NewControllerServiceCapability(cap csi.ControllerServiceCapability_RPC_Type) *csi.ControllerServiceCapability { - return &csi.ControllerServiceCapability{ - Type: &csi.ControllerServiceCapability_Rpc{ - Rpc: &csi.ControllerServiceCapability_RPC{ - Type: cap, - }, - }, - } -} - -func RunNodePublishServer(endpoint string, d *CSIDriver, ns csi.NodeServer) { - ids := NewDefaultIdentityServer(d) - - s := NewNonBlockingGRPCServer() - s.Start(endpoint, ids, nil, ns) - s.Wait() -} - -func RunControllerPublishServer(endpoint string, d *CSIDriver, cs csi.ControllerServer) { - ids := NewDefaultIdentityServer(d) - - s := NewNonBlockingGRPCServer() - s.Start(endpoint, ids, cs, nil) - s.Wait() -} - -func RunControllerandNodePublishServer(endpoint string, d *CSIDriver, cs csi.ControllerServer, ns csi.NodeServer) { - ids := NewDefaultIdentityServer(d) - - s := NewNonBlockingGRPCServer() - s.Start(endpoint, ids, cs, ns) - s.Wait() -} - -func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - glog.V(3).Infof("GRPC call: %s", info.FullMethod) - glog.V(5).Infof("GRPC request: %+v", req) - resp, err := handler(ctx, req) - if err != nil { - glog.Errorf("GRPC error: %v", err) - } else { - glog.V(5).Infof("GRPC response: %+v", resp) - } - return resp, err -} From c8544f2228bfeb44597d02b3950decae99baca5c Mon Sep 17 00:00:00 2001 From: Amarnath Valluri Date: Wed, 13 Feb 2019 10:50:36 +0200 Subject: [PATCH 2/2] Using protosanitizer while logging gRPC request/response protosanitizer supports stripping secrets from requests while logging. Signed-off-by: Amarnath Valluri --- Gopkg.lock | 12 +- pkg/hostpath/server.go | 5 +- .../golang/protobuf/descriptor/descriptor.go | 93 ++++++++ .../kubernetes-csi/csi-lib-utils/LICENSE | 201 ++++++++++++++++++ .../protosanitizer/protosanitizer.go | 177 +++++++++++++++ .../csi-lib-utils/release-tools/LICENSE | 201 ++++++++++++++++++ 6 files changed, 686 insertions(+), 3 deletions(-) create mode 100644 vendor/github.com/golang/protobuf/descriptor/descriptor.go create mode 100644 vendor/github.com/kubernetes-csi/csi-lib-utils/LICENSE create mode 100644 vendor/github.com/kubernetes-csi/csi-lib-utils/protosanitizer/protosanitizer.go create mode 100644 vendor/github.com/kubernetes-csi/csi-lib-utils/release-tools/LICENSE diff --git a/Gopkg.lock b/Gopkg.lock index 2c542c6e0..7507907f5 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -18,9 +18,10 @@ revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" [[projects]] - digest = "1:588beb9f80d2b0afddf05663b32d01c867da419458b560471d81cca0286e76b8" + digest = "1:9cab16c200148edbdc9f314f69bf71987085f618ec107385bd6634be21d1aae8" name = "github.com/golang/protobuf" packages = [ + "descriptor", "proto", "protoc-gen-go/descriptor", "ptypes", @@ -41,6 +42,14 @@ revision = "d460ce9f8df2e77fb1ba55ca87fafed96c607494" version = "v1.0.0" +[[projects]] + digest = "1:5f039a8e43dc5b00adee7b38e39baf6c36f607372940c11975f00ec9c5f298ae" + name = "github.com/kubernetes-csi/csi-lib-utils" + packages = ["protosanitizer"] + pruneopts = "UT" + revision = "763b95da1f9f7804ffe5e33f9aee5debf4517adf" + version = "v0.3.0" + [[projects]] digest = "1:e5d0bd87abc2781d14e274807a470acd180f0499f8bf5bb18606e9ec22ad9de9" name = "github.com/pborman/uuid" @@ -176,6 +185,7 @@ "github.com/golang/glog", "github.com/golang/protobuf/ptypes", "github.com/golang/protobuf/ptypes/timestamp", + "github.com/kubernetes-csi/csi-lib-utils/protosanitizer", "github.com/pborman/uuid", "golang.org/x/net/context", "google.golang.org/grpc", diff --git a/pkg/hostpath/server.go b/pkg/hostpath/server.go index a7690551d..157015482 100644 --- a/pkg/hostpath/server.go +++ b/pkg/hostpath/server.go @@ -28,6 +28,7 @@ import ( "google.golang.org/grpc" "github.com/container-storage-interface/spec/lib/go/csi" + "github.com/kubernetes-csi/csi-lib-utils/protosanitizer" ) func NewNonBlockingGRPCServer() *nonBlockingGRPCServer { @@ -114,12 +115,12 @@ func parseEndpoint(ep string) (string, string, error) { func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { glog.V(3).Infof("GRPC call: %s", info.FullMethod) - glog.V(5).Infof("GRPC request: %+v", req) + glog.V(5).Infof("GRPC request: %+v", protosanitizer.StripSecrets(req)) resp, err := handler(ctx, req) if err != nil { glog.Errorf("GRPC error: %v", err) } else { - glog.V(5).Infof("GRPC response: %+v", resp) + glog.V(5).Infof("GRPC response: %+v", protosanitizer.StripSecrets(resp)) } return resp, err } diff --git a/vendor/github.com/golang/protobuf/descriptor/descriptor.go b/vendor/github.com/golang/protobuf/descriptor/descriptor.go new file mode 100644 index 000000000..ac7e51bfb --- /dev/null +++ b/vendor/github.com/golang/protobuf/descriptor/descriptor.go @@ -0,0 +1,93 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Package descriptor provides functions for obtaining protocol buffer +// descriptors for generated Go types. +// +// These functions cannot go in package proto because they depend on the +// generated protobuf descriptor messages, which themselves depend on proto. +package descriptor + +import ( + "bytes" + "compress/gzip" + "fmt" + "io/ioutil" + + "github.com/golang/protobuf/proto" + protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" +) + +// extractFile extracts a FileDescriptorProto from a gzip'd buffer. +func extractFile(gz []byte) (*protobuf.FileDescriptorProto, error) { + r, err := gzip.NewReader(bytes.NewReader(gz)) + if err != nil { + return nil, fmt.Errorf("failed to open gzip reader: %v", err) + } + defer r.Close() + + b, err := ioutil.ReadAll(r) + if err != nil { + return nil, fmt.Errorf("failed to uncompress descriptor: %v", err) + } + + fd := new(protobuf.FileDescriptorProto) + if err := proto.Unmarshal(b, fd); err != nil { + return nil, fmt.Errorf("malformed FileDescriptorProto: %v", err) + } + + return fd, nil +} + +// Message is a proto.Message with a method to return its descriptor. +// +// Message types generated by the protocol compiler always satisfy +// the Message interface. +type Message interface { + proto.Message + Descriptor() ([]byte, []int) +} + +// ForMessage returns a FileDescriptorProto and a DescriptorProto from within it +// describing the given message. +func ForMessage(msg Message) (fd *protobuf.FileDescriptorProto, md *protobuf.DescriptorProto) { + gz, path := msg.Descriptor() + fd, err := extractFile(gz) + if err != nil { + panic(fmt.Sprintf("invalid FileDescriptorProto for %T: %v", msg, err)) + } + + md = fd.MessageType[path[0]] + for _, i := range path[1:] { + md = md.NestedType[i] + } + return fd, md +} diff --git a/vendor/github.com/kubernetes-csi/csi-lib-utils/LICENSE b/vendor/github.com/kubernetes-csi/csi-lib-utils/LICENSE new file mode 100644 index 000000000..8dada3eda --- /dev/null +++ b/vendor/github.com/kubernetes-csi/csi-lib-utils/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/vendor/github.com/kubernetes-csi/csi-lib-utils/protosanitizer/protosanitizer.go b/vendor/github.com/kubernetes-csi/csi-lib-utils/protosanitizer/protosanitizer.go new file mode 100644 index 000000000..af64a7b27 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/csi-lib-utils/protosanitizer/protosanitizer.go @@ -0,0 +1,177 @@ +/* +Copyright 2018 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 protosanitizer supports logging of gRPC messages without +// accidentally revealing sensitive fields. +package protosanitizer + +import ( + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" + protobufdescriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" +) + +// StripSecrets returns a wrapper around the original CSI gRPC message +// which has a Stringer implementation that serializes the message +// as one-line JSON, but without including secret information. +// Instead of the secret value(s), the string "***stripped***" is +// included in the result. +// +// StripSecrets relies on an extension in CSI 1.0 and thus can only +// be used for messages based on that or a more recent spec! +// +// StripSecrets itself is fast and therefore it is cheap to pass the +// result to logging functions which may or may not end up serializing +// the parameter depending on the current log level. +func StripSecrets(msg interface{}) fmt.Stringer { + return &stripSecrets{msg, isCSI1Secret} +} + +// StripSecretsCSI03 is like StripSecrets, except that it works +// for messages based on CSI 0.3 and older. It does not work +// for CSI 1.0, use StripSecrets for that. +func StripSecretsCSI03(msg interface{}) fmt.Stringer { + return &stripSecrets{msg, isCSI03Secret} +} + +type stripSecrets struct { + msg interface{} + + isSecretField func(field *protobuf.FieldDescriptorProto) bool +} + +func (s *stripSecrets) String() string { + // First convert to a generic representation. That's less efficient + // than using reflect directly, but easier to work with. + var parsed interface{} + b, err := json.Marshal(s.msg) + if err != nil { + return fmt.Sprintf("<>", s.msg, err) + } + if err := json.Unmarshal(b, &parsed); err != nil { + return fmt.Sprintf("<>", s.msg, err) + } + + // Now remove secrets from the generic representation of the message. + s.strip(parsed, s.msg) + + // Re-encoded the stripped representation and return that. + b, err = json.Marshal(parsed) + if err != nil { + return fmt.Sprintf("<>", s.msg, err) + } + return string(b) +} + +func (s *stripSecrets) strip(parsed interface{}, msg interface{}) { + protobufMsg, ok := msg.(descriptor.Message) + if !ok { + // Not a protobuf message, so we are done. + return + } + + // The corresponding map in the parsed JSON representation. + parsedFields, ok := parsed.(map[string]interface{}) + if !ok { + // Probably nil. + return + } + + // Walk through all fields and replace those with ***stripped*** that + // are marked as secret. This relies on protobuf adding "json:" tags + // on each field where the name matches the field name in the protobuf + // spec (like volume_capabilities). The field.GetJsonName() method returns + // a different name (volumeCapabilities) which we don't use. + _, md := descriptor.ForMessage(protobufMsg) + fields := md.GetField() + if fields != nil { + for _, field := range fields { + if s.isSecretField(field) { + // Overwrite only if already set. + if _, ok := parsedFields[field.GetName()]; ok { + parsedFields[field.GetName()] = "***stripped***" + } + } else if field.GetType() == protobuf.FieldDescriptorProto_TYPE_MESSAGE { + // When we get here, + // the type name is something like ".csi.v1.CapacityRange" (leading dot!) + // and looking up "csi.v1.CapacityRange" + // returns the type of a pointer to a pointer + // to CapacityRange. We need a pointer to such + // a value for recursive stripping. + typeName := field.GetTypeName() + if strings.HasPrefix(typeName, ".") { + typeName = typeName[1:] + } + t := proto.MessageType(typeName) + if t == nil || t.Kind() != reflect.Ptr { + // Shouldn't happen, but + // better check anyway instead + // of panicking. + continue + } + v := reflect.New(t.Elem()) + + // Recursively strip the message(s) that + // the field contains. + i := v.Interface() + entry := parsedFields[field.GetName()] + if slice, ok := entry.([]interface{}); ok { + // Array of values, like VolumeCapabilities in CreateVolumeRequest. + for _, entry := range slice { + s.strip(entry, i) + } + } else { + // Single value. + s.strip(entry, i) + } + } + } + } +} + +// isCSI1Secret uses the csi.E_CsiSecret extension from CSI 1.0 to +// determine whether a field contains secrets. +func isCSI1Secret(field *protobuf.FieldDescriptorProto) bool { + ex, err := proto.GetExtension(field.Options, e_CsiSecret) + return err == nil && ex != nil && *ex.(*bool) +} + +// Copied from the CSI 1.0 spec (https://github.com/container-storage-interface/spec/blob/37e74064635d27c8e33537c863b37ccb1182d4f8/lib/go/csi/csi.pb.go#L4520-L4527) +// to avoid a package dependency that would prevent usage of this package +// in repos using an older version of the spec. +// +// Future revision of the CSI spec must not change this extensions, otherwise +// they will break filtering in binaries based on the 1.0 version of the spec. +var e_CsiSecret = &proto.ExtensionDesc{ + ExtendedType: (*protobufdescriptor.FieldOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 1059, + Name: "csi.v1.csi_secret", + Tag: "varint,1059,opt,name=csi_secret,json=csiSecret", + Filename: "github.com/container-storage-interface/spec/csi.proto", +} + +// isCSI03Secret relies on the naming convention in CSI <= 0.3 +// to determine whether a field contains secrets. +func isCSI03Secret(field *protobuf.FieldDescriptorProto) bool { + return strings.HasSuffix(field.GetName(), "_secrets") +} diff --git a/vendor/github.com/kubernetes-csi/csi-lib-utils/release-tools/LICENSE b/vendor/github.com/kubernetes-csi/csi-lib-utils/release-tools/LICENSE new file mode 100644 index 000000000..8dada3eda --- /dev/null +++ b/vendor/github.com/kubernetes-csi/csi-lib-utils/release-tools/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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.