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

Report total memory under management for licensing #2277

Merged
merged 34 commits into from
Dec 20, 2019

Conversation

thbkrkr
Copy link
Contributor

@thbkrkr thbkrkr commented Dec 17, 2019

Start a reporter in a goroutine that repeatedly (every 2 minutes) aggregates the total memory of
all Elastic managed components by the operator and reports it in the form of a licensing information
in a config map.

> kubectl -n elastic-system get cm elastic-licensing -o json | jq .data
{
  "eck_license_level": "enterprise",
  "enterprise_resource_units": "1",
  "timestamp": "2019-12-20T18:18:31+01:00",
  "total_managed_memory": "12.88GB"
}

I left cmd/licensing-info/main.go to show another use:

> go run cmd/licensing-info/main.go | jq . 
{
  "eck_license_level": "enterprise",
  "enterprise_resource_units": "1",
  "timestamp": "2019-12-20T18:18:31+01:00",
  "total_managed_memory": "12.88GB"
}

Start a reporter in a goroutine that repeatedly aggregates the total memory of
all Elastic components and reports it in the form of a licensing information
in a config map.
@thbkrkr thbkrkr added the >feature Adds or discusses adding a feature to the product label Dec 17, 2019
@pebrc pebrc added the v1.0.0 label Dec 17, 2019
pebrc
pebrc previously requested changes Dec 17, 2019
pkg/controller/license/license_controller.go Outdated Show resolved Hide resolved
pkg/resource/license.go Outdated Show resolved Hide resolved
pkg/resource/license.go Outdated Show resolved Hide resolved
@thbkrkr thbkrkr force-pushed the memory-accounting-for-licensing branch from 9f59f72 to 562d835 Compare December 17, 2019 15:12
@thbkrkr thbkrkr requested a review from pebrc December 17, 2019 15:27
Copy link
Contributor

@david-kow david-kow left a comment

Choose a reason for hiding this comment

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

Looks good overall, few comments.

pkg/resource/license.go Outdated Show resolved Hide resolved
pkg/resource/aggregator.go Outdated Show resolved Hide resolved
pkg/resource/aggregator.go Outdated Show resolved Hide resolved
pkg/resource/aggregator.go Outdated Show resolved Hide resolved
@pebrc pebrc dismissed their stale review December 17, 2019 16:04

Issue has been fixed, dismissing this big red X as I am off tomorrow for most of the day.

pkg/resource/aggregator.go Outdated Show resolved Hide resolved
pkg/resource/aggregator.go Outdated Show resolved Hide resolved
pkg/resource/aggregator.go Outdated Show resolved Hide resolved
pkg/resource/aggregator.go Outdated Show resolved Hide resolved
pkg/resource/aggregator.go Outdated Show resolved Hide resolved
pkg/resource/license.go Outdated Show resolved Hide resolved
pkg/resource/license.go Outdated Show resolved Hide resolved
pkg/resource/license.go Outdated Show resolved Hide resolved
pkg/resource/license.go Outdated Show resolved Hide resolved
pkg/resource/reporter.go Outdated Show resolved Hide resolved
@thbkrkr thbkrkr force-pushed the memory-accounting-for-licensing branch from 692cb4e to f8b86bf Compare December 17, 2019 17:53
@itsmed

This comment has been minimized.

pkg/license/aggregator.go Outdated Show resolved Hide resolved
pkg/controller/common/license/check.go Outdated Show resolved Hide resolved
pkg/license/license.go Outdated Show resolved Hide resolved
@thbkrkr

This comment has been minimized.

@thbkrkr
Copy link
Contributor Author

thbkrkr commented Dec 18, 2019

Thanks for all the feedbacks.
We are good for another pass.

pkg/license/aggregator.go Outdated Show resolved Hide resolved
pkg/license/aggregator.go Outdated Show resolved Hide resolved
pkg/license/aggregator.go Show resolved Hide resolved
pkg/license/aggregator.go Show resolved Hide resolved
pkg/license/aggregator.go Outdated Show resolved Hide resolved
pkg/license/aggregator.go Show resolved Hide resolved
pkg/license/license.go Outdated Show resolved Hide resolved

log.V(1).Info("Saving", "license_info", info)
cm := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Copy link
Contributor

Choose a reason for hiding this comment

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

We'd also need to retrieve StatefulSets in the operator namespace so we get its UID, which is not something we currently have RBAC permissions for.

pkg/license/reporter.go Show resolved Hide resolved
pkg/license/reporter_test.go Show resolved Hide resolved
@thbkrkr

This comment has been minimized.

@thbkrkr

This comment has been minimized.

cmd/licensing-info/main.go Outdated Show resolved Hide resolved
cmd/manager/main.go Outdated Show resolved Hide resolved
pkg/license/reporter_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@sebgl sebgl left a comment

Choose a reason for hiding this comment

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

LGTM after we fix the remaining small nits

@thbkrkr thbkrkr merged commit c9124a3 into elastic:master Dec 20, 2019
@thbkrkr thbkrkr deleted the memory-accounting-for-licensing branch December 20, 2019 17:28
mjmbischoff pushed a commit to mjmbischoff/cloud-on-k8s that referenced this pull request Jan 13, 2020
Start a reporter in a goroutine that repeatedly (every 2 minutes) aggregates the total memory of
all Elastic managed components by the operator and reports it in the form of a licensing information in a config map.

Example of the content of the config map:

  > kubectl -n elastic-system get cm elastic-licensing -o json | jq .data
  {
    "eck_license_level": "enterprise",
    "enterprise_resource_units": "1",
    "timestamp": "2019-12-20T18:18:31+01:00",
    "total_managed_memory": "12.88GB"
  }

Notes:
- "Enterprise resource units" is an Elastic unit calculated with the total memory under management divided by 64GB.
- The ECK license level can be basic, trial-enterprise or entreprise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>feature Adds or discusses adding a feature to the product v1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants