-
Notifications
You must be signed in to change notification settings - Fork 45
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
SWATCH-2358: Only meter ELS 3rd party converted PAYG instances #3237
SWATCH-2358: Only meter ELS 3rd party converted PAYG instances #3237
Conversation
9ccc9fa
to
004afcd
Compare
A new field got added to SKUs (SPECIAL_PRICING_FLAG) and we want to detect if it's set to MIGRATION_OFFERING, which will indicate that particular sku is for a third-party migrated offering. Making that differentiation will allow us to tally 3rd party migrated instances separately. With this commit, swatch will now consume that flag during Offering sync and persist that information in the database. Co-authored-by: Jose Carvajal <[email protected]>
Metrics gathered from prometheus or CostMgmt will parse/populate the flag to be used during product tag lookup when processing instance data
Metrics gathered from prometheus or CostMgmt will parse/populate the flag to be used during product tag lookup when processing instance data
004afcd
to
efa4719
Compare
/retest |
/retest |
/retest |
...ch-metrics/src/main/java/com/redhat/swatch/metrics/service/PrometheusMeteringController.java
Outdated
Show resolved
Hide resolved
...ch-metrics/src/main/java/com/redhat/swatch/metrics/service/PrometheusMeteringController.java
Show resolved
Hide resolved
...ch-metrics/src/main/java/com/redhat/swatch/metrics/service/PrometheusMeteringController.java
Outdated
Show resolved
Hide resolved
- Remove findFirst() usage and warn if multiple product tags match an event for some reason
These were leftover from when swatch-metrics had a database integration. As they've been updated, they've become redundant and don't test anything useful for us. Deleting them now and will add more useful tests at a later time.
/retest |
Two test failures on IQE are related to:
I am still verifying the functionality, should finish by tomorrow. |
- Most values that get generated/derived from labels are covered by the MeteringEventsFactoryTest class - Added a test for when the product identifier coming from prometheus is in the "resource_name" label (rhods specific) - Added test for when product identifier is in the "product" label (rest of openshift payg products) - Added test for when product field has a list of engineering ids (rhelemeter products). - Added a variant of the rhelemeter test that ensures an Event is not generated if there's no unique product tag that matches it
@lindseyburnett I am seeing if event has product_tag for rhel-for-x86-els-payg and even if conversion is False, host is considered in rhel-for-x86-els-payg. I expected host to not present in rhel-for-x86-els-payg. Reproducer : Create events as below, sync hourly tally and see instances api showing host even if conversion is False.
|
/retest |
Added more logic to ensure that product tag is matching a product config definition, and to fail validation if there isn't a defined product tag or if the event message has defined product tags that don't match the ones from the lookup. If there is not a matching product tag, the event is considered invalid and will not get persisted.
Fixed this by adding product tag verification to our "event validation" check at the very beginning of ingestion. If data in the event doesn't align with a product tag, a warning message appears in the logs and validation fails. If the event has a product tag on it, but the other data doesn't match the configured product tag, the same error will happen. Events that fail validation don't get saved to the events table in the database.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Related automation changes in https://gitlab.cee.redhat.com/insights-qe/iqe-rhsm-subscriptions-plugin/-/merge_requests/697
PR #3237 introduced the SPECIAL_PRICING_FLAG to the offering table for the monolith, but we need to add a liquibase script specific for h2 databases so swatch-contracts integration test will be successful Resolves exception ``` Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement [Column "SPECIAL_PRICING_FLAG" not found; SQL statement: insert into offering (cores,derived_sku,description,has_unlimited_usage,hypervisor_cores,hypervisor_sockets,metered,product_family,product_name,role,sla,sockets,special_pricing_flag,usage,sku) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) [42122-224]] [insert into offering (cores,derived_sku,description,has_unlimited_usage,hypervisor_cores,hypervisor_sockets,metered,product_family,product_name,role,sla,sockets,special_pricing_flag,usage,sku) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)] ```
Jira issue: SWATCH-2358
Description
We want to differentiate and count ELS PAYG instances separately - depending on if they were 3rd party migrated or not.
To support this, a new field was added to skus, "SPECIAL_PRICING_FLAG". When that field contains the flag "MIGRATION_OFFERING", instances associated with that offering will be considered 3rd party migrated.
This PR does a handful of things:
isMigrationProduct
in the swatch-product-configuration.This PR effectively disables support for non-migration ELS PAYG being metered in swatch. SWATCH-2401 re-enables ELS paygo non-migration support.
Testing
IQE MR: https://gitlab.cee.redhat.com/insights-qe/iqe-rhsm-subscriptions-plugin/-/merge_requests/666
For offering and capacity:
Setup
RHSM_SUBSCRIPTIONS_ENABLE_SYNCHRONOUS_OPERATIONS=true DEV_MODE=true PROM_URL=http://localhost:8082/api/metrics/v1/telemeter/api/v1 SWATCH_CONTRACTS_INTERNAL_SERVICE=http://localhost:8882 SERVER_PORT=8000 SPRING_PROFILES_ACTIVE=worker,kafka-queue,api,capacity-ingress,rh-marketplace,kafka-queue,rhsm-conduit ./gradlew clean :bootRun
Steps and Verification for Offering and Capacity
Response Verification:
rhel-for-x86-els-payg
Offering table:
RH02781MO,RHEL Server,RHEL,,,,,,Premium,Production,"Red Hat Enterprise Linux for Third Party Linux Migration with Extended Life Cycle Support (On-Demand, Monthly Production Support)",false,,true,MIGRATION_OFFERING
sku_product_tag:
RH02781MO,rhel-for-x86-els-payg
Response Verification:
For rhelemeter instances
Using the swatch-support-scripts repo from gitlab, start a token refresher for stage rhelemeter. You'll need to set
VAULT_TOKEN
first.Start swatch-metrics with rhelemeter as the event source
EVENT_SOURCE=rhelemeter PROM_URL="http://localhost:8082/api/v1" ./gradlew :swatch-metrics:quarkusDev
Kick off metering for
rhel-for-x86-els-payg
product tag with an orgId that has els metrics with conversions_success label set to true.Verify that the Event message that got put onto the
service-instance-ingress
topic has the"conversion":true
attribute and the product_tag field gets cleared out. This is to force that event ingestion looks up the proper product tag, taking the conversion status into consideration.http://localhost:3030/#/cluster/default/topic/n/platform.rhsm-subscriptions.service-instance-ingress/
There isn't data in stage to test when the label is missing or set to false. You can manually modify the payload and put a message on the topic though. The key should match the org_id and the value is the json.