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: support for new quotas submodule and standard DA #208

Merged
merged 37 commits into from
Nov 29, 2024
Merged

Conversation

Soaib024
Copy link
Member

@Soaib024 Soaib024 commented Oct 18, 2024

Description

issue: https://github.ibm.com/GoldenEye/issues/issues/11125

  • New submodule to set pull traffic and quota limit
  • Added new DA which can be used to create a namespace, upgarde to standard plan, set pull traffic and storage quota
    (At a time only one namespace can be created, and plan and quotas can be set only for one registry this is done to avoid complex input variable (list of object))

Release required?

  • No release
  • Patch release (x.x.X)
  • Minor release (x.X.x)
  • Major release (X.x.x)
Release notes content

Run the pipeline

If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.

Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:

/run pipeline

Checklist for reviewers

  • If relevant, a test for the change is included or updated with this PR.
  • If relevant, documentation for the change is included or updated with this PR.

For mergers

  • Use a conventional commit message to set the release level. Follow the guidelines.
  • Include information that users need to know about the PR in the commit message. The commit message becomes part of the GitHub release notes.
  • Use the Squash and merge option.

@Soaib024 Soaib024 changed the title [WIP] Add da Support for new quotas submodule and standard DA Oct 18, 2024
@Soaib024
Copy link
Member Author

Upgrade test is expected to fail as previous directory used by it no longer exists
Screenshot 2024-10-18 at 4 02 08 PM

