Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
87c7df6
Squashed 'release-tools/' changes from bc0504ad..6616a6b5
pohly May 5, 2021
8421cd9
Merge commit '38af8d2026bafc418acd9f77965d327b61f184eb' into prow-upd…
pohly May 5, 2021
d8840a6
Merge pull request #302 from pohly/prow-update-master
k8s-ci-robot May 5, 2021
642bf04
Merge pull request #304 from Jiawei0227/panic
k8s-ci-robot May 6, 2021
75b09fa
Squashed 'release-tools/' changes from 6616a6b5..f3255906
pohly May 21, 2021
91bf4c1
Merge commit '30c86166317e93071f74f5e450771aceeb7a9dcc' into prow-upd…
pohly May 21, 2021
86e000b
OWNERS update with aliases
pohly May 21, 2021
d6c2e72
Merge pull request #309 from pohly/prow-update-master
k8s-ci-robot May 25, 2021
5d5fea8
Use CSI spec v1.5.0
chrishenzie Jun 14, 2021
9193818
Merge pull request #312 from chrishenzie/csi-spec-v1.5.0
k8s-ci-robot Jun 14, 2021
eaab87c
Add command line arguments to configure leader election options
RaunakShah Jun 23, 2021
29bc0f8
Merge pull request #313 from RaunakShah/le_config
k8s-ci-robot Jun 24, 2021
7b4a543
Squashed 'release-tools/' changes from f3255906..c0a4fb1d
pohly Jul 6, 2021
6d2ad69
Merge commit '35c8d0d52eab755a13e5cba50b1fc2187b5f1e6d' into prow-upd…
pohly Jul 6, 2021
f862bd4
Merge pull request #315 from pohly/prow-update-master
k8s-ci-robot Jul 12, 2021
2e0921e
Update k8s dependencies to v1.22.0-rc.0
chrishenzie Jul 27, 2021
f523b0f
Merge pull request #317 from chrishenzie/k8s-v1.22
k8s-ci-robot Jul 28, 2021
67cf03d
reuse same CSI controller client
Jul 31, 2021
0691388
Merge pull request #318 from yeya24/use-csi-client
k8s-ci-robot Aug 4, 2021
f9d0163
Update k8s dependencies to v1.22.0
chrishenzie Jul 28, 2021
8d88873
Update README for compatible CSI spec, K8s feature status
chrishenzie Aug 4, 2021
5840385
Merge pull request #321 from chrishenzie/k8s-v1.22
k8s-ci-robot Aug 5, 2021
a2bc5ed
Consolidate controller capability checks
chrishenzie Jul 27, 2021
bbc9af1
Map PV access modes to CSI access modes based on driver capability
chrishenzie Mar 12, 2021
6718e0b
Merge pull request #308 from chrishenzie/single-node-access-modes
k8s-ci-robot Aug 5, 2021
f0410ec
Add CHANGELOG for v3.3.0
jsafrane Aug 5, 2021
ac8c4de
Merge pull request #323 from jsafrane/release-3.3
k8s-ci-robot Aug 9, 2021
2180e1b
Merge tag 'v3.3.0' into rebase-v3.3.0
dobsonj Aug 18, 2021
842885d
Update OWNERS_ALIASES
dobsonj Aug 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
211 changes: 211 additions & 0 deletions CHANGELOG/CHANGELOG-3.3.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# See the OWNERS docs at https://go.k8s.io/owners

approvers:
- openshift-storage-maintainers
component: "Storage"
2 changes: 1 addition & 1 deletion OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ aliases:
- tsmetana
- gnufied
- bertinatto
- huffmanca
- dobsonj
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This information reflects the head of this branch.

