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

initial pass of a whitelist that adds labels relevant for aggregation #2719

Merged
merged 3 commits into from
May 30, 2024

Conversation

AjayTripathy
Copy link
Contributor

What does this PR change?

  • Support a label whitelist, but leave all labels on

Does this PR relate to any other PRs?

  • No

How will this PR impact users?

  • Lower prometheus memory impact.

How was this PR tested?

  • Unit tests, run manually on a GKE cluster

Does this PR require changes to documentation?

  • Yes; we should document this feature when ready.

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?

  • Still mainly a proposal

Copy link

vercel bot commented Apr 28, 2024

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

Name Status Preview Updated (UTC)
opencost ✅ Ready (Inspect) Visit Preview Apr 28, 2024 11:04pm

Copy link

sonarcloud bot commented Apr 28, 2024

@AjayTripathy AjayTripathy changed the title [DRAFT] initial pass of a whitelist that adds labels relevant for aggregation initial pass of a whitelist that adds labels relevant for aggregation May 15, 2024
@AjayTripathy
Copy link
Contributor Author

@cliffcolvin could we get a review on this one?

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestWhitelist(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any way we could get an assertion here that could fail? Hard to call it a "test" if it can't fail. (Or perhaps I am being dumb and am missing that bit?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, this is my bad. good catch, I'll add an assertion.

Comment on lines +21 to +22
UseLabelsWhitelist bool `json:"useLabelsWhitelist,omitempty"`
LabelsWhitelist map[string]bool `json:"labelsWhiteList,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this get configured? How would it be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be helpful to be explicit in the variable name that these only apply to pod labels?

@@ -29,6 +37,40 @@ func (kpmc KubePodLabelsCollector) Describe(ch chan<- *prometheus.Desc) {
}
}

func (kpmc *KubePodLabelsCollector) UpdateControllerSelectorsCache() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need anything Deployment-specific here? Or does the ReplicaSet case cover Deployments adequately? Looking over pkg/costmodel/allocation.go the only relevant metrics I see are:

  • service_selector_labels
  • deployment_match_labels
  • statefulSet_match_labels

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replicasets covers deployments!

@AjayTripathy AjayTripathy merged commit f362d96 into develop May 30, 2024
5 checks passed
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