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

feat: add ibm_event_streams_quota data source and resource #5610

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

kccox
Copy link
Contributor

@kccox kccox commented Sep 4, 2024

What has been done?

Add a data source and resource for the IBM Event Streams quotas.

  • Quotas are created on an Event Streams service instance.
  • Quotas define two rate limits, for producers and consumers. Rates are in bytes/second. A rate of -1 means no limit.
  • A default quota can be created which applies to all users.
  • A quota can also be created for a user, identified by IAM ID.

The quota data model used by both data source and resource is:

  • resource_instance_id: The CRN of the Event Streams service instance. (Our existing models for topics and schemas also use this to identify the service instance.) Required in data source and resource.
  • entity: "default", or the IAM ID of the user. Required in data source and resource.
  • producer_byte_rate: The producer limit, using -1 for no limit. Computed in data source, required in resource.
  • consumer_byte_rate: The consumer limit, using -1 for no limit. Computed in data source, required in resource.

The implementations use the Event Streams SDK client for our admin-rest API.

  • The client is created similarly to the schema registry client:
    • config.go adds a client for this API using the SDK
    • The create/read/update/delete functions initialize the client with the REST endpoint (kafka_http_url)

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes internal Event Streams feature request from BNPP

Output from acceptance testing:

$ make testacc TEST=./ibm/service/eventstreams TESTARGS='-run=TestAccIBMEventStreamsQuotaDataSource\|TestAccIBMEventStreamsQuotaResource'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./ibm/service/eventstreams -v -run=TestAccIBMEventStreamsQuotaDataSource\|TestAccIBMEventStreamsQuotaResource -timeout 700m
  (skipping many warnings to set environment variables not used by this test)
=== RUN   TestAccIBMEventStreamsQuotaDataSource
--- PASS: TestAccIBMEventStreamsQuotaDataSource (54.73s)
=== RUN   TestAccIBMEventStreamsQuotaResource
--- PASS: TestAccIBMEventStreamsQuotaResource (67.78s)
PASS
ok  	github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/eventstreams
...

@uchenwankwo
Copy link

LGTM
-- Uche Nwankwo (OM for Event Streams)

@@ -3325,6 +3334,20 @@ func (c *Config) ClientSession() (interface{}, error) {
})
}

esAdminRestV1Options := &adminrestv1.AdminrestV1Options{
Copy link
Collaborator

Choose a reason for hiding this comment

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

check other client session creation for visibility . If visbility is private then we construct service endpoint with private does your serivce support private endpoints

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Visibility doesn't apply in our case, we do not set visibility in the client session. The code interacts with an instance of the Event Streams service which the user has provisioned. The endpoint is determined by a URL exposed in the instance metadata.

if err != nil {
log.Printf("[DEBUG] GetQuota failed with error: %s and response: %s\n", err, response)
if response != nil && response.StatusCode == 404 {
return diag.FromErr(fmt.Errorf("Quota for '%s' does not exist", entity))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you migrate to new error framework as announced in different slack channels

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have migrated to the flex framework, and also updated #5621.

@hkantare hkantare merged commit 87c26c0 into IBM-Cloud:master Oct 14, 2024
1 check passed
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.

3 participants