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

migrate azurerm_synapse_role_assignment to support new roles and scopes #11690

Merged
merged 6 commits into from Jun 15, 2021

Conversation

njuCZ
Copy link
Contributor

@njuCZ njuCZ commented May 13, 2021

fix #10141

in old api version, the only supported role is Workspace Admin, Sql Admin and Apache Spark Admin. The scope is workspace.

in new api version, exsiting roles are renamed and new roles are added, Users could also specify different scope: workspace, spark pool or others (not suported in terraform, so not added in this PR) .

image

@njuCZ
Copy link
Contributor Author

njuCZ commented May 28, 2021

this PR contains breaking changes, is it possible to be merged in the next major version 3.0 ?

@katbyte katbyte added this to the v3.0.0 milestone Jun 1, 2021
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

@njuCZ - is there a reason we can't map the old roles to the new ones so this isn't a breaking change? (at least for upgrading?)

@njuCZ
Copy link
Contributor Author

njuCZ commented Jun 2, 2021

@katbyte we could map the old roles to the new, in this PR I also added a stateUpgrade func to make it. But in the old api, the scope of role assignment is always workspace level, while the new api could be workspace level, sparkpool level and others. So I removed property synapse_workspace_id and add property synapse_scope, I think this is a breaking change for users.

@ghost ghost removed the waiting-response label Jun 2, 2021
@njuCZ njuCZ requested a review from katbyte June 2, 2021 01:52
@chrsundermann
Copy link

chrsundermann commented Jun 2, 2021

Does it make sense not to hardcode possible roles? As soon as new roles will be integrated they can't be picked and code has to be updated.

To update on this:
The implemented synapse_scope want the id of the synapse workspace but there are more settings possible. If you request possible values via az cli you get this output:

image

@katbyte
Copy link
Collaborator

katbyte commented Jun 3, 2021

But in the old api, the scope of role assignment is always workspace level, while the new api could be workspace level, sparkpool level and others

if we default to workspace level and mark that as optional it's not a breaking change?

@njuCZ
Copy link
Contributor Author

njuCZ commented Jun 7, 2021

@katbyte yes, in the state upgrade func I did that. I thought changing the schema name (synapse_workspace_id -> syanpse_scope) belongs to breaking change because we need users to modify the property name in TF config file. If this change is OK, I think we could remove the breaking change label.

@njuCZ
Copy link
Contributor Author

njuCZ commented Jun 7, 2021

another way to make this PR: we could mark synapse_workspace_id optional, and add other schema for scope, for example: spark_pool_id. In this way, we would have multiple specific schema to represent scope and only one of them should be specified.

@katbyte
Copy link
Collaborator

katbyte commented Jun 8, 2021

another way to make this PR: we could mark synapse_workspace_id optional, and add other schema for scope, for example: spark_pool_id. In this way, we would have multiple specific schema to represent scope and only one of them should be specified.

I like this id! and then we get proper validation on the id of the scope and no breaking change, this works for me!

@njuCZ
Copy link
Contributor Author

njuCZ commented Jun 8, 2021

@katbyte I have refined this PR, now there is no breaking change. All acctest could pass.
image

@njuCZ
Copy link
Contributor Author

njuCZ commented Jun 9, 2021

@chrsundermann sorry for late reply. Currently there is not many roles, so we could hardcode in the validation function and provide more friendly user experience . If there are many roles added in future, we could add another data source for role definition.

As for synapse scope, since integrationRuntimes, credentials, linkedservice are not supported in terraform yet, so in this PR, I don't support them. I think it's easy to add support for those scope in future.

@katbyte
Copy link
Collaborator

katbyte commented Jun 10, 2021

@njuCZ - looks like all the tests are now filing:

------- Stdout: -------
=== RUN   TestAccSynapseRoleAssignment_basic
=== PAUSE TestAccSynapseRoleAssignment_basic
=== CONT  TestAccSynapseRoleAssignment_basic
    testing.go:620: Step 1/2 error: Error running apply: exit status 1
        
        Error: waiting on creation for Synapse Workspace "acctestsw210610181822439671" (Resource Group "acctestRG-synapse-210610181822439671"): Code="CreateWorkspaceError" Message="An error has occured while creating the workspace. Correlation Id: 9e48fcab-9fa9-4f04-80e5-3538b340c54f"
        
          with azurerm_synapse_workspace.test,
          on terraform_plugin_test.tf line 26, in resource "azurerm_synapse_workspace" "test":
          26: resource "azurerm_synapse_workspace" "test" {
        
--- FAIL: TestAccSynapseRoleAssignment_basic (881.76s)
FAIL

------- Stderr: -------
2021/06/10 18:18:22 [DEBUG] not using binary driver name, it's no longer needed
2021/06/10 18:18:22 [DEBUG] not using binary driver name, it's no longer needed

@njuCZ njuCZ force-pushed the synapse_new_role_assignment branch from 72f4799 to aba894a Compare June 11, 2021 08:57
@njuCZ
Copy link
Contributor Author

njuCZ commented Jun 11, 2021

@katbyte the acctest in teamcity could pass now.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

one last comment i think

@njuCZ njuCZ force-pushed the synapse_new_role_assignment branch from 799fb39 to d104491 Compare June 15, 2021 06:53
@njuCZ njuCZ force-pushed the synapse_new_role_assignment branch from d104491 to 9b10400 Compare June 15, 2021 07:06
@njuCZ njuCZ requested a review from katbyte June 15, 2021 07:15
@njuCZ
Copy link
Contributor Author

njuCZ commented Jun 15, 2021

@katbyte thanks for your suggestions. I have added support for old roles and add a suppressFunc to avoid diff between old roles and new roles.

image

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @njuCZ - LGTM aside from one comment which i'll fix now 🍰

azurerm/internal/services/synapse/client/client.go Outdated Show resolved Hide resolved
@katbyte katbyte merged commit ccef7c7 into hashicorp:master Jun 15, 2021
katbyte added a commit that referenced this pull request Jun 15, 2021
katbyte added a commit that referenced this pull request Jun 18, 2021
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2021
@katbyte katbyte modified the milestones: v3.0.0-to-review, v2.64.0 Oct 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Synapse Workspace new roles for Role Assignment
3 participants