Skip to content

Commit

Permalink
Merge branch 'main' into PROD-3036/fix-ansible-docker-image
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Dec 19, 2024
2 parents 8706b63 + 387f38b commit 65af51a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions charts/deployment-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
name: deployment-operator
description: creates a new instance of the plural deployment operator
appVersion: 0.5.2
version: 0.5.2
appVersion: 0.5.3
version: 0.5.3
maintainers:
- name: Plural
url: https://www.plural.sh
Expand Down
20 changes: 10 additions & 10 deletions internal/controller/kubecostextractor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,15 @@ func (r *KubecostExtractorReconciler) fetch(host, path string, params map[string
return buffer.Bytes(), nil
}

func (r *KubecostExtractorReconciler) getAllocation(ctx context.Context, srv *corev1.Service, servicePort, aggregate string) (*allocationResponse, error) {
func (r *KubecostExtractorReconciler) getAllocation(ctx context.Context, srv *corev1.Service, servicePort, aggregate string, idle bool) (*allocationResponse, error) {
queryParams := map[string]string{
"window": "30d",
"aggregate": aggregate,
"accumulate": "true",
}
if idle {
queryParams["shareIdle"] = "true"
}

var response []byte
var err error
Expand All @@ -239,7 +242,7 @@ func (r *KubecostExtractorReconciler) getAllocation(ctx context.Context, srv *co
func (r *KubecostExtractorReconciler) getRecommendationAttributes(ctx context.Context, srv *corev1.Service, servicePort string, recommendationThreshold float64) ([]*console.ClusterRecommendationAttributes, error) {
var result []*console.ClusterRecommendationAttributes
for _, resourceType := range kubecostResourceTypes {
ar, err := r.getAllocation(ctx, srv, servicePort, resourceType)
ar, err := r.getAllocation(ctx, srv, servicePort, resourceType, false)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -267,7 +270,7 @@ func (r *KubecostExtractorReconciler) getRecommendationAttributes(ctx context.Co

func (r *KubecostExtractorReconciler) getNamespacesCost(ctx context.Context, srv *corev1.Service, servicePort string) ([]*console.CostAttributes, error) {
var result []*console.CostAttributes
ar, err := r.getAllocation(ctx, srv, servicePort, "namespace")
ar, err := r.getAllocation(ctx, srv, servicePort, "namespace", false)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -305,7 +308,7 @@ func (r *KubecostExtractorReconciler) getClusterCost(ctx context.Context, srv *c
if err != nil {
return nil, err
}
ar, err := r.getAllocation(ctx, srv, servicePort, "cluster")
ar, err := r.getAllocation(ctx, srv, servicePort, "cluster", true)
if err != nil {
return nil, err
}
Expand All @@ -327,7 +330,7 @@ func (r *KubecostExtractorReconciler) getClusterCost(ctx context.Context, srv *c
}

func (r *KubecostExtractorReconciler) getControlPlaneCost(ctx context.Context, srv *corev1.Service, servicePort string) (*float64, error) {
ar, err := r.getAllocation(ctx, srv, servicePort, "controller")
ar, err := r.getAllocation(ctx, srv, servicePort, "controller", false)
if err != nil {
return nil, err
}
Expand All @@ -349,7 +352,7 @@ func (r *KubecostExtractorReconciler) getControlPlaneCost(ctx context.Context, s

func (r *KubecostExtractorReconciler) getNodeCost(ctx context.Context, srv *corev1.Service, servicePort string) (*float64, error) {
var totalNodeCost float64
ar, err := r.getAllocation(ctx, srv, servicePort, "node")
ar, err := r.getAllocation(ctx, srv, servicePort, "node", true)
if err != nil {
return nil, err
}
Expand All @@ -360,10 +363,7 @@ func (r *KubecostExtractorReconciler) getNodeCost(ctx context.Context, srv *core
if nodeCosts == nil {
continue
}
for name, allocation := range nodeCosts {
if name == opencost.IdleSuffix {
continue
}
for _, allocation := range nodeCosts {
totalNodeCost += allocation.TotalCost()
}
}
Expand Down

0 comments on commit 65af51a

Please sign in to comment.