Merge pull request #469 from Madhu-1/driver-version

Update driver version during build time
This commit is contained in:
Humble Devassy Chirammal
2019-07-24 14:41:45 +05:30
committed by GitHub
6 changed files with 24 additions and 11 deletions

View File

@ -26,8 +26,6 @@ import (
)
const (
// version of ceph driver
version = "1.0.0"
// volIDVersion is the version number of volume ID encoding scheme
volIDVersion uint16 = 1
@ -94,7 +92,6 @@ func NewNodeServer(d *csicommon.CSIDriver) *NodeServer {
// Run start a non-blocking grpc controller,node and identityserver for
// ceph CSI driver which can serve multiple parallel requests
func (fs *Driver) Run(driverName, nodeID, endpoint, volumeMounter, mountCacheDir, instanceID string, cachePersister util.CachePersister) {
klog.Infof("Driver: %v version: %v", driverName, version)
// Configuration
@ -144,7 +141,7 @@ func (fs *Driver) Run(driverName, nodeID, endpoint, volumeMounter, mountCacheDir
}
// Initialize default library driver
fs.cd = csicommon.NewCSIDriver(driverName, version, nodeID)
fs.cd = csicommon.NewCSIDriver(driverName, util.DriverVersion, nodeID)
if fs.cd == nil {
klog.Fatalln("failed to initialize CSI driver")
}

View File

@ -39,7 +39,7 @@ func initVolumeMountCache(driverName, mountCacheDir string) {
volumeMountCache.nodeCacheStore.BasePath = mountCacheDir
volumeMountCache.nodeCacheStore.CacheDir = driverName
klog.Infof("mount-cache: name: %s, version: %s, mountCacheDir: %s", driverName, version, mountCacheDir)
klog.Infof("mount-cache: name: %s, version: %s, mountCacheDir: %s", driverName, util.DriverVersion, mountCacheDir)
}
func remountCachedVolumes() error {
@ -228,7 +228,7 @@ func (mc *volumeMountCacheMap) nodeStageVolume(volID, stagingTargetPath, mounter
klog.Warningf("mount-cache: node stage volume ignore last cache entry for volume %s", volID)
}
me = volumeMountCacheEntry{DriverVersion: version}
me = volumeMountCacheEntry{DriverVersion: util.DriverVersion}
me.VolumeID = volID
me.Secrets = encodeCredentials(secrets)

View File

@ -46,7 +46,6 @@ type Driver struct {
}
var (
version = "1.0.0"
// PluginFolder defines the location of ceph plugin
PluginFolder = "/var/lib/kubelet/plugins/"
@ -102,8 +101,6 @@ func NewNodeServer(d *csicommon.CSIDriver, containerized bool) (*NodeServer, err
func (r *Driver) Run(driverName, nodeID, endpoint, instanceID string, containerized bool, cachePersister util.CachePersister) {
var err error
klog.Infof("Driver: %v version: %v", driverName, version)
// Create ceph.conf for use with CLI commands
if err = util.WriteCephConfig(); err != nil {
klog.Fatalf("failed to write ceph configuration file (%v)", err)
@ -123,7 +120,7 @@ func (r *Driver) Run(driverName, nodeID, endpoint, instanceID string, containeri
snapJournal.SetCSIDirectorySuffix(CSIInstanceID)
// Initialize default library driver
r.cd = csicommon.NewCSIDriver(driverName, version, nodeID)
r.cd = csicommon.NewCSIDriver(driverName, util.DriverVersion, nodeID)
if r.cd == nil {
klog.Fatalln("Failed to initialize CSI Driver.")
}

View File

@ -39,6 +39,14 @@ func RoundUpToMiB(size int64) int64 {
return roundUpSize(requestBytes, MiB)
}
// variables which will be set during the build time
var (
// GitCommit tell the latest git commit image is built from
GitCommit string
// DriverVersion which will be driver version
DriverVersion string
)
func roundUpSize(volumeSizeBytes, allocationUnitBytes int64) int64 {
roundedUp := volumeSizeBytes / allocationUnitBytes
if volumeSizeBytes%allocationUnitBytes > 0 {