Skip to content

Commit

Permalink
Merge pull request #997 from siyanshen/revert-981-cherry-pick-973-to-…
Browse files Browse the repository at this point in the history
…release-1.7

Revert "[release-1.7] Create standalone lock release controller"
  • Loading branch information
k8s-ci-robot authored Nov 6, 2024
2 parents ee5a67d + 75c84c7 commit 76c1775
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 523 deletions.
31 changes: 0 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# Core Filestore CSI driver binary
DRIVERBINARY=gcp-filestore-csi-driver
WEBHOOKBINARY=gcp-filestore-csi-driver-webhook
LOCKRELEASEBINARY=gcp-filestore-csi-driver-lockrelease
$(info PULL_BASE_REF is $(PULL_BASE_REF))
$(info PWD is $(PWD))

Expand Down Expand Up @@ -46,15 +45,6 @@ else
endif
$(info WEBHOOK_STAGINGIMAGE is $(WEBHOOK_STAGINGIMAGE))

LOCKRELEASE_STAGINGIMAGE=
ifdef GCP_FS_CSI_LOCKRELEASE_STAGING_IMAGE
LOCKRELEASE_STAGINGIMAGE=$(GCP_FS_CSI_LOCKRELEASE_STAGING_IMAGE)
else
LOCKRELEASE_STAGINGIMAGE=gcr.io/$(PROJECT)/gcp-filestore-csi-driver-lockrelease
endif
$(info LOCKRELEASE_STAGINGIMAGE is $(LOCKRELEASE_STAGINGIMAGE))


BINDIR?=bin

# This flag is used only for csi-client and windows.
Expand Down Expand Up @@ -152,27 +142,6 @@ build-and-push-multi-arch: build-image-and-push-linux-arm64 build-image-and-push
docker manifest create --amend $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux_amd64 $(STAGINGIMAGE):$(STAGINGVERSION)_linux_arm64
docker manifest push -p $(STAGINGIMAGE):$(STAGINGVERSION)

# Build the go binary for the CSI driver lock release controller.
lockrelease:
mkdir -p ${BINDIR}
{ \
set -e ; \
CGO_ENABLED=0 go build -mod=vendor -a -ldflags '-X main.version=$(STAGINGVERSION) -extldflags "-static"' -o ${BINDIR}/${LOCKRELEASEBINARY} ./cmd/lockrelease/; \
}

# Build the docker image for the lock release controller.
lockrelease-image: init-buildx
{ \
set -e ; \
docker buildx build \
--platform linux/amd64 \
--build-arg STAGINGVERSION=$(STAGINGVERSION) \
--build-arg BUILDPLATFORM=linux/amd64 \
--build-arg TARGETPLATFORM=linux/amd64 \
-f ./cmd/lockrelease/Dockerfile \
-t $(LOCKRELEASE_STAGINGIMAGE):$(STAGINGVERSION) --push .; \
}

# Build the go binary for the CSI driver.
# STAGINGVERSION may contain multiple tags (e.g. canary, vX.Y.Z etc). Use one of the tags
# for setting the driver version variable. For convenience we are using the first value.
Expand Down
26 changes: 0 additions & 26 deletions cmd/lockrelease/Dockerfile

This file was deleted.

122 changes: 0 additions & 122 deletions cmd/lockrelease/main.go

This file was deleted.

4 changes: 3 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ var (
resourceTagsStr = flag.String("resource-tags", "", "Resource tags to attach to each volume created. It is a comma separated list of tags of the form '<parentID_1>/<tagKey_1>/<tagValue_1>...<parentID_N>/<tagKey_N>/<tagValue_N>' where, parentID is the ID of Organization or Project resource where tag key and value resources exist, tagKey is the shortName of the tag key resource, tagValue is the shortName of the tag value resource. See https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing for more details.")

// Feature lock release specific parameters, only take effect when feature-lock-release is set to true.
featureLockRelease = flag.Bool("feature-lock-release", false, "if set to true, the node driver will support Filestore lock release.")
featureLockRelease = flag.Bool("feature-lock-release", false, "if set to true, the node driver will support Filestore lock release.")
lockReleaseSyncPeriod = flag.Duration("lock-release-sync-period", 60*time.Second, "Duration, in seconds, the sync period of the lock release controller. Defaults to 60 seconds.")

// Feature configurable shares per Filestore instance specific parameters.
featureMaxSharePerInstance = flag.Bool("feature-max-shares-per-instance", false, "If this feature flag is enabled, allows the user to configure max shares packed per Filestore instance")
Expand Down Expand Up @@ -170,6 +171,7 @@ func main() {
LeaseDuration: *leaderElectionLeaseDuration,
RenewDeadline: *leaderElectionRenewDeadline,
RetryPeriod: *leaderElectionRetryPeriod,
SyncPeriod: *lockReleaseSyncPeriod,
MetricEndpoint: *httpEndpoint,
MetricPath: *metricsPath,
},
Expand Down
44 changes: 17 additions & 27 deletions deploy/kubernetes/overlays/lockrelease/configmap_rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ metadata:
name: gke-managed-filestorecsi

---
##### Lock release controller Service Account, Roles, RoleBindings
apiVersion: v1
kind: ServiceAccount
metadata:
name: filestore-lockrelease-controller-sa
namespace: gcp-filestore-csi-driver
---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
Expand All @@ -23,6 +16,21 @@ rules:

---

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: filestorecsi-node-driver-cluster-role-binding
subjects:
- kind: ServiceAccount
name: gcp-filestore-csi-node-sa
namespace: gcp-filestore-csi-driver
roleRef:
kind: ClusterRole
name: filestorecsi-node-driver-cluster-role
apiGroup: rbac.authorization.k8s.io

---

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand All @@ -31,7 +39,7 @@ metadata:
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "update", "create"]
verbs: ["get", "list", "update", "create"]

---

Expand All @@ -47,29 +55,14 @@ rules:

---

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: filestorecsi-lockrelease-controller-cluster-role-binding
subjects:
- kind: ServiceAccount
name: filestore-lockrelease-controller-sa
namespace: gcp-filestore-csi-driver
roleRef:
kind: ClusterRole
name: filestorecsi-node-driver-cluster-role
apiGroup: rbac.authorization.k8s.io

---

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: filestorecsi-node-leaderelection-binding
namespace: gke-managed-filestorecsi
subjects:
- kind: ServiceAccount
name: filestore-lockrelease-controller-sa
name: gcp-filestore-csi-node-sa
namespace: gcp-filestore-csi-driver
roleRef:
kind: Role
Expand All @@ -87,9 +80,6 @@ subjects:
- kind: ServiceAccount
name: gcp-filestore-csi-node-sa
namespace: gcp-filestore-csi-driver
- kind: ServiceAccount
name: filestore-lockrelease-controller-sa
namespace: gcp-filestore-csi-driver
roleRef:
kind: Role
name: filestorecsi-node-driver-role
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/overlays/lockrelease/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
resources:
- ../stable-master
- configmap_rbac.yaml
- lock_release_controller.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions pkg/csi_driver/gcfs_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ func (driver *GCFSDriver) Run(endpoint string) {
// Start the nonblocking GRPC.
s := NewNonBlockingGRPCServer()
s.Start(endpoint, driver.ids, driver.cs, driver.ns)
if driver.config.RunNode && driver.config.FeatureOptions.FeatureLockRelease.Enabled {
// Start the lock release controller on node driver.
driver.ns.(*nodeServer).lockReleaseController.Run(context.Background())
}
s.Wait()
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/csi_driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ var (
)

// nodeServer handles mounting and unmounting of GCFS volumes on a node
// TODO(b/375481562): refactor config map utils & remove node driver's dependency on lockReleaseController
type nodeServer struct {
driver *GCFSDriver
mounter mount.Interface
Expand All @@ -77,7 +76,7 @@ func newNodeServer(driver *GCFSDriver, mounter mount.Interface, metaService meta
if err != nil {
return nil, err
}
lc, err := lockrelease.NewLockReleaseController(client, ns.features.FeatureLockRelease.Config, nil)
lc, err := lockrelease.NewLockReleaseController(client, ns.features.FeatureLockRelease.Config)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 76c1775

Please sign in to comment.