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-14544 - Add CentralRequest field documentation #743

Merged
merged 3 commits into from
Feb 15, 2023
Merged

Conversation

SimonBaeumer
Copy link
Member

@SimonBaeumer SimonBaeumer commented Jan 20, 2023

Description

Added CentralRequest documentation.

Checklist (Definition of Done)

  • Unit and integration tests added
  • Added test description under Test manual
  • Evaluated and added CHANGELOG.md entry if required
  • 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.

Test manual

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 20, 2023

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

@SimonBaeumer SimonBaeumer temporarily deployed to development January 20, 2023 09:38 — with GitHub Actions Inactive
Region string `json:"region"`
// ClusterID is the data-plane cluster ID
ClusterID string `json:"cluster_id" gorm:"index"`
// CloudProvider ...
CloudProvider string `json:"cloud_provider"`
Copy link
Member Author

Choose a reason for hiding this comment

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

Double-check in production in production system

Copy link
Contributor

Choose a reason for hiding this comment

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

Cloud provider that runs the data plane instance. Also the cloud provider that owns the customer account we bill again.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Region string `json:"region"`
// ClusterID is the data-plane cluster ID
ClusterID string `json:"cluster_id" gorm:"index"`
// CloudProvider ...
CloudProvider string `json:"cloud_provider"`
CloudAccountID string `json:"cloud_account_id"`
Copy link
Member Author

Choose a reason for hiding this comment

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

Double-check in production in production system. Maybe remove it (cc @johannes94)

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it is used by @kovayur, see:

rr.BillingMarketplaceAccount(dinosaur.CloudAccountID)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the billing cloud account, definitely don't remove or we won't get paid ;-).

Copy link
Member Author

Choose a reason for hiding this comment

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

done

MultiAZ bool `json:"multi_az"`
// MultiAZ enables multi AZ support
MultiAZ bool `json:"multi_az"`
// Name of the ACS instance
Name string `json:"name" gorm:"index"`
Status string `json:"status" gorm:"index"`
Copy link
Member Author

Choose a reason for hiding this comment

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

Lifecycle status of the CentralRequest, link to constants

Copy link
Member Author

Choose a reason for hiding this comment

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

done

MultiAZ bool `json:"multi_az"`
// MultiAZ enables multi AZ support
MultiAZ bool `json:"multi_az"`
// Name of the ACS instance
Name string `json:"name" gorm:"index"`
Status string `json:"status" gorm:"index"`
SubscriptionID string `json:"subscription_id"`
Copy link
Member Author

Choose a reason for hiding this comment

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

by @kovayur

SubscriptionID is returned by ams (ocm) when the user’s (owner) quota is reserved for Central

Copy link
Member Author

Choose a reason for hiding this comment

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

Owner = OCM owner who created the tenant (email), how is it populated? (Identify ID type, seems to be different for RH employees joined after a specific date, or based on the preferred username (OpenID feature, ocm whoami prints the active username))
OwnerAccountID and OrganisationID maybe the same fields.

Code snippet:

dinosaurRequest.Owner, _ = claims.GetUsername()
dinosaurRequest.OrganisationID, _ = claims.GetOrgID()
dinosaurRequest.OwnerAccountID, _ = claims.GetAccountID()
dinosaurRequest.OwnerUserID, _ = claims.GetUserID()
tenantUsernameClaim = "username"

//-------------- 

// GetUsername ...
func (c *ACSClaims) GetUsername() (string, error) {
	if idx, val := arrays.FindFirst(func(x interface{}) bool { return x != nil },
		(*c)[tenantUsernameClaim], (*c)[alternateTenantUsernameClaim]); idx != -1 {
		if userName, ok := val.(string); ok {
			return userName, nil
		}
	}
	return "", fmt.Errorf("can't find neither %q or %q attribute in claims",
		tenantUsernameClaim, alternateTenantUsernameClaim)
}

//--------------

// sso.redhat.com token claim keys.
	alternateTenantUsernameClaim = "preferred_username"
	tenantUserIDClaim            = "account_id"
	tenantSubClaim               = "sub"
	// Only service accounts that have been created via the service_accounts API have this claim set.
	alternateTenantIDClaim = "rh-org-id

Copy link
Member Author

@SimonBaeumer SimonBaeumer Jan 20, 2023

Choose a reason for hiding this comment

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

OwnerUserID, OwnerAccountID needs investigation. Is the same in @johannes94 database. Not equal to organisation ID.

Copy link
Contributor

@stehessel stehessel Jan 21, 2023

Choose a reason for hiding this comment

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

organisation ID and organisation name are the Red Hat SSO organisation identifiers - it identifies a customer organisation, e.g. 16678382 and IBM. We need the id for authn/z, and the name for observability purposes. There can be many users that part of one customer organisation - for example, all Red Hat employee accounts are part of org_id=11009103.

OwnerAccountID will be used in telemetry, it is the account_id claim of the Red Hat SSO token. OwnerUserID is the subject claim (confusingly it is NOT the user_id claim) of the Red Hat SSO token - this one I don't know if we use it anywhere.

Copy link
Contributor

@stehessel stehessel Jan 21, 2023

Choose a reason for hiding this comment

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

