Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #270 from cofyc/cephfs_identity
Browse files Browse the repository at this point in the history
CephFS provisioner use provisioner name as identitiy by default instead of random string
  • Loading branch information
wongma7 authored Aug 2, 2017
2 parents 5cfe9d4 + 1427e9f commit 429394d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
31 changes: 22 additions & 9 deletions ceph/cephfs/cephfs-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"flag"
"fmt"
"os"
"os/exec"
"strings"

Expand All @@ -37,10 +38,11 @@ import (
)

const (
provisionerName = "ceph.com/cephfs"
provisionCmd = "/usr/local/bin/cephfs_provisioner"
provisionerIDAnn = "cephFSProvisionerIdentity"
cephShareAnn = "cephShare"
provisionerName = "ceph.com/cephfs"
provisionCmd = "/usr/local/bin/cephfs_provisioner"
provisionerIDAnn = "cephFSProvisionerIdentity"
cephShareAnn = "cephShare"
provisionerNameKey = "PROVISIONER_NAME"
)

type provisionOutput struct {
Expand Down Expand Up @@ -272,10 +274,6 @@ func main() {
} else {
config, err = rest.InClusterConfig()
}
prID := string(uuid.NewUUID())
if *id != "" {
prID = *id
}
if err != nil {
glog.Fatalf("Failed to create config: %v", err)
}
Expand All @@ -284,6 +282,20 @@ func main() {
glog.Fatalf("Failed to create client: %v", err)
}

prName := provisionerName
prNameFromEnv := os.Getenv(provisionerNameKey)
if prNameFromEnv != "" {
prName = prNameFromEnv
}

// By default, we use provisioner name as provisioner identity.
// User may specify their own identity with `-id` flag to distinguish each
// others, if they deploy more than one CephFS provisioners under same provisioner name.
prID := prName
if *id != "" {
prID = *id
}

// The controller needs to know what the server version is because out-of-tree
// provisioners aren't officially supported until 1.5
serverVersion, err := clientset.Discovery().ServerVersion()
Expand All @@ -293,13 +305,14 @@ func main() {

// Create the provisioner: it implements the Provisioner interface expected by
// the controller
glog.Infof("Creating CephFS provisioner %s with identity: %s", prName, prID)
cephFSProvisioner := newCephFSProvisioner(clientset, prID)

// Start the provision controller which will dynamically provision cephFS
// PVs
pc := controller.NewProvisionController(
clientset,
provisionerName,
prName,
cephFSProvisioner,
serverVersion.GitVersion,
)
Expand Down
Empty file modified ceph/cephfs/local-start.sh
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions ceph/rbd/cmd/rbd-provisioner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func main() {
prName = prNameFromEnv
}

// By default, we use provision name as provisioner identity.
// By default, we use provisioner name as provisioner identity.
// User may specify their own identity with `-id` flag to distinguish each
// others, if they deploy more than one RBD provisioners under same provisioner name.
prID := prName
Expand All @@ -81,7 +81,7 @@ func main() {

// Create the provisioner: it implements the Provisioner interface expected by
// the controller
glog.Infof("Creating RBD provisioner with identity: %s", prID)
glog.Infof("Creating RBD provisioner %s with identity: %s", prName, prID)
rbdProvisioner := provision.NewRBDProvisioner(clientset, prID)

// Start the provision controller which will dynamically provision rbd
Expand Down

0 comments on commit 429394d

Please sign in to comment.