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

ROX-16587: API for switching billing model of a central #1598

Merged
merged 26 commits into from
Mar 26, 2024

Conversation

parametalol
Copy link
Contributor

@parametalol parametalol commented Jan 18, 2024

Description

Allow for switching:

  • central billing model: from standard to marketplace-aws and back;
  • product: from RHACSTrial to RHACS and, therefore, instance type from eval to standard.

Unblocked by OCM-4209.

Checklist (Definition of Done)

  • Unit and integration tests added
  • Added test description under Test manual
  • Documentation added if necessary (i.e. changes to dev setup, test execution, ...)
  • CI and all relevant tests are passing
  • Add the ticket number to the PR title if available, i.e. ROX-12345: ...
  • Discussed security and business related topics privately. Will move any security and business related topics that arise to private communication channel.
  • Add secret to app-interface Vault or Secrets Manager if necessary
  • RDS changes were e2e tested manually
  • Check AWS limits are reasonable for changes provisioning new resources

Test manual

marketplace-aws to standard

Switching marketplace-aws to standard for local instance:

$ curl -H $AUTH "http://localhost:8000/api/rhacs/v1/admin/centrals/cml530p8pthd6k6u5i50/billing-model" \
-X PATCH \
-d '{"model": "standard", "cloud_provider": "aws", "cloud_account_id": "676188018476"}'
$

Resulting quota_cost:

    {
      "allowed": 25,
      "consumed": 1,
      "href": "/api/accounts_mgmt/v1/organizations/2D58jWME1XKVfAl0h3MGH5eekmc/quota_cost",
      "kind": "QuotaCost",
      "organization_id": "2D58jWME1XKVfAl0h3MGH5eekmc",
      "quota_id": "cluster|rhinfra|rhacs|standard",
      "version": "4d479bfc-8be3-4f16-817b-67220f124b21"
    },
    {
      "allowed": 50,
      "consumed": 6,
      "href": "/api/accounts_mgmt/v1/organizations/2D58jWME1XKVfAl0h3MGH5eekmc/quota_cost",
      "kind": "QuotaCost",
      "organization_id": "2D58jWME1XKVfAl0h3MGH5eekmc",
      "quota_id": "cluster|rhinfra|rhacs|marketplace",
      "version": "4d479bfc-8be3-4f16-817b-67220f124b21"
    },

Changing back to marketplace-aws transfers the quota back.

eval to standard

me@work$ curl -s -H $AUTH "http://localhost:8000/api/rhacs/v1/admin/centrals" | jq
{
  "kind": "CentralList",
  "page": 1,
  "size": 1,
  "total": 1,
  "items": [
    {
      "id": "cnj1so2afmud6k403p10",
      "kind": "CentralRequest",
      "href": "/api/rhacs/v1/centrals/cnj1so2afmud6k403p10",
      "status": "provisioning",
      "cloud_provider": "aws",
      "multi_az": true,
      "region": "standalone",
      "owner": "mipetrov@redhat.com",
      "name": "test-central-3",
      "host": "acs-cnj1so2afmud6k403p10.cluster.local",
      "created_at": "2024-03-04T19:17:52.119201Z",
      "updated_at": "2024-03-04T19:50:22.52576Z",
      "instance_type": "eval",
      "traits": [
        "trait1",
        "trait2"
      ]
    }
  ]
}
me@work$ curl -H $AUTH "http://localhost:8000/api/rhacs/v1/admin/centrals/cnj1so2afmud6k403p10/billing-model" \
-X PATCH \
-d '{"product": "RHACS", "model": "strandard"}'
me@work$ curl -s -H $AUTH "http://localhost:8000/api/rhacs/v1/admin/centrals" | jq
{
  "kind": "CentralList",
  "page": 1,
  "size": 1,
  "total": 1,
  "items": [
    {
      "id": "cnj1so2afmud6k403p10",
      "kind": "CentralRequest",
      "href": "/api/rhacs/v1/centrals/cnj1so2afmud6k403p10",
      "status": "provisioning",
      "cloud_provider": "aws",
      "multi_az": true,
      "region": "standalone",
      "owner": "mipetrov@redhat.com",
      "name": "test-central-3",
      "host": "acs-cnj1so2afmud6k403p10.cluster.local",
      "created_at": "2024-03-04T19:17:52.119201Z",
      "updated_at": "2024-03-04T19:53:42.661576Z",
      "instance_type": "standard",
      "traits": [
        "trait1",
        "trait2"
      ]
    }
  ]
}

Copy link
Contributor

openshift-ci bot commented Jan 18, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@parametalol parametalol marked this pull request as ready for review January 29, 2024 12:48
Copy link
Contributor

@ivan-degtiarenko ivan-degtiarenko left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@dhaus67 dhaus67 left a comment

Choose a reason for hiding this comment

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

Minor comments, otherwise LGTM (since I have limited exposure to the billing stuff, would be great if @ivan-degtiarenko or @stehessel could TAL and approve as well)

internal/dinosaur/pkg/services/dinosaur.go Show resolved Hide resolved
internal/dinosaur/pkg/services/dinosaur.go Outdated Show resolved Hide resolved
internal/dinosaur/pkg/services/dinosaur.go Outdated Show resolved Hide resolved
internal/dinosaur/pkg/services/dinosaur.go Outdated Show resolved Hide resolved
internal/dinosaur/pkg/services/quota/ams_quota_service.go Outdated Show resolved Hide resolved
Copy link
Contributor

openshift-ci bot commented Mar 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 0x656b694d, dhaus67, ivan-degtiarenko

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [dhaus67,ivan-degtiarenko]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot removed the lgtm label Mar 26, 2024
Copy link
Contributor

openshift-ci bot commented Mar 26, 2024

New changes are detected. LGTM label has been removed.

@parametalol parametalol merged commit d13db4f into main Mar 26, 2024
8 checks passed
@parametalol parametalol deleted the michael/ROX-16587-switch-model branch March 26, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants