Sfoglia il codice sorgente

comments and cleanups

AjayTripathy 7 anni fa
parent
commit
4b8419345f
4 ha cambiato i file con 10 aggiunte e 8 eliminazioni
  1. 3 3
      cloud/awsprovider.go
  2. 5 3
      cloud/gcpprovider.go
  3. 1 1
      cloud/provider.go
  4. 1 1
      main.go

+ 3 - 3
cloud/awsprovider.go

@@ -77,7 +77,7 @@ type AWSProductAttributes struct {
 	OperatingSystem string `json:"operatingSystem"`
 	PreInstalledSw  string `json:"preInstalledSw"`
 	InstanceFamily  string `json:"instanceFamily"`
-	GPU             string `json:gpu`
+	GPU             string `json:"gpu"` // GPU represents the number of GPU on the instance
 }
 
 // AWSPricingTerms are how you pay for the node: OnDemand, Reserved, or (TODO) Spot
@@ -111,7 +111,7 @@ type AWSProductTerms struct {
 	Memory   string        `json:"memory"`
 	Storage  string        `json:"storage"`
 	VCpu     string        `json:"vcpu"`
-	GPU      string        `json:"gpu"`
+	GPU      string        `json:"gpu"` // GPU represents the number of GPU on the instance
 }
 
 // ClusterIdEnvVar is the environment variable in which one can manually set the ClusterId
@@ -468,7 +468,7 @@ func (aws *AWS) createNode(terms *AWSProductTerms, usageType string, k Key) (*No
 			UsageType:    usageType,
 		}, nil
 	}
-	c, ok  := terms.OnDemand.PriceDimensions[terms.Sku+OnDemandRateCode+HourlyRateCode]
+	c, ok := terms.OnDemand.PriceDimensions[terms.Sku+OnDemandRateCode+HourlyRateCode]
 	if !ok {
 		return nil, fmt.Errorf("Could not fetch data for \"%s\"", k.ID())
 	}

+ 5 - 3
cloud/gcpprovider.go

@@ -26,6 +26,8 @@ import (
 	"k8s.io/client-go/kubernetes"
 )
 
+const GKE_GPU_TAG = "cloud.google.com/gke-accelerator"
+
 type userAgentTransport struct {
 	userAgent string
 	base      http.RoundTripper
@@ -296,7 +298,7 @@ func (gcp *GCP) parsePage(r io.Reader, inputKeys map[string]Key) (map[string]*GC
 						for k, key := range inputKeys {
 							if key.GPUType() == gpuType {
 								if region == strings.Split(k, ",")[0] {
-									klog.V(3).Infof("MATCHED GPU TO NODE in region " + region)
+									klog.V(3).Infof("Matched GPU to node in region \"%s\"", region)
 									candidateKeyGPU = key.Features()
 									if pl, ok := gcpPricingList[candidateKeyGPU]; ok {
 										pl.Node.GPUName = gpuType
@@ -497,7 +499,7 @@ func (gcp *gcpKey) ID() string {
 }
 
 func (gcp *gcpKey) GPUType() string {
-	if t, ok := gcp.Labels["cloud.google.com/gke-accelerator"]; ok {
+	if t, ok := gcp.Labels[GKE_GPU_TAG]; ok {
 		klog.V(3).Infof("GPU of type: \"%s\" found", t)
 		return t
 	}
@@ -521,7 +523,7 @@ func (gcp *gcpKey) Features() string {
 		usageType = "ondemand"
 	}
 
-	if _, ok := gcp.Labels["cloud.google.com/gke-accelerator"]; ok {
+	if _, ok := gcp.Labels[GKE_GPU_TAG]; ok {
 		return region + "," + instanceType + "," + usageType + "," + "gpu"
 	}
 

+ 1 - 1
cloud/provider.go

@@ -31,7 +31,7 @@ type Node struct {
 	UsesBaseCPUPrice bool   `json:"usesDefaultPrice"`
 	BaseCPUPrice     string `json:"baseCPUPrice"` // Used to compute an implicit RAM GB/Hr price when RAM pricing is not provided.
 	UsageType        string `json:"usageType"`
-	GPU              string `json:"gpu"`
+	GPU              string `json:"gpu"` // GPU represents the number of GPU on the instance
 	GPUName          string `json:"gpuName"`
 	GPUCost          string `json:"gpuCost"`
 }

+ 1 - 1
main.go

@@ -141,7 +141,7 @@ func (p *Accesses) UpdateConfigs(w http.ResponseWriter, r *http.Request, ps http
 	w.Write(wrapData(data, err))
 	err = p.Cloud.DownloadPricingData()
 	if err != nil {
-		klog.V(1).Infof("Error redownloading data on config update")
+		klog.V(1).Infof("Error redownloading data on config update: %s", err.Error())
 	}
 	return
 }