Sfoglia il codice sorgente

Merge pull request #1538 from nickcurie/nick/azure-orphaned-resources-disknames

Nick/azure orphaned resources disknames
Michael Dresser 3 anni fa
parent
commit
1f0a379bee
2 ha cambiato i file con 15 aggiunte e 2 eliminazioni
  1. 14 2
      pkg/cloud/azureprovider.go
  2. 1 0
      pkg/cloud/provider.go

+ 14 - 2
pkg/cloud/azureprovider.go

@@ -3,7 +3,6 @@ package cloud
 import (
 	"context"
 	"fmt"
-	"github.com/opencost/opencost/pkg/kubecost"
 	"io"
 	"net/http"
 	"net/url"
@@ -14,6 +13,8 @@ import (
 	"sync"
 	"time"
 
+	"github.com/opencost/opencost/pkg/kubecost"
+
 	"github.com/opencost/opencost/pkg/clustercache"
 	"github.com/opencost/opencost/pkg/env"
 	"github.com/opencost/opencost/pkg/log"
@@ -1266,14 +1267,25 @@ func (az *Azure) GetOrphanedResources() ([]OrphanedResource, error) {
 				return nil, err
 			}
 
+			diskName := ""
+			if d.Name != nil {
+				diskName = *d.Name
+			}
+
+			diskRegion := ""
+			if d.Location != nil {
+				diskRegion = *d.Location
+			}
+
 			or := OrphanedResource{
 				Kind:   "disk",
-				Region: *d.Location,
+				Region: diskRegion,
 				Description: map[string]string{
 					"diskState":   string(d.DiskState),
 					"timeCreated": d.TimeCreated.String(),
 				},
 				Size:        d.DiskSizeGB,
+				DiskName:    diskName,
 				MonthlyCost: &cost,
 			}
 			orphanedResources = append(orphanedResources, or)

+ 1 - 0
pkg/cloud/provider.go

@@ -109,6 +109,7 @@ type OrphanedResource struct {
 	Region      string            `json:"region"`
 	Description map[string]string `json:"description"`
 	Size        *int32            `json:"diskSizeInGB,omitempty"`
+	DiskName    string            `json:"diskName,omitempty"`
 	Address     string            `json:"ipAddress,omitempty"`
 	MonthlyCost *float64          `json:"monthlyCost"`
 }