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

only query subscriptions service with sku based features #161

Merged

Conversation

dagbay-rh
Copy link
Contributor

Summary

  • in the /services endpoint, only query subscriptions service for features that are sku based, aka have >1 sku attached to them

Why

Right now we are querying IT subscriptions service for all features defined in the ENT_FEATURES environment variable. In stage/prod, this is set to: ansible,smart_management,rhods,rhoam,rhosak,openshift,acs

This config results in the following request made to subs service from entitlements:

GET https://subscription.api.redhat.com/svcrest/subscription/v5/featureStatus?features=ansible&features=smart_management&features=rhods&features=rhoam&features=rhosak&features=openshift&features=acs&accountId=123

The openshift feature is not configured to be sku based in prod, which means bundle_sync does not create this feature in subs service when it runs, which results in errors in subs service when we eventually include &features=openshift in our query

So this PR adds a bit of logic to only include features in our query that are sku based, aka features that are 1) included in ENT_FEATURES, 2) have a non nil, non zero sized list of skus attached to them in our configuration

here is the prod entitlements config for reference: https://github.com/RedHatInsights/entitlements-config/blob/master/configs/prod/bundles.yml
notice how the openshift bundle does not have any skus defined for it. Same with a few others. This means they will not / should not have a feature created in IT subs service and that we should not query for it

Testing

I copied the prod config locally to make things simple

copy prod config (linked above) to `.../entitlements-api-go/local/prod-bundles.yml

start entitlements locally with the following config:

export ENT_KEY=<path to your certs>/nonprod-redhatcloudservices.key
export ENT_CERT=<path to your certs>/nonprod-redhatcloudservices.crt
export ENT_CA_PATH=/home/danielagbay/workspace/consoledot/entitlements-api-go/resources/ca.crt
export ENT_SUBS_HOST=https://subscription.api.redhat.com
export ENT_BUNDLE_INFO_YAML=<path to your entitlements repo>/entitlements-api-go/local/prod-bundles.yml
export ENT_FEATURES=ansible,smart_management,rhods,rhoam,rhosak,openshift,acs

hit the entitlements endpoint:

curl --location 'http://localhost:3000/api/entitlements/v1/services' \
--header 'x-rh-identity: eyAiaWRlbnRpdHkiIDogeyAiYWNjb3VudF9udW1iZXIiOiAiNTQwMTU1IiwgInR5cGUiOiAiVXNlciIsICJpbnRlcm5hbCI6IHsgIm9yZ19pZCI6ICIxMTAwOTEwMyIgfSwgInVzZXIiOiB7ICJpc19vcmdfYWRtaW4iOiB0cnVlIH0gfSB9Cg==' \

check the service logs, and you should see a log made about the request to subs service like so:

{
  "cache_hit": false,
  "caller": "github.com/RedHatInsights/entitlements-api-go/controllers.Services.func1",
  "file": "/home/danielagbay/workspace/consoledot/entitlements-api-go/controllers/subscriptions.go:226",
  "logLevel": "info",
  "msg": "subs call complete",
  "subs_call_duration": 0.611769356,
  "ts": "2024-01-08T16:44:19-06:00",
  "url": "https://subscription.api.redhat.com/svcrest/subscription/v5/featureStatus?features=ansible&features=smart_management&features=rhods&features=rhoam&features=rhosak&features=acs&accountId=11009103"
}

and then we can verify the request url did not contain the features=openshift param as expected

Copy link
Contributor

@coderbydesign coderbydesign left a comment

Choose a reason for hiding this comment

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

Having an issue with my local dev environment, but approving based on the code! 🌴

@dagbay-rh dagbay-rh merged commit 4942e1e into RedHatInsights:main Jan 15, 2024
4 checks passed
@dagbay-rh dagbay-rh deleted the query-only-sku-based-features branch January 15, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants