Skip to content

Refactor TypeSpec with separate update models - #6462

Open
Matthew Barnes (mbarnes) wants to merge 5 commits into
Azure:mainfrom
mbarnes:mbarnes/public-preview-typespec-rework
Open

Refactor TypeSpec with separate update models#6462
Matthew Barnes (mbarnes) wants to merge 5 commits into
Azure:mainfrom
mbarnes:mbarnes/public-preview-typespec-rework

Conversation

@mbarnes

@mbarnes Matthew Barnes (mbarnes) commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

What

Refactors the TypeSpec API definition files for public preview compliance.

Primarily, we've been instructed to discontinue use of the ArmResourcePatchAsync template in favor of ArmCustomPatchAsync.

This sucks.

ArmResourcePatchAsync is nice because it auto-generates update model definitions in the JSON Swagger files. But it doesn't provide that benefit for generated SDKs and we've been largely disregarding SDK generation until now.

ArmCustomPatchAsync requires a separate set of models for patch operations. These "update" models only include properties with Lifecycle.Update visibility. This means we now have to maintain two copies of most of our TypeSpec models: one for PUT, another for PATCH.

Testing

No new tests necessary. If I did this right then current tests should all pass.

Special notes for your reviewer

I tried my best to avoid churn in the JSON Swagger files, but the Azure.ResourceManager.CommonTypes package does not provide "update" models. So there is some unfortunate churn around the definitions for patching MSI and tags fields for tracked resource types.

PR Checklist

  • PR is scoped to a single task (no mixed concerns)
  • Title follows Conventional Commits format
  • Summary explains the "Why" behind the change
  • Linked to relevant ticket/issue
  • Screenshots included (if graph/UI/metrics changes)
  • Self-reviewed the diff
  • CI/CD checks are passing (ignore Tide)
  • Draft PR used for WIP (if applicable)
  • Commit history is clean (rebased/squashed)
  • Tricky code blocks are commented
  • Specific reviewers tagged
  • All comment threads resolved before merge

If E2E tests are included:

  • E2E tests follow Principles of Good E2E Test Case Design
  • If new E2E use case is covered (via a new test or new check/verifier),
    demonstrate that the test is able to detect a defect/error and fail with
    proper error message and logs which communicates nature of the problem.

Copilot AI lite review requested due to automatic review settings August 6, 2026 17:36
@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mbarnes

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved label Aug 6, 2026
@mbarnes
Matthew Barnes (mbarnes) force-pushed the mbarnes/public-preview-typespec-rework branch from caff07b to c156e30 Compare August 6, 2026 17:51
Copilot AI lite review requested due to automatic review settings August 6, 2026 17:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings August 6, 2026 18:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

* Budgets that have not been successfully drained from a node will be forcibly evicted. This is
* especially relevant to cluster upgrades.
*
* Valid values are in minutes and from 0 to 10080 minutes (1 week).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit:

Don't need "Valid values are in minutes and from 0 to 10080 minutes (1 week)." if we have a @max and @min decorator since they're rendered into the description i believe. Just call out the units.

* of a TypeSpec bug with updatable fields. The default value will be
* declared in a future API version once the TypeSpec bug is fixed.
* https://github.com/Azure/typespec-azure/issues/1586
* If not specified, the default value is 'stable'.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove what the default is here. Also an update we don't take a default, so remove this text entirely.

Matthew Barnes added 4 commits August 6, 2026 14:43
Explicitly specify the version so local copies stay synchronized
with what the CI check uses.
…tions

Use // comment style in the TypeSpec files for annotations that we
don't want published in customer-facing documentation. Things like
workarounds for upstream TypeSpec bugs, etc.
Based on a buried blurb in a TypeSpec How-To [1]:

Note: The ArmResourcePatch* templates are not recommended. They rely
on Lifecycle.Update visibility analysis to automatically determine
which properties are included in the PATCH schema, but this analysis
is only performed by the typespec-autorest emitter and will not be
replicated in SDKs generated for the PATCH operation. Instead, spec
authors should define a specific PATCH model and use the
ArmCustomPatch* templates.

This means we have to revert back to maintaining separate update
models for our resource types.  :(

[1] https://azure.github.io/typespec-azure/docs/howtos/arm/resource-operations/#resource-update-operations-patch
Regenerating SDKs for all API versions to verify no E2E breakage.
@@ -394,37 +508,22 @@ model ClusterAutoscalingProfile {

/** maxPodGracePeriod is the maximum seconds to wait for graceful pod termination before scaling down a NodePool.
* The default is 600 seconds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: remove "The default is 600 seconds".

maxPodGracePeriodSeconds?: int32 = 600;

/** maxNodeProvisionTimeSeconds is the maximum time to wait for node provisioning before considering the
* provisioning to be unsuccessful. The default is 900 seconds, or 15 minutes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: remove "The default is 900 seconds, or 15 minutes."

maxNodeProvisionTimeSeconds?: int32 = 900;

/** podPriorityThreshold enables users to schedule "best-effort" pods, which shouldn't trigger autoscaler actions,
* but only run when there are spare resources available. The default is -10.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit, remove "default" text.

/**
* The number of worker nodes, it cannot be used together with autoscaling.
* Validation:
* - Minimum: 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove min value specified in validation, it's in the decorator. Keep the max.

* If unset the cluster nodeDrainTimeoutMinutes value is used as a default.
*/
@visibility(Lifecycle.Read, Lifecycle.Create, Lifecycle.Update)
nodeDrainTimeoutMinutes?: int32;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: add a Min Kim (@min) Max Schoening (@max) decorator, and remove valid values.

* If not specified, the default value is 'stable'.
*/
@visibility(Lifecycle.Read, Lifecycle.Create, Lifecycle.Update)
channelGroup?: string;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"the default value is 'stable'" -> actually configure a default and set it. Then remove the default value text.

* provider, must be issued to. At least one of the entries must match the
* 'aud' claim in the JWT token.
*
* audiences must contain at least one entry and must not exceed ten entries.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not needed, it's part of min/max items.

* - "username": the mapped value will be "https://myoidc.tld#userA"
* - "email": the mapped value will be "userA@myoidc.tld"
*/
prefixPolicy?: UsernameClaimPrefixPolicy;

@bennerv Ben Vesel (bennerv) Aug 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove default text in here. It should have the default defined in the typespec base one.

@bennerv Ben Vesel (bennerv) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So it looks like the default doesn't get rendered into the descriptions on https://learn.microsoft.com/en-us/rest/api. But the min/max values do. So keep the default text on creates, but min/max values are rendered so we can omit them from descriptions afaict.

Worst case we add them back in.

Since we're not using the ArmResourcePatchAsync template anymore,
Azure/typespec-azure#1586 is no longer
relevant for us. We can drop the workarounds.
Copilot AI review requested due to automatic review settings August 6, 2026 19:56
@mbarnes
Matthew Barnes (mbarnes) force-pushed the mbarnes/public-preview-typespec-rework branch from 3b68f27 to b7aabbb Compare August 6, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@openshift-ci

openshift-ci Bot commented Aug 8, 2026

Copy link
Copy Markdown

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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.

3 participants