Skip to content

Commit

Permalink
Merge pull request #19 from deckhouse/add-cluster-info
Browse files Browse the repository at this point in the history
Add clusterUUID as label to newly created disks
  • Loading branch information
name212 authored Apr 23, 2024
2 parents 565ebf2 + 99eeae9 commit d7c17ce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.52.2
version: v1.55.2
args: --timeout=5m
build:
runs-on: ubuntu-latest
Expand Down
13 changes: 7 additions & 6 deletions cmd/yandex-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ import (

func main() {
var (
endpoint = flag.String("endpoint", "unix:///var/lib/kubelet/plugins/"+driver.DefaultDriverName+"/csi.sock", "CSI endpoint")
folderID = flag.String("folder-id", "", "Folder ID")
driverName = flag.String("driver-name", driver.DefaultDriverName, "Name for the driver")
address = flag.String("address", driver.DefaultAddress, "Address to serve on")
version = flag.Bool("version", false, "Print the version and exit.")
endpoint = flag.String("endpoint", "unix:///var/lib/kubelet/plugins/"+driver.DefaultDriverName+"/csi.sock", "CSI endpoint")
folderID = flag.String("folder-id", "", "Folder ID")
driverName = flag.String("driver-name", driver.DefaultDriverName, "Name for the driver")
address = flag.String("address", driver.DefaultAddress, "Address to serve on")
clusterUUID = flag.String("cluster-uuid", driver.DefaultClusterUUID, "Cluster UUID")
version = flag.Bool("version", false, "Print the version and exit.")
)
flag.Parse()

Expand All @@ -46,7 +47,7 @@ func main() {

authKeys := os.Getenv("YANDEX_AUTH_KEYS")

drv, err := driver.NewDriver(*endpoint, authKeys, *folderID, *driverName, *address)
drv, err := driver.NewDriver(*endpoint, authKeys, *folderID, *driverName, *address, *clusterUUID)
if err != nil {
log.Fatalln(err)
}
Expand Down
1 change: 1 addition & 0 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
FolderId: d.folderID,
Name: volumeName,
Description: createdByYandex,
Labels: map[string]string{"cluster_uuid": d.clusterUUID},
TypeId: typeID,
ZoneId: zone,
Size: size,
Expand Down
14 changes: 9 additions & 5 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
// DefaultAddress is the default address that the csi plugin will serve its
// http handler on.
DefaultAddress = "127.0.0.1:12302"
DefaultClusterUUID = "default"
defaultWaitActionTimeout = 5 * time.Minute
)

Expand All @@ -59,10 +60,9 @@ var (

// Driver implements the following CSI interfaces:
//
// csi.IdentityServer
// csi.ControllerServer
// csi.NodeServer
//
// csi.IdentityServer
// csi.ControllerServer
// csi.NodeServer
type Driver struct {
name string
// publishInfoVolumeName is used to pass the volume name from
Expand All @@ -78,6 +78,8 @@ type Driver struct {
region string
zone string

clusterUUID string

srv *grpc.Server
httpSrv http.Server
log *logrus.Entry
Expand Down Expand Up @@ -109,7 +111,7 @@ func (d *Driver) ListSnapshots(context.Context, *csi.ListSnapshotsRequest) (*csi
// NewDriver returns a CSI plugin that contains the necessary gRPC
// interfaces to interact with Kubernetes over unix domain sockets for
// managaing Yandex Disks
func NewDriver(ep, authKeysStr, folderID, driverName, address string) (*Driver, error) {
func NewDriver(ep, authKeysStr, folderID, driverName, address, clusterUUID string) (*Driver, error) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

Expand Down Expand Up @@ -170,6 +172,8 @@ func NewDriver(ep, authKeysStr, folderID, driverName, address string) (*Driver,
resizeLocks: NewRwMap(),
waitActionTimeout: defaultWaitActionTimeout,

clusterUUID: clusterUUID,

sdk: sdk,

healthChecker: healthChecker,
Expand Down

0 comments on commit d7c17ce

Please sign in to comment.