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

Fixing container service warning and arm-types reference #24044

Merged

Conversation

allenjzhang
Copy link
Member

@allenjzhang allenjzhang commented May 18, 2023

  • Added arm-types-dir so the common type reference built in rest-api-repo is correct
  • Kept the CreateOrUpdate operation id via suppress. Without this override, it generated Fleet_Create.
  • Updated tspconfig.yaml to align with repo convention

Passing build in pipeline specs - typespec - ci: https://dev.azure.com/azure-sdk/public/_build/results?buildId=2785861&view=logs&j=9cd39ef8-47c1-5b58-08db-8c3708712f1b&t=462145f3-d740-50de-51e9-126e7c0a29e2

TypeSpecValidation is showing an error (even though it reports green status), but this is a bug where TypeSpecValidation can't handle multiple versions of the generated swagger in the repo. It should only be comparing the generated swagger against version 2023-03-15, but it tries to compare against 2022-09-02 instead, which fails.

@openapi-workflow-bot
Copy link

Hi, @allenjzhang Thanks for your PR. I am workflow bot for review process. Here are some small tips.

  • Please ensure to do self-check against checklists in first PR comment.
  • PR assignee is the person auto-assigned and responsible for your current PR reviewing and merging.
  • For specs comparison cross API versions, Use API Specs Comparison Report Generator
  • If there is CI failure(s), to fix CI error(s) is mandatory for PR merging; or you need to provide justification in PR comment for explanation. How to fix?

  • Any feedback about review process or workflow bot, pls contact swagger and tools team. [email protected]

    @openapi-pipeline-app
    Copy link

    openapi-pipeline-app bot commented May 18, 2023

    Swagger Validation Report

    ️️✔️BreakingChange succeeded [Detail] [Expand]
    There are no breaking changes.
    ️️✔️Breaking Change(Cross-Version) succeeded [Detail] [Expand]
    There are no breaking changes.
    ️️✔️CredScan succeeded [Detail] [Expand]
    There is no credential detected.
    ️️✔️LintDiff succeeded [Detail] [Expand]
    Validation passes for LintDiff.
    ️️✔️Avocado succeeded [Detail] [Expand]
    Validation passes for Avocado.
    ️️✔️ApiReadinessCheck succeeded [Detail] [Expand]
    ️️✔️~[Staging] ServiceAPIReadinessTest succeeded [Detail] [Expand]
    Validation passes for ServiceAPIReadinessTest.
    ️️✔️SwaggerAPIView succeeded [Detail] [Expand]
    ️️✔️CadlAPIView succeeded [Detail] [Expand]
    ️️✔️TypeSpecAPIView succeeded [Detail] [Expand]
    ️️✔️ModelValidation succeeded [Detail] [Expand]
    Validation passes for ModelValidation.
    ️️✔️SemanticValidation succeeded [Detail] [Expand]
    Validation passes for SemanticValidation.
    ️️✔️PoliCheck succeeded [Detail] [Expand]
    Validation passed for PoliCheck.
    ️️✔️PrettierCheck succeeded [Detail] [Expand]
    Validation passes for PrettierCheck.
    ️️✔️SpellCheck succeeded [Detail] [Expand]
    Validation passes for SpellCheck.
    ️️✔️Lint(RPaaS) succeeded [Detail] [Expand]
    Validation passes for Lint(RPaaS).
    ️️✔️CadlValidation succeeded [Detail] [Expand]
    Validation passes for CadlValidation.
    ️️✔️TypeSpec Validation succeeded [Detail]
    Rule Message
    InConsistentSwagger "details":"The generated swagger file 2022-09-02-preview/fleets.json from typespec specification/containerservice/Fleet.Management is not the same as the '/mnt/vss/_work/1/azure-rest-api-specs/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/preview/2022-09-02-preview/fleets.json' in PR,
    please make sure the swagger is consistent with the generated swagger. You can find the difference in the pipeline log."
    InConsistentSwagger "details":"The generated swagger file 2023-03-15-preview/fleets.json from typespec specification/containerservice/Fleet.Management is not the same as the '/mnt/vss/_work/1/azure-rest-api-specs/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2023-03-15-preview/fleets.json' in PR,
    please make sure the swagger is consistent with the generated swagger. You can find the difference in the pipeline log."
    ️️✔️PR Summary succeeded [Detail] [Expand]
    Validation passes for Summary.
    Posted by Swagger Pipeline | How to fix these errors?

    @openapi-pipeline-app
    Copy link

    openapi-pipeline-app bot commented May 18, 2023

    Swagger pipeline restarted successfully, please wait for status update in this comment.

    @ghost ghost added the Container Service label May 18, 2023
    @openapi-pipeline-app
    Copy link

    openapi-pipeline-app bot commented May 18, 2023

    Generated ApiView

    Language Package Name ApiView Link
    TypeSpec Fleet.Management https://apiview.dev/Assemblies/Review/8857ba5792294341a33f254fab0a130d

    @@ -2,7 +2,9 @@ emit:
    - '@azure-tools/typespec-autorest'
    options:
    '@azure-tools/typespec-autorest':
    azure-resource-provider-folder: '{cwd}/../resource-manager'
    arm-types-dir: ../../../../../../common-types/resource-management
    Copy link
    Member

    Choose a reason for hiding this comment

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

    Is this necessary? That path looks like a recipe for trouble.

    Copy link
    Member

    Choose a reason for hiding this comment

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

    Suggested change
    arm-types-dir: ../../../../../../common-types/resource-management
    arm-types-dir: "{project-root}/../../common-types/resource-management"

    it should be using {project-root} (not sure I fixed it correctly here)

    Copy link
    Member

    @markcowl markcowl May 19, 2023

    Choose a reason for hiding this comment

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

    We should not have a relative path here. We should use a path starting from "{project-root}" https://github.com/Azure/typespec-azure/blob/main/packages/typespec-autorest/src/openapi.ts#L799-L808

    Copy link
    Member

    Choose a reason for hiding this comment

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

    I merged @timotheeguerin suggestion, CI pipeline will tell us if it works.

    Copy link
    Member

    Choose a reason for hiding this comment

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

    Does this mean that folks with this reference will not be able to run outside of the specs repo? For the most part we have blocked references outside of the service directory but this will be one which goes outside of it.

    Copy link
    Member

    Choose a reason for hiding this comment

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

    nvm, repro'd I copied the wrong tspconfig

    Copy link
    Member

    Choose a reason for hiding this comment

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

    Copy link
    Member Author

    @allenjzhang allenjzhang May 23, 2023

    Choose a reason for hiding this comment

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

    We can remove this config then as it is defualt value. I will remove it from the template definitely.

    Copy link
    Member

    Choose a reason for hiding this comment

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

    I will create a PR to upgrade the specs repo to use the new autorest emitter (and verify it doesn't regress any specs currently building)

    Copy link
    Member

    Choose a reason for hiding this comment

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

    PR to update tools: #24100

    Pipeline specs - typespec - ci is passing, which means no spec in the repo was currently relying on the buggy behavior. So we can either:

    1. Merge this PR, then 24100, then fix the usage of {project-root} in a third PR
    2. Merge 24100, then fix the usage of {project-root} in this PR, then merge this PR

    @@ -2,7 +2,9 @@ emit:
    - '@azure-tools/typespec-autorest'
    options:
    '@azure-tools/typespec-autorest':
    azure-resource-provider-folder: '{cwd}/../resource-manager'
    arm-types-dir: ../../../../../../common-types/resource-management
    Copy link
    Member

    @markcowl markcowl May 19, 2023

    Choose a reason for hiding this comment

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

    We should not have a relative path here. We should use a path starting from "{project-root}" https://github.com/Azure/typespec-azure/blob/main/packages/typespec-autorest/src/openapi.ts#L799-L808

    @mikeharder
    Copy link
    Member

    @timotheeguerin, @markcowl: Think this is ready to merge, given this is the best we can do until https://github.com/Azure/typespec-azure/issues/3024 is fixed?

    @mikeharder
    Copy link
    Member

    /azp run

    @azure-pipelines
    Copy link

    Azure Pipelines successfully started running 2 pipeline(s).

    @timotheeguerin
    Copy link
    Member

    @mikeharder, made a hotfix friday for the project-root issue, waiting on the pr bumping the versions and the hotfix should be usable https://github.com/Azure/typespec-azure/pull/3026

    Because technically that bug breaks a bad use, there could be some specs that need updating though so if you prefer to merge this for now with relative ref, I have no issue

    @allenjzhang
    Copy link
    Member Author

    Discussed with Stephane, he will send a PR from his side that incorporate these small changes rather than merging. So closing this.

    @allenjzhang allenjzhang reopened this May 23, 2023
    @allenjzhang
    Copy link
    Member Author

    Actually, he is not merging into the main and won't have time for now. So let's merge this PR then. Reactivated.

    @allenjzhang
    Copy link
    Member Author

    @mikeharder, made a hotfix friday for the project-root issue, waiting on the pr bumping the versions and the hotfix should be usable Azure/typespec-azure#3026

    Because technically that bug breaks a bad use, there could be some specs that need updating though so if you prefer to merge this for now with relative ref, I have no issue

    I think it is best to have {project-root}/../xxx for now. Once the hotfix version is updated, we can do a full pass on the repo and correct other instances all together.

    @allenjzhang
    Copy link
    Member Author

    @markcowl, feel free to remove -1 and merge to unblock Mike.

    @mikeharder
    Copy link
    Member

    I think we need to update the version of autorest in the repo to prevent this PR from breaking the CI pipeline. I'll just add the version update to this PR.

    @mikeharder
    Copy link
    Member

    I think we need to update the version of autorest in the repo to prevent this PR from breaking the CI pipeline. I'll just add the version update to this PR.

    Sorry I misunderstood. I see the plan is to intentionally use the buggy behavior for {project-root} in this PR, and fix it in a later PR where the version of autorest is updated. Fine with me.

    @timotheeguerin
    Copy link
    Member

    @mikeharder autorest has been updated with the fix. Version 0.30.1

    @mikeharder
    Copy link
    Member

    @mikeharder autorest has been updated with the fix. Version 0.30.1

    Yep, I will create a separate PR to update the version of autorest in root package.json to 0.30.1. In this PR, we will need to fix any usage of {project-root} depending on the old behavior (like this current PR).

    @mikeharder
    Copy link
    Member

    /azp run

    @azure-pipelines
    Copy link

    Azure Pipelines successfully started running 2 pipeline(s).

    - Setting matches default value
    @mikeharder
    Copy link
    Member

    @weshaggard: If you think this is ready to merge, can you approve?

    I'd like to get this merged soon if there are no other comments. We can always make additional improvements in future PRs.

    @weshaggard weshaggard merged commit 89ba26d into Azure:main May 24, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    6 participants