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

SWATCH-2915 Specify BYOS aws product code #3821

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lindseyburnett
Copy link
Contributor

@lindseyburnett lindseyburnett commented Oct 2, 2024

Jira issue: SWATCH-2915

Description

Our previous implementation was based off the incorrect assumption that the presence of an aws billing code on a system fact indicated that system was tied to a marketplace subscription. We've since learned that any system provisioned in aws, regardless of if they're paying for the subscription through aws, gets an aws billing code associated with it.

Systems that were provisioned with a red hat gold image get specifically bp-63a5400a as a billing product code. PM identified this product code as indicating BYOS. If a billing product code is absent, that also indicates BYOS. A meeting with PM was had, and it was decided that we would maintain a list of product codes to consider BYOS instead of the opposite. If a billing product code is present and it doesn't appear in the list of BYOS product codes, then consider it a Marketplace system. Similar updates will need to happen with other system reporters since HBI doesn't centralize any normalization.

Testing

Setup

swatch-2915-wiremock.zip

Run wiremock with stubs. For convenience here is a zip file with a compose file and the wiremock mappings and payloads. The format of the responses came from a real response from https://api.rhsm.redhat.com/v1/candlepin/consumers/feeds, and then I modified sensitive values. Account numbers and ip addresses are randomly generated.

If you don't use podman-compose, here's the cli equivalent:

podman run -d \
  --name wiremock \
  -p 8101:8080 \
  -v ./wiremock/mappings:/home/wiremock/mappings:z \
  -v ./wiremock/__files:/home/wiremock/__files:z \
  wiremock/wiremock:2.32.0 \
  --verbose --global-response-templating

Confirm that wiremock is serving responses properly for both account ids 9999999 and 1111111.

We're expecting

http http://localhost:8101/v1/candlepin/consumers/feeds X-RhsmApi-AccountID:9999999 | jq '.body[0] | {name, aws_instance_id: .facts.aws_instance_id,  aws_billing_products: .facts.aws_billing_products}'
{
  "name": "bananas.lab.eng.brq2.redhat.com",
  "aws_instance_id": "i-0c892607c9a3820c6",
  "aws_billing_products": "weeee_not_byos_billing_product_code"
}
http http://localhost:8101/v1/candlepin/consumers/feeds X-RhsmApi-AccountID:1111111 | jq '.body[0] | {name, aws_instance_id: .facts.aws_instance_id,  aws_billing_products: .facts.aws_billing_products}'
{
  "name": "oranges.lab.eng.brq2.redhat.com",
  "aws_instance_id": "i-d4e435fa4dc3f9189",
  "aws_billing_products": "bp-63a5400a"
}

Steps

Start conduit

RHSM_URL=http://localhost:8101/v1 DEV_MODE=true ./gradlew :swatch-system-conduit:bootRun

Hit the conduit API described as "Initiate viewing conduit representation of an org's systems from RHSM" with each of the org ids that we mocked with wiremock

http ':8000/api/rhsm-subscriptions/v1/internal/organizations/9999999/inventory?limit=10' x-rh-swatch-psk:placeholder Origin:console.redhat.com

http ':8000/api/rhsm-subscriptions/v1/internal/organizations/1111111/inventory?limit=10' x-rh-swatch-psk:placeholder Origin:console.redhat.com

Verification

We're expecting is_marketplace: true for 9999999, and is_marketplace: false for 1111111

http ':8000/api/rhsm-subscriptions/v1/internal/organizations/9999999/inventory?limit=10' x-rh-swatch-psk:placeholder Origin:console.redhat.com | jq '.consumer_inventories[0] | {org_id, provider_id, is_marketplace, cloud_provider, provider_type}'
{
  "org_id": "9999999",
  "provider_id": "i-0c892607c9a3820c6",
  "is_marketplace": true,
  "cloud_provider": "aws",
  "provider_type": "aws"
}
http ':8000/api/rhsm-subscriptions/v1/internal/organizations/1111111/inventory?limit=10' x-rh-swatch-psk:placeholder Origin:console.redhat.com | jq '.consumer_inventories[0] | {org_id, provider_id, is_marketplace, cloud_provider, provider_type}'
{
  "org_id": "1111111",
  "provider_id": "i-d4e435fa4dc3f9189",
  "is_marketplace": false,
  "cloud_provider": "aws",
  "provider_type": "aws"
}

@lindseyburnett lindseyburnett force-pushed the lburnett/swatch-2915-rhel-byos-identification branch from 84eba36 to ced5969 Compare October 2, 2024 15:08
@lindseyburnett lindseyburnett added QE Pull request should be approved by QE before merge Dev Pull requests that need developer review labels Oct 2, 2024
@lindseyburnett lindseyburnett force-pushed the lburnett/swatch-2915-rhel-byos-identification branch from ced5969 to bf8b439 Compare October 2, 2024 19:07
Our previous implementation was based off the incorrect assumption that the presence of an aws billing code on a system fact indicated that system was tied to a marketplace subscription.  We've since learned that any system provisioned in aws, regardless of if they're paying for the subscription through aws, gets an aws billing code associated with it.

Systems that were provisioned with a red hat gold image get specifically *bp-63a5400a* as a billing product code.  PM identified this product code as indicating BYOS.  If a billing product code is absent, that also indicates BYOS.  A meeting with PM was had, and it was decided that we would maintain a list of product codes to consider BYOS instead of the opposite.  If a billing product code is present and it doesn't appear in the list of BYOS product codes, then consider it a Marketplace system.  Similar updates will need to happen with other system reporters since HBI doesn't centralize any normalization.
@lindseyburnett lindseyburnett force-pushed the lburnett/swatch-2915-rhel-byos-identification branch from bf8b439 to 4301b36 Compare October 2, 2024 19:08
@ntkathole
Copy link
Member

/retest

@kahowell kahowell self-assigned this Oct 3, 2024
@kahowell kahowell added Dev/approved Pull requests that have been approved by all assigned developers and removed Dev Pull requests that need developer review labels Oct 3, 2024
@lindseyburnett lindseyburnett changed the title DRAFT: SWATCH-2915 Specify BYOS aws product code SWATCH-2915 Specify BYOS aws product code Oct 3, 2024
@lindseyburnett lindseyburnett marked this pull request as ready for review October 3, 2024 18:50
@liwalker-rh
Copy link

/retest

1 similar comment
@lindseyburnett
Copy link
Contributor Author

/retest

@liwalker-rh
Copy link

/retest

@liwalker-rh
Copy link

Tested locally and seems to work as expected. Automation is looking pretty good, just dealing with MR pipeline issues and flaky runs in EE (not related to is_marketplace). New test worked well when testing locally in stage, so hoping by first thing next week automation can get merged. Feel free to merge this sooner.

IQE MR: https://gitlab.cee.redhat.com/insights-qe/iqe-rhsm-subscriptions-plugin/-/merge_requests/891

@liwalker-rh liwalker-rh added QE/approved Pull requests that have been approved by all assigned QEs and removed QE Pull request should be approved by QE before merge labels Oct 4, 2024
@liwalker-rh
Copy link

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev/approved Pull requests that have been approved by all assigned developers QE/approved Pull requests that have been approved by all assigned QEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants