Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aggregate by all if aggregate is empty #2376

Merged

Conversation

nickcurie
Copy link
Contributor

What does this PR change?

Does this PR relate to any other PRs?

How will this PR impact users?

Does this PR address any GitHub or Zendesk issues?

  • Closes ...

How was this PR tested?

Does this PR require changes to documentation?

Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next OpenCost release? If not, why not?

Copy link

vercel bot commented Dec 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
opencost ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 8, 2023 11:17pm

@@ -38,6 +38,11 @@ func ParseCloudCostRequest(qp httputil.QueryParams) (*QueryRequest, error) {
aggregateBy = append(aggregateBy, prop)
}

// if we're aggregating by nothing (aka `item` on the frontend) then aggregate by all
if aggregateBy != nil && len(aggregateBy) < 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetList() returns nil if the string is empty https://github.com/opencost/opencost/blob/develop/pkg/util/mapper/mapper.go#L440

Suggested change
if aggregateBy != nil && len(aggregateBy) < 1 {
if len(aggregateBy) == 0 {

should work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails the tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aggregateBy != nil was what fixed it but probably caused the issue to not get solved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change the test; behavior isn't working as its supposed to so we're fixing a bug. I'd say that the unit test is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we probably need to do the "all" thing and treat both nil and {} as "do not aggregate." Which might mean that we need a test change? Does that sound right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok let me nuke the test for now just to make sure this solves the problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm clear on what "do not aggregate" means. Would that just return one line item or something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "do not aggregate" I believe niko means "return maximum-resolution lines", the same as a "full group by"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what's all then? I thought that would be full group by

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe "all" is supposed to produce a single, fully-totalled, line

Signed-off-by: nickcurie <ncurie@kubecost.com>
Signed-off-by: nickcurie <ncurie@kubecost.com>
@nickcurie nickcurie force-pushed the nick/cloud-cost-empty-aggregate branch from 7531495 to 6c19d08 Compare December 8, 2023 23:11
@michaelmdresser michaelmdresser merged commit f0e3e8d into opencost:develop Dec 8, 2023
5 checks passed
michaelmdresser pushed a commit that referenced this pull request Dec 8, 2023
* aggregate by all if aggregate is empty

Signed-off-by: nickcurie <ncurie@kubecost.com>

* resolved broken test

Signed-off-by: nickcurie <ncurie@kubecost.com>

---------

Signed-off-by: nickcurie <ncurie@kubecost.com>
michaelmdresser pushed a commit that referenced this pull request Dec 8, 2023
* aggregate by all if aggregate is empty

Signed-off-by: nickcurie <ncurie@kubecost.com>

* resolved broken test

Signed-off-by: nickcurie <ncurie@kubecost.com>

---------

Signed-off-by: nickcurie <ncurie@kubecost.com>
Signed-off-by: Michael Dresser <michaelmdresser@gmail.com>
michaelmdresser added a commit that referenced this pull request Dec 8, 2023
* aggregate by all if aggregate is empty



* resolved broken test



---------

Signed-off-by: nickcurie <ncurie@kubecost.com>
Signed-off-by: Michael Dresser <michaelmdresser@gmail.com>
Co-authored-by: Nick Curie <32180999+nickcurie@users.noreply.github.com>
@nickcurie nickcurie deleted the nick/cloud-cost-empty-aggregate branch December 9, 2023 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants