Ver Fonte

storageclass logging improvements

AjayTripathy há 6 anos atrás
pai
commit
3cc7e5f1f6
4 ficheiros alterados com 21 adições e 0 exclusões
  1. 8 0
      cloud/awsprovider.go
  2. 4 0
      cloud/azureprovider.go
  3. 8 0
      cloud/gcpprovider.go
  4. 1 0
      cloud/provider.go

+ 8 - 0
cloud/awsprovider.go

@@ -378,6 +378,10 @@ func (k *awsKey) Features() string {
 }
 }
 
 
 func (aws *AWS) PVPricing(pvk PVKey) (*PV, error) {
 func (aws *AWS) PVPricing(pvk PVKey) (*PV, error) {
+	if pvk.GetStorageClass() == "" {
+		klog.V(3).Infof("Disk in %s does not have a storageclass set, cannot look up pricing info.", pvk.Features())
+		return &PV{}, nil
+	}
 	pricing, ok := aws.Pricing[pvk.Features()]
 	pricing, ok := aws.Pricing[pvk.Features()]
 	if !ok {
 	if !ok {
 		klog.V(2).Infof("Persistent Volume pricing not found for %s", pvk.Features())
 		klog.V(2).Infof("Persistent Volume pricing not found for %s", pvk.Features())
@@ -399,6 +403,10 @@ func (aws *AWS) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string)
 	}
 	}
 }
 }
 
 
+func (key *awsPVKey) GetStorageClass() string {
+	return key.StorageClassName
+}
+
 func (key *awsPVKey) Features() string {
 func (key *awsPVKey) Features() string {
 	storageClass := key.StorageClassName
 	storageClass := key.StorageClassName
 	if storageClass == "standard" {
 	if storageClass == "standard" {

+ 4 - 0
cloud/azureprovider.go

@@ -435,6 +435,10 @@ func (az *Azure) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string)
 	}
 	}
 }
 }
 
 
+func (key *azurePvKey) GetStorageClass() string {
+	return key.StorageClass
+}
+
 func (key *azurePvKey) Features() string {
 func (key *azurePvKey) Features() string {
 	storageClass := key.StorageClassParameters["type"]
 	storageClass := key.StorageClassParameters["type"]
 	if storageClass == "pd-ssd" {
 	if storageClass == "pd-ssd" {

+ 8 - 0
cloud/gcpprovider.go

@@ -694,6 +694,10 @@ func (gcp *GCP) DownloadPricingData() error {
 }
 }
 
 
 func (gcp *GCP) PVPricing(pvk PVKey) (*PV, error) {
 func (gcp *GCP) PVPricing(pvk PVKey) (*PV, error) {
+	if pvk.GetStorageClass() == "" {
+		klog.V(3).Infof("Disk in %s does not have a storageclass set, cannot look up pricing info.", pvk.Features())
+		return &PV{}, nil
+	}
 	gcp.DownloadPricingDataLock.RLock()
 	gcp.DownloadPricingDataLock.RLock()
 	defer gcp.DownloadPricingDataLock.RUnlock()
 	defer gcp.DownloadPricingDataLock.RUnlock()
 	pricing, ok := gcp.Pricing[pvk.Features()]
 	pricing, ok := gcp.Pricing[pvk.Features()]
@@ -710,6 +714,10 @@ type pvKey struct {
 	StorageClassParameters map[string]string
 	StorageClassParameters map[string]string
 }
 }
 
 
+func (key *pvKey) GetStorageClass() string {
+	return key.StorageClass
+}
+
 func (gcp *GCP) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string) PVKey {
 func (gcp *GCP) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string) PVKey {
 	return &pvKey{
 	return &pvKey{
 		Labels:                 pv.Labels,
 		Labels:                 pv.Labels,

+ 1 - 0
cloud/provider.go

@@ -62,6 +62,7 @@ type Key interface {
 
 
 type PVKey interface {
 type PVKey interface {
 	Features() string
 	Features() string
+	GetStorageClass() string
 }
 }
 
 
 // OutOfClusterAllocation represents a cloud provider cost not associated with kubernetes
 // OutOfClusterAllocation represents a cloud provider cost not associated with kubernetes