Owner is the Red Hat SSO login name. It is either the email, or the user name, depending on what the user chose to login with. It's displayed in the console UI.

Copy link
Member Author

Choose a reason for hiding this comment

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

@stehessel Where do you see the OrganisationName? I could find the field in the CentralRequest struct.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rebased and added it

@rukletsov rukletsov self-requested a review January 20, 2023 17:13
MultiAZ bool `json:"multi_az"`
// MultiAZ enables multi AZ support
MultiAZ bool `json:"multi_az"`
// Name of the ACS instance
Name string `json:"name" gorm:"index"`
Status string `json:"status" gorm:"index"`
SubscriptionID string `json:"subscription_id"`
Copy link
Contributor

Choose a reason for hiding this comment

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

SubscriptionID is returned by AMS and identifies a Central instance in their system. We need it to deregister instances again from AMS.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@SimonBaeumer SimonBaeumer temporarily deployed to development February 15, 2023 10:31 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer marked this pull request as ready for review February 15, 2023 10:31
@SimonBaeumer SimonBaeumer temporarily deployed to development February 15, 2023 10:31 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer changed the title Add CentralRequest field documentation ROX-14544 - Add CentralRequest field documentation Feb 15, 2023
Region string `json:"region"`
ClusterID string `json:"cluster_id" gorm:"index"`
CloudProvider string `json:"cloud_provider"`
// Region is the cloud region the service is deployed in, i.e. us-east-1
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you end sentence comments with a "." everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

MultiAZ bool `json:"multi_az"`
Name string `json:"name" gorm:"index"`
Status string `json:"status" gorm:"index"`
// MultiAZ enables multi AZ support
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd spell out availability zone in the explanation.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

SubscriptionID string `json:"subscription_id"`
Owner string `json:"owner" gorm:"index"` // TODO: ocm owner?
// Owner is the Red Hat SSO login name. It is either the email, or the user name, depending on what the user chose to login with. It's displayed in the console UI.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Owner is the Red Hat SSO login name. It is either the email, or the user name, depending on what the user chose to login with. It's displayed in the console UI.
// Owner is the Red Hat SSO login name of the user who created the instance. It is either the email, or the user name, depending on what the user chose to login with. It's displayed in the console UI.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Owner string `json:"owner" gorm:"index"` // TODO: ocm owner?
// Owner is the Red Hat SSO login name. It is either the email, or the user name, depending on what the user chose to login with. It's displayed in the console UI.
Owner string `json:"owner" gorm:"index"`
// OwnerAccountID is used in telemetry, it is the account_id claim of the Red Hat SSO token.
Copy link
Contributor

Choose a reason for hiding this comment

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

We switched to user_id claim in telemetry. owner_account_id is no longer used as far as I can tell.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is never read anywhere, only set once in fleet-manager. Is it safe to assume that we can remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

How could I test that the change worked?

Copy link
Contributor

Choose a reason for hiding this comment

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

How could I test that the change worked?

You can take a look at Telemetry events in https://app.segment.com/redhat-devtools/sources/acs_instances_backend_dev/debugger.

Is it safe to assume that we can remove it?

I think we can remove this field, yes. Just need to be careful with backwards/forwards compatibility.

Copy link
Member Author

@SimonBaeumer SimonBaeumer Feb 15, 2023

Choose a reason for hiding this comment

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

Would it be okay for you to mark it here as deprecated and removing the field in a follow-up ticket?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that makes sense.

OrganisationID string `json:"organisation_id" gorm:"index"`
Host string `json:"host"`
// OrganisationID is a Red Hat SSO organisation identifier to identify a customer. It is needed as an id for authn/z, and the name for observability purposes.
OrganisationID string `json:"organisation_id" gorm:"index"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not 100% true (depends on definition of customer), it is just one customer organisation. For example IBM has many Red Hat orgs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it to:
// OrganisationID identifies a customer's organisation. It is needed as an id for authn/z, and the name for observability purposes.

Host string `json:"host"`
// OrganisationID is a Red Hat SSO organisation identifier to identify a customer. It is needed as an id for authn/z, and the name for observability purposes.
OrganisationID string `json:"organisation_id" gorm:"index"`
// OrganisationName is a Red Hat SSO organisation identifier to identify a customer. It is needed as an id for authn/z, and the name for observability purposes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Organisation names not unique. Its purpose is mostly human readability and observability purposes (e.g. display in dashboards).

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@SimonBaeumer SimonBaeumer temporarily deployed to development February 15, 2023 12:48 — with GitHub Actions Inactive
Copy link
Contributor

@stehessel stehessel left a comment

Choose a reason for hiding this comment

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

Thanks for going over these 🚀

@openshift-ci openshift-ci bot added the lgtm label Feb 15, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 15, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SimonBaeumer, stehessel

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:

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 Feb 15, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 15, 2023

New changes are detected. LGTM label has been removed.

@SimonBaeumer SimonBaeumer temporarily deployed to development February 15, 2023 14:31 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer enabled auto-merge (squash) February 15, 2023 14:34
@SimonBaeumer SimonBaeumer merged commit dc1c855 into main Feb 15, 2023
@SimonBaeumer SimonBaeumer deleted the sb/add-doc branch February 15, 2023 15:06
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.

3 participants