| Compatible with CSI Version | Container Image | [Min K8s Version](https://kubernetes-csi.github.io/docs/kubernetes-compatibility.html#minimum-version) | [Recommended K8s Version](https://kubernetes-csi.github.io/docs/kubernetes-compatibility.html#recommended-version) |
| ------------------------------------------------------------------------------------------ | ------------------------------------| ---- | ---- |
| [CSI Spec v1.2.0](https://github.com/container-storage-interface/spec/releases/tag/v1.2.0) | k8s.gcr.io/sig-storage/csi-attacher | 1.17 | 1.17 |
| [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/csi-attacher | 1.17 | 1.22 |

## Feature Status

Expand All @@ -32,7 +32,8 @@ The following table reflects the head of this branch.

| Feature | Status | Default | Description |
| ------------- | ------- | ------- | --------------------------------------------------------------------------------------------- |
| CSIMigration* | Beta | On | [Migrating in-tree volume plugins to CSI](https://kubernetes.io/docs/concepts/storage/volumes/#csi-migration). |
| CSIMigration* | Beta | On | [Migrating in-tree volume plugins to CSI](https://kubernetes.io/docs/concepts/storage/volumes/#csi-migration). |
| ReadWriteOncePod* | Alpha | Off | [Single pod access mode for PersistentVolumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes). |

*) There is no special feature gate for this feature. It is enabled by turning on the corresponding features in Kubernetes.

Expand Down Expand Up @@ -78,6 +79,12 @@ Note that the external-attacher does not scale with more replicas. Only one exte

* `--kube-api-burst`: The number of requests to the Kubernetes API server, exceeding the QPS, that can be sent at any given time. Defaults to `10`.

* `--leader-election-lease-duration <duration>`: Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.

* `--leader-election-renew-deadline <duration>`: Duration, in seconds, that the acting leader will retry refreshing leadership before giving up. Defaults to 10 seconds.

* `--leader-election-retry-period <duration>`: Duration, in seconds, the LeaderElector clients should wait between tries of actions. Defaults to 5 seconds.

#### Other recognized arguments

* `--kubeconfig <path>`: Path to Kubernetes client configuration that the external-attacher uses to connect to Kubernetes API server. When omitted, default token provided by Kubernetes will be used. This option is useful only when the external-attacher does not run as a Kubernetes pod, e.g. for debugging.
Expand Down
66 changes: 40 additions & 26 deletions cmd/csi-attacher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ var (
retryIntervalStart = flag.Duration("retry-interval-start", time.Second, "Initial retry interval of failed create volume or deletion. It doubles with each failure, up to retry-interval-max.")
retryIntervalMax = flag.Duration("retry-interval-max", 5*time.Minute, "Maximum retry interval of failed create volume or deletion.")

enableLeaderElection = flag.Bool("leader-election", false, "Enable leader election.")
leaderElectionNamespace = flag.String("leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set.")
enableLeaderElection = flag.Bool("leader-election", false, "Enable leader election.")
leaderElectionNamespace = flag.String("leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set.")
leaderElectionLeaseDuration = flag.Duration("leader-election-lease-duration", 15*time.Second, "Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.")
leaderElectionRenewDeadline = flag.Duration("leader-election-renew-deadline", 10*time.Second, "Duration, in seconds, that the acting leader will retry refreshing leadership before giving up. Defaults to 10 seconds.")
leaderElectionRetryPeriod = flag.Duration("leader-election-retry-period", 5*time.Second, "Duration, in seconds, the LeaderElector clients should wait between tries of actions. Defaults to 5 seconds.")

reconcileSync = flag.Duration("reconcile-sync", 1*time.Minute, "Resync interval of the VolumeAttachment reconciler.")

Expand Down Expand Up @@ -188,36 +191,50 @@ func main() {
klog.Error(err.Error())
os.Exit(1)
}

var (
supportsAttach bool
supportsReadOnly bool
supportsListVolumesPublishedNodes bool
supportsSingleNodeMultiWriter bool
)
if !supportsService {
handler = controller.NewTrivialHandler(clientset)
klog.V(2).Infof("CSI driver does not support Plugin Controller Service, using trivial handler")
} else {
// Find out if the driver supports attach/detach.
supportsAttach, supportsReadOnly, err := supportsControllerPublish(ctx, csiConn)
supportsAttach, supportsReadOnly, supportsListVolumesPublishedNodes, supportsSingleNodeMultiWriter, err = supportsControllerCapabilities(ctx, csiConn)
if err != nil {
klog.Error(err.Error())
os.Exit(1)
}

if supportsAttach {
pvLister := factory.Core().V1().PersistentVolumes().Lister()
vaLister := factory.Storage().V1().VolumeAttachments().Lister()
csiNodeLister := factory.Storage().V1().CSINodes().Lister()
volAttacher := attacher.NewAttacher(csiConn)
CSIVolumeLister := attacher.NewVolumeLister(csiConn)
handler = controller.NewCSIHandler(clientset, csiAttacher, volAttacher, CSIVolumeLister, pvLister, csiNodeLister, vaLister, timeout, supportsReadOnly, csitrans.New())
handler = controller.NewCSIHandler(
clientset,
csiAttacher,
volAttacher,
CSIVolumeLister,
pvLister,
csiNodeLister,
vaLister,
timeout,
supportsReadOnly,
supportsSingleNodeMultiWriter,
csitrans.New(),
)
klog.V(2).Infof("CSI driver supports ControllerPublishUnpublish, using real CSI handler")
} else {
handler = controller.NewTrivialHandler(clientset)
klog.V(2).Infof("CSI driver does not support ControllerPublishUnpublish, using trivial handler")
}
}

slvpn, err := supportsListVolumesPublishedNodes(ctx, csiConn)
if err != nil {
klog.Errorf("Failed to check if driver supports ListVolumesPublishedNodes, assuming it does not: %v", err)
}

if slvpn {
if supportsListVolumesPublishedNodes {
klog.V(2).Infof("CSI driver supports list volumes published nodes. Using capability to reconcile volume attachment objects with actual backend state")
}

Expand All @@ -229,7 +246,7 @@ func main() {
factory.Core().V1().PersistentVolumes(),
workqueue.NewItemExponentialFailureRateLimiter(*retryIntervalStart, *retryIntervalMax),
workqueue.NewItemExponentialFailureRateLimiter(*retryIntervalStart, *retryIntervalMax),
slvpn,
supportsListVolumesPublishedNodes,
*reconcileSync,
)

Expand Down Expand Up @@ -261,6 +278,10 @@ func main() {
le.WithNamespace(*leaderElectionNamespace)
}

le.WithLeaseDuration(*leaderElectionLeaseDuration)
le.WithRenewDeadline(*leaderElectionRenewDeadline)
le.WithRetryPeriod(*leaderElectionRetryPeriod)

if err := le.Run(); err != nil {
klog.Fatalf("failed to initialize leader election: %v", err)
}
Expand All @@ -274,24 +295,17 @@ func buildConfig(kubeconfig string) (*rest.Config, error) {
return rest.InClusterConfig()
}

func supportsControllerPublish(ctx context.Context, csiConn *grpc.ClientConn) (supportsControllerPublish bool, supportsPublishReadOnly bool, err error) {
caps, err := rpc.GetControllerCapabilities(ctx, csiConn)
if err != nil {
return false, false, err
}

supportsControllerPublish = caps[csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME]
supportsPublishReadOnly = caps[csi.ControllerServiceCapability_RPC_PUBLISH_READONLY]
return supportsControllerPublish, supportsPublishReadOnly, nil
}

func supportsListVolumesPublishedNodes(ctx context.Context, csiConn *grpc.ClientConn) (bool, error) {
func supportsControllerCapabilities(ctx context.Context, csiConn *grpc.ClientConn) (bool, bool, bool, bool, error) {
caps, err := rpc.GetControllerCapabilities(ctx, csiConn)
if err != nil {
return false, fmt.Errorf("failed to get controller capabilities: %v", err)
return false, false, false, false, err
}

return caps[csi.ControllerServiceCapability_RPC_LIST_VOLUMES] && caps[csi.ControllerServiceCapability_RPC_LIST_VOLUMES_PUBLISHED_NODES], nil
supportsControllerPublish := caps[csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME]
supportsPublishReadOnly := caps[csi.ControllerServiceCapability_RPC_PUBLISH_READONLY]
supportsListVolumesPublishedNodes := caps[csi.ControllerServiceCapability_RPC_LIST_VOLUMES] && caps[csi.ControllerServiceCapability_RPC_LIST_VOLUMES_PUBLISHED_NODES]
supportsSingleNodeMultiWriter := caps[csi.ControllerServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER]
return supportsControllerPublish, supportsPublishReadOnly, supportsListVolumesPublishedNodes, supportsSingleNodeMultiWriter, nil
}

func supportsPluginControllerService(ctx context.Context, csiConn *grpc.ClientConn) (bool, error) {
Expand Down
44 changes: 10 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,22 @@ module github.com/kubernetes-csi/external-attacher
go 1.16

require (
github.com/container-storage-interface/spec v1.4.0
github.com/container-storage-interface/spec v1.5.0
github.com/davecgh/go-spew v1.1.1
github.com/evanphx/json-patch v4.9.0+incompatible
github.com/evanphx/json-patch v4.11.0+incompatible
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.5.1
github.com/golang/protobuf v1.5.2
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gnostic v0.5.4 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/kubernetes-csi/csi-lib-utils v0.9.1
github.com/kubernetes-csi/csi-lib-utils v0.10.0
github.com/kubernetes-csi/csi-test/v4 v4.0.2
github.com/prometheus/client_golang v1.9.0 // indirect
github.com/prometheus/common v0.19.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 // indirect
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84 // indirect
golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210317182105-75c7a8546eb9 // indirect
google.golang.org/grpc v1.36.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.21.0
k8s.io/apimachinery v0.21.0
k8s.io/client-go v0.21.0
k8s.io/component-base v0.21.0 // indirect
k8s.io/csi-translation-lib v0.21.0
k8s.io/klog/v2 v2.8.0
k8s.io/kube-openapi v0.0.0-20210305164622-f622666832c1 // indirect
k8s.io/utils v0.0.0-20210305010621-2afb4311ab10 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.1 // indirect
google.golang.org/grpc v1.38.0
k8s.io/api v0.22.0
k8s.io/apimachinery v0.22.0
k8s.io/client-go v0.22.0
k8s.io/csi-translation-lib v0.22.0
k8s.io/klog/v2 v2.9.0
)

replace k8s.io/component-base => k8s.io/component-base v0.21.0

replace k8s.io/node-api => k8s.io/node-api v0.21.0

replace k8s.io/api => k8s.io/api v0.21.0

replace k8s.io/apimachinery => k8s.io/apimachinery v0.21.0

replace k8s.io/client-go => k8s.io/client-go v0.21.0

replace k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.21.0
Loading