@Soaib024 Soaib024 changed the title Support for new quotas submodule and standard DA feat: support for new quotas submodule and standard DA Oct 18, 2024
@Soaib024 Soaib024 marked this pull request as ready for review October 18, 2024 10:48
destroy_method = "PATCH"
destroy_path = "//${var.container_registry_endpoint}/api/v1/quotas"
destroy_data = jsonencode({
"storage_megabytes" : 500 # set to default 500 MB
Copy link
Member

Choose a reason for hiding this comment

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

This might be ok but my worry here is that if a user does not start at 500mb the destroy is not reverting to the previous value. Account settings with IAM settings have a similar problem. We should check how that module handles it. @ocofaigh this is what I mentioned

Copy link
Member

Choose a reason for hiding this comment

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

Here is what I was thinking of. The ibm_iam_account_settings resource supports setting the value NOT_SET for some account settings. And as per provider docs:

NOT_SET - to 'unset' a previous set value.

I don't know how the provider is doing this? Are the storing the previous value in the state?

Copy link
Member Author

Choose a reason for hiding this comment

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

We are using restapi provider here and there isn't any previous value in the state file, it's mostly the api response

Copy link
Member

Choose a reason for hiding this comment

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

Not sure what else we can do here. Do we have a provider issue open to support doing this in provider?

Copy link
Member

Choose a reason for hiding this comment

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

Created the provider issue -> IBM-Cloud/terraform-provider-ibm#5816

Copy link
Member

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

Left some comments. Also the DA should support taking in an existing namespace and configuring it

ibm_catalog.json Outdated Show resolved Hide resolved
ibm_catalog.json Outdated Show resolved Hide resolved
destroy_method = "PATCH"
destroy_path = "//${var.container_registry_endpoint}/api/v1/quotas"
destroy_data = jsonencode({
"storage_megabytes" : 500 # set to default 500 MB
Copy link
Member

Choose a reason for hiding this comment

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

Here is what I was thinking of. The ibm_iam_account_settings resource supports setting the value NOT_SET for some account settings. And as per provider docs:

NOT_SET - to 'unset' a previous set value.

I don't know how the provider is doing this? Are the storing the previous value in the state?

modules/quotas/version.tf Outdated Show resolved Hide resolved
modules/quotas/version.tf Outdated Show resolved Hide resolved

variable "region" {
type = string
description = "The IBM Cloud region where the container registry namespace and retentation policy will be created."
Copy link
Member

Choose a reason for hiding this comment

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

It seems your only using region in the provider config. Meaning its going to apply to all resources in the DA. Since the namespace resources doesn't take in any region value, I suspect it takes it from the provider config? So what happens if a user want to create a global namespace? Does region support taking in the string global? If so, I suspect you will want to use a provider alias just for namespace creation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, using global as a region works

I have added a new provider block with namespace alias and also renamed region variable to namespace_region

This block will be used for resource group and to get a iam token

provider "ibm" {
  ibmcloud_api_key = var.ibmcloud_api_key
  region           = "us-south"
}

This block will be used to create namespace and set retentation policy

provider "ibm" {
  alias            = "namespace"
  ibmcloud_api_key = var.ibmcloud_api_key
  region           = var.namespace_region
}

solutions/standard/variables.tf Show resolved Hide resolved
variable "container_registry_endpoint" {
description = "The endpoint of the ICR region, eg. https://us.icr.io or https://de.icr.io"
type = string
default = "us.icr.io"
Copy link
Member

Choose a reason for hiding this comment

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

why do we need to ask for this if we already ask for region? I suspect we can create a mapping between region and the corresponding CR endpoint.
We may though wan't to ask what endpoint type to use, and default to private

Copy link
Member Author

Choose a reason for hiding this comment

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

region field was used for namespace, whereas the registry endpoint field is used to set the plan and quotas for the registry. I have renamed region to namespace_region as it is more intuitive.

Additionally, there isn't a direct one-to-one mapping between regions and ICR endpoints. For instance, if I want to use the jp.icr.io registry, its local region name is ap-north, but it's also known as jp-tok.

I think directly inputting the endpoint with a clear description indicating that it will be used for updating plan and quotas would be a simpler and more convenient approach also we might need to maintain mapping and validation if theres any changes in future.

However, if you think a mapping would be beneficial, let me know, and I can create it based on this table https://cloud.ibm.com/docs/Registry?topic=Registry-registry_overview#registry_regions_local

Copy link
Member

Choose a reason for hiding this comment

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

I think if we can programatically determine this we should. I'm trying to reduce the amount of places where the consumer can make a mistake. If they entered jp-tok for namespace_region for example, they may not realise they also need to update this variable to be jp.icr.io. So I think its a better user experience if we do mapping. We do it in other DAs too (for example here)

Copy link
Member

Choose a reason for hiding this comment

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

one thing we may need to expose is an endpoint type incase user doesn't have access to public endpoint, and does have access to the IBM private one. But perhaps we can re-use the value passed with the provider_visibility input?

solutions/standard/variables.tf Show resolved Hide resolved
solutions/standard/outputs.tf Show resolved Hide resolved
ibm_catalog.json Outdated Show resolved Hide resolved
@Soaib024
Copy link
Member Author

Soaib024 commented Nov 3, 2024

/run pipeline

@Soaib024 Soaib024 requested a review from ocofaigh November 4, 2024 10:09
Copy link
Member

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

see latest comments

solutions/standard/variables.tf Outdated Show resolved Hide resolved

variable "storage_megabytes" {
type = number
description = "The storage quota in megabytes for the container registry. Use -1 for unlimited storage."
Copy link
Member

Choose a reason for hiding this comment

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

What is the behaviour is no value is set? The description should include this information

ibm_catalog.json Outdated Show resolved Hide resolved
solutions/standard/variables.tf Outdated Show resolved Hide resolved
solutions/standard/variables.tf Outdated Show resolved Hide resolved
solutions/standard/main.tf Show resolved Hide resolved
destroy_method = "PATCH"
destroy_path = "//${var.container_registry_endpoint}/api/v1/quotas"
destroy_data = jsonencode({
"storage_megabytes" : 500 # set to default 500 MB
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what else we can do here. Do we have a provider issue open to support doing this in provider?

ibm_catalog.json Outdated Show resolved Hide resolved
examples/complete/provider.tf Outdated Show resolved Hide resolved
tests/pr_test.go Show resolved Hide resolved
tests/other_test.go Outdated Show resolved Hide resolved
@ocofaigh
Copy link
Member

@Soaib024 what is the latest here?

@iamar7
Copy link
Member

iamar7 commented Nov 25, 2024

/run pipeline

@iamar7
Copy link
Member

iamar7 commented Nov 25, 2024

/run pipeline

@iamar7
Copy link
Member

iamar7 commented Nov 25, 2024

/run pipeline

@iamar7
Copy link
Member

iamar7 commented Nov 25, 2024

/run pipeline

@iamar7
Copy link
Member

iamar7 commented Nov 25, 2024

/run pipeline

@iamar7
Copy link
Member

iamar7 commented Nov 25, 2024

/run pipeline

@iamar7 iamar7 self-assigned this Nov 25, 2024
@iamar7
Copy link
Member

iamar7 commented Nov 25, 2024

/run pipeline

@iamar7
Copy link
Member

iamar7 commented Nov 25, 2024

/run pipeline

@iamar7 iamar7 requested a review from ocofaigh November 26, 2024 19:50
@ocofaigh ocofaigh merged commit bf49fb9 into main Nov 29, 2024
2 checks passed
@ocofaigh ocofaigh deleted the add-da branch November 29, 2024 16:42
@terraform-ibm-modules-ops
Copy link
Contributor

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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