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

@azure/communication-common Azure Core 2.0 Migration #20337

Merged
merged 19 commits into from
Feb 25, 2022
Merged

@azure/communication-common Azure Core 2.0 Migration #20337

merged 19 commits into from
Feb 25, 2022

Conversation

petrsvihlik
Copy link
Contributor

@petrsvihlik petrsvihlik commented Feb 11, 2022

Packages impacted by this PR

  • @azure/communication-common
  • and once migrated, transitively its dependencies

Issues associated with this PR

Describe the problem that is addressed by this PR

What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?

Are there test cases added in this PR?

  • Yes

Provide a list of related PRs (if any)

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator? NO
  • Added a changelog (if necessary)

Changes

  • old policy preserved to maintain the backward compatibility and allow gradual migration of the ACS libraries and moved to /src/credential/auth-policy-v1/
  • new policy created in /src/credential/auth-policy-v2/ (based on @azure/core-rest-pipeline)
  • reduced the number of references to @azure/core-http to minimum (enable easier future removal of the dependency)
  • removed circular dependencies (detected by npx madge --circular --extensions ts ./)
  • removed SubtleCrypto & related shims

Migration guide for ACS modalities

  • createCommunicationAuthPolicy -> createCommunicationAuthenticationPolicy
  • createCommunicationAuthenticationPolicy -> createCommunicationAuthenticationPolicy
// Old code
const authPolicy = createCommunicationAuthPolicy(credential);
const pipeline = createPipelineFromOptions(internalPipelineOptions, authPolicy);
this.client = new IdentityRestClient(url, pipeline).communicationIdentity;
// New code
this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });
const authPolicy = createCommunicationAuthenticationPolicy(credential);
this.client.pipeline.addPolicy(authPolicy);

@petrsvihlik petrsvihlik marked this pull request as ready for review February 11, 2022 15:16
@azure-sdk

This comment was marked as outdated.

@azure-sdk

This comment was marked as outdated.

@petrsvihlik petrsvihlik changed the title @azure/communication-common Core2 Migration @azure/communication-common Azure Core 2.0 Migration Feb 15, 2022
@Shamkh Shamkh self-requested a review February 16, 2022 00:18
@check-enforcer
Copy link

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run js - [service] - ci

@petrsvihlik
Copy link
Contributor Author

petrsvihlik commented Feb 16, 2022

The PR contains a new version of the auth policy that is used by several ACS modalities (SMS, ShortCodes, NetworkTraversal, Identity, PhoneNumbers). To preserve the backward compatibility and allow gradual onboarding by the aforementioned modalities, I'm keeping both the old and the new version of the policy. To avoid naming collisions while not having to suffix the new one with sth like "V2", I've decided to use slightly different names for the new policy:

  • createCommunicationAuthPolicy -> createCommunicationAuthenticationPolicy
  • createCommunicationAccessKeyCredentialPolicy-> createCommunicationKeyCredentialPolicy

Also, all these methods are marked as @hidden to be excluded from the docs, and I marked the old ones with @deprecated.

I was considering removing the old policy entirely since it's marked as @hidden and not supposed to be used by customers but in the end, I decided not to because I couldn't find any Azure guidelines that would allow me to do so.

Both have their pros and cons. If we delete the old one, we should migrate all the client libs in a single PR...a bit more work but less code to maintain in the end. If we stick with the current approach, we allow for gradual onboarding and still can decide to remove it later, once everyone's onboarded.

I was discussing it with @DominikMe and he's also not 100% sure which approach shall we take in this case and recommended asking you folks.

@xirzec @bterlson Could you please let me know what approach you would recommend and if it's the current one, then approve the related API view?

@xirzec
Copy link
Member

xirzec commented Feb 16, 2022

@xirzec @bterlson Could you please let me know what approach you would recommend and if it's the current one, then approve the related API view?

Our normal approach in these sorts of situations (we're updating a core package) is to bump the major version and do the break (so ditch the old policies and export the new ones with the same name) and then have dependent packages upgrade incrementally.

@ramya-rao-a
Copy link
Contributor

Both have their pros and cons. If we delete the old one, we should migrate all the client libs in a single PR...a bit more work but less code to maintain in the end. If we stick with the current approach, we allow for gradual onboarding and still can decide to remove it later, once everyone's onboarded.

I agree with @xirzec.
By doing a major version update for communication-common, we will be free to remove dependency on core-http. The rest of the communication libraries can move to this new major version in different PRs.

@petrsvihlik
Copy link
Contributor Author

@xirzec @ramya-rao-a thanks both! I'll update the PR then to remove the old policy and the dependency on @azure/core-http.

fyi @AlonsoMondal - It seems it could help us resolve the other issue we are facing when trying to migrate the libraries dependent on communication-common.

@petrsvihlik
Copy link
Contributor Author

@xirzec I have removed the old policy and replaced it with a new one. No APIView has been generated, I suspect it's because I have bumped the major version as you suggested. Can you please give a final approval so that we can merge this PR? The API change is visible here: https://github.com/Azure/azure-sdk-for-js/pull/20337/files#diff-aa1c3b86239992f00aa0ef7192f0f24632b66e2a0b086a001189b2670cba75e7

Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

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

API changes look good! Thanks for the update! 👍

@petrsvihlik
Copy link
Contributor Author

petrsvihlik commented Feb 24, 2022

@xirzec in the end, I managed to create an API view for this PR manually. can you please approve it there as well?
https://apiview.dev/Assemblies/Review/cd646a2eb52342bd84aa3d1e3fb4285e/7e0a3470c9584f4cbacba31220aa2889?diffRevisionId=f86bf33908884a1bb597730856d29199&doc=False&diffOnly=True

edit:

@azure-sdk
Copy link
Collaborator

API changes have been detected in @azure/communication-common. You can review API changes here

API changes

- createCommunicationAccessKeyCredentialPolicy: (credential: KeyCredential) => RequestPolicyFactory
- createCommunicationAuthPolicy: (credential: KeyCredential | TokenCredential) => RequestPolicyFactory
+ export declare function createCommunicationAccessKeyCredentialPolicy(credential: KeyCredential): PipelinePolicy;
+ export declare function createCommunicationAuthPolicy(credential: KeyCredential | TokenCredential): PipelinePolicy;

@xirzec
Copy link
Member

xirzec commented Feb 24, 2022

@xirzec in the end, I managed to create an API view for this PR manually. can you please approve it there as well? https://apiview.dev/Assemblies/Review/cd646a2eb52342bd84aa3d1e3fb4285e/7e0a3470c9584f4cbacba31220aa2889?diffRevisionId=f86bf33908884a1bb597730856d29199&doc=False&diffOnly=True

edit:

I approved both! so you're super approved. 😆

@ramya-rao-a
Copy link
Contributor

Lets go! Lets go!

@petrsvihlik petrsvihlik merged commit a595cb2 into Azure:main Feb 25, 2022
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-js that referenced this pull request Aug 23, 2022
[Hub Generated] Publish private branch 'datafactory/mash/feature/GoogleSheets/swaggerNew' (Azure#20337)

* [AutoSync] 41dd785da9 GoogleSheets Swagger changes

* [AutoSync] 41dd785da9 GoogleSheets Swagger changes

Co-authored-by: swagger-automation <swagger@microsoft.com>
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.