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: added mirroring support #327

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

feat: added mirroring support #327

wants to merge 13 commits into from

Conversation

Ak-sky
Copy link
Member

@Ak-sky Ak-sky commented Oct 29, 2024

Description

Added ES mirroring support for disaster recovery usecase.
Git Issue

Release required?

  • No release
  • Patch release (x.x.X)
  • Minor release (x.X.x)
  • Major release (X.x.x)
Release notes content
  • Added support for mirroring for disaster recovery usecase.

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.

@JunliWang
Copy link
Contributor

JunliWang commented Oct 29, 2024

mirroring needs a parameters_json with a structure like this, so that cluster provisioning will come with additional workerpool and mirrormaker application running on it.
source_crn, source_alias, and target_alias are user input and required.

parameters_json = jsonencode(
    {
      mirroring = {
        source_crn   = data.ibm_resource_instance.es_instance_source.id
        source_alias = "source-alias"
        target_alias = "target-alias"
        }
     }
 )

user also has the options to configure it to be more complex like below:

parameters_json = jsonencode(
   {
     mirroring = {
       source_crn   = data.ibm_resource_instance.es_instance_source.id
       source_alias = "source-alias"
       target_alias = "target-alias"
       options = {
         topic_name_transform = {
            type = "rename" 
            rename = {
              add_prefix = "add_prefix"
              add_suffix = "add_suffix"
              remove_prefix = "remove_prefix"
              remove_suffix = "remove_suffix"
            }
         }
         group_id_transform = {
           type = "rename" 
           rename = {
             add_prefix = "add_prefix"
             add_suffix = "add_suffix"
             remove_prefix = "remove_prefix"
             remove_suffix = "remove_suffix"
           }
         }
       }
     }
   }
 )

@kccox
Copy link
Contributor

kccox commented Oct 31, 2024

Note, you need plan = "enterprise-3nodes-2tb" to use mirroring, but provisioning of an enterprise instance can take two to three hours. You probably do not want to test that in pr_test.go.

@Ak-sky
Copy link
Member Author

Ak-sky commented Nov 5, 2024

Addressing changes with the latest stable provider release https://registry.terraform.io/providers/IBM-Cloud/ibm/1.71.0

@JunliWang
Copy link
Contributor

@Ak-sky
the resource ibm_event_streams_mirroring_config depends on the provider release v1.71.0, the parameters_json for mirroring does not, it is already supported by resource controller and Event Streams' service broker.

@JunliWang
Copy link
Contributor

example doc for mirroring
IBM-Cloud/terraform-provider-ibm#5767

@Ak-sky Ak-sky marked this pull request as ready for review November 18, 2024 14:16
@Ak-sky Ak-sky requested a review from akocbek as a code owner November 18, 2024 14:16
@Ak-sky Ak-sky changed the title [DONOTMERGE]feat: added mirroring support feat: added mirroring support Nov 18, 2024
@Ak-sky
Copy link
Member Author

Ak-sky commented Nov 19, 2024

@srikant-sahu, can you please have a look at this PR.

@Ak-sky
Copy link
Member Author

Ak-sky commented Nov 19, 2024

/run pipeline

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.

The mirror example will take too long to run in pr_test.go. I think we maybe add a permanent enterprise instance to our account, and update the fscloud example with mirror support. Then we can run the fscloud example in pr_test.go to test all enterprise features

examples/complete/variables.tf Outdated Show resolved Hide resolved
examples/complete/variables.tf Outdated Show resolved Hide resolved
}

# Create s2s at service level for provisioning mirroring instance
resource "ibm_iam_authorization_policy" "es_service_policy" {
Copy link
Member Author

@Ak-sky Ak-sky Nov 19, 2024

Choose a reason for hiding this comment

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

@ocofaigh, should we create this bool variable skip_es_s2s_authorization_policy if the user has this policy already existing?

resource "ibm_iam_authorization_policy" "es_service_policy" {
  count               = var.skip_es_s2s_authorization_policy ? 0 : 1
  source_service_name = "messagehub"
  target_service_name = "messagehub"
  roles               = ["Reader"]
  description         = "Required for provisioning mirroring instance."
}

Copy link
Member

Choose a reason for hiding this comment

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

thats a odd policy - the service needs to grant itself reader access? If anything this policy should probably be scoped to exact instances if possible. And yes always provide the ability to skip s2s auth policy 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.

@ocofaigh
So there are 2 policies required for mirroring-
1- service-to-service (The odd one, which is required for ES mirror instance provisioning.)
2- instance-to-instance (This is to allow source cluster access to target cluster.)

I discussed the same with ES team, for which they mentioned both the policies are required for the mirroring feature.

@srikant-sahu/@JunliWang, can you please pitch in here for service-to-service policy need?

Copy link
Contributor

Choose a reason for hiding this comment

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

the expected workflow for mirroring

  • provision source cluster
  • create s2s policy at service level (at this point we do not have target cluster CRN yet, so grant at service level)
  • provision target cluster (this requires s2s policy because mirrormaker2 on target cluster will be configured to read from source cluster, reader role is needed)
  • create s2s policy at instance level (in order to ensure target can read from source cluster, at this point both CRNs are available)
  • delete s2s policy at service level (can be done via terraform destroy xxx)

Copy link
Member

Choose a reason for hiding this comment

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

OK so it seems we can at least scope the auth policy to the source instance anyway. And we can even scope it to the target resource group since we know what that will be

Copy link
Member

@ocofaigh ocofaigh Nov 19, 2024

Choose a reason for hiding this comment

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

@JunliWang The approach you have mentioned around deleting the global auth policy and replacing it with a finer scoped one after the target instance is created does not work with terraform (or at least is not something we can automate in our module)

default = null
}

variable "mirroring" {
Copy link
Contributor

Choose a reason for hiding this comment

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

the variable mirroring needs to have the full mirroring configuration. A user has an option to enable/disbale topic/group renaming. For reference of a full mirroring configuration options see the #327 (comment)

@ocofaigh ocofaigh mentioned this pull request Nov 19, 2024
6 tasks
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.

5 participants