Skip to content

Conversation

@sujay-hashicorp
Copy link
Contributor

Description

Added Census client for handling operator utilization related calls

Testing & Reproduction steps

n/a

Links

n/a

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@sujay-hashicorp sujay-hashicorp added the backport/all Apply backports for all active releases per .release/versions.hcl label Sep 26, 2025
@sujay-hashicorp sujay-hashicorp requested a review from a team as a code owner September 26, 2025 05:07
@github-actions github-actions bot added the theme/api Relating to the HTTP API interface label Sep 26, 2025
sujay-hashicorp added a commit that referenced this pull request Sep 26, 2025
sujay-hashicorp added a commit that referenced this pull request Sep 26, 2025
Copy link
Contributor

@srahul3 srahul3 left a comment

Choose a reason for hiding this comment

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

Added few minor comments.

if q != nil {
r.setQueryOptions(q)
}
if req != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, the request must not be optional. return appropriate error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per the CLI, all the flags are optional, i.e. each of message, today-only and send_report will have a default value. Therefore, a GET request without any query params is valid and an empty request should be handled with default value.
As for CustomerID, it is a required parameter for CreateBundle but it can be derived later in reporting package itself using license data. Hence, I have removed it from here.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the rational behind passing the Customer ID in CLI. This information is already available in License and hence it can be bundled in the response.

r.setQueryOptions(q)
}
if req != nil {
if req.CustomerID != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, the CustomerID must not be optional. return error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this as a request param as it will be derived in reporting package using the license data at the time of starting reporting agent for metric collection. This CustomerID will be maintained in cache there after for Bundle creation.

api/txn.go Outdated
type CensusOp string

const (
CensusPut CensusOp = "put"
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 take care of linting issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the lint errors now

sujay-hashicorp added a commit that referenced this pull request Sep 26, 2025
sujay-hashicorp added a commit that referenced this pull request Sep 26, 2025
sujay-hashicorp added a commit that referenced this pull request Sep 26, 2025
@sujay-hashicorp sujay-hashicorp added backport/1.21 This release series is longer active on CE, use backport/ent/1.21 backport/all Apply backports for all active releases per .release/versions.hcl and removed backport/all Apply backports for all active releases per .release/versions.hcl backport/1.21 This release series is longer active on CE, use backport/ent/1.21 labels Sep 26, 2025
Copy link
Contributor

@srahul3 srahul3 left a comment

Choose a reason for hiding this comment

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

✅ LGTM

if q != nil {
r.setQueryOptions(q)
}
if req != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the rational behind passing the Customer ID in CLI. This information is already available in License and hence it can be bundled in the response.

// Utilization generates a census utilization bundle by calling the
// /v1/operator/utilization endpoint. The returned byte slice contains the bundle
// JSON payload suitable for saving to disk or further processing.
func (c *Census) Utilization(req *UtilizationBundleRequest, q *QueryOptions) ([]byte, *QueryMeta, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the response struct method in followup PR.

@sujay-hashicorp sujay-hashicorp merged commit 72918f9 into main Sep 26, 2025
122 checks passed
@hc-github-team-consul-core hc-github-team-consul-core added the backport/1.21 This release series is longer active on CE, use backport/ent/1.21 label Sep 26, 2025
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sujay-hashicorp! a backport is missing for this PR [22837] for versions [1.18,1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

1 similar comment
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sujay-hashicorp! a backport is missing for this PR [22837] for versions [1.18,1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/all Apply backports for all active releases per .release/versions.hcl backport/ent/1.18 Changes are backported to 1.18 ent backport/ent/1.19 Changes are backported to 1.19 ent backport/ent/1.20 backport to ent 1.20 backport/1.21 This release series is longer active on CE, use backport/ent/1.21 theme/api Relating to the HTTP API interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants