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

fix: avoid sending template metadata update if max_port_share_level is default #190

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Feb 25, 2025

Closes #188.

For context, the MaxPortShareLevel template metadata value was not present on the coderd create template request prior to 2.15. As such, during template creation we need to send an update request for backwards compatibility (though we could probably remove this soon), see #110.

Whilst we don't send this update request is the attribute is omitted on the resource, we were sending a spurious update request if the value was explicitly configured to the default value ('owner' for enterprise+, 'public' otherwise). This was causing the error in the linked issue. An example is seen in the newly added test.

The fix is to just not send that update request if the configured value is:

  • Unknown
  • Equal to the value on the newly created template.

note: I'd recommend hiding the whitespace when reviewing the diff

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ethanndickson ethanndickson marked this pull request as ready for review February 25, 2025 03:02
@@ -573,6 +573,8 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
// deployment running `v2.15.0` or later.
if data.MaxPortShareLevel.IsUnknown() {
data.MaxPortShareLevel = types.StringValue(string(templateResp.MaxPortShareLevel))
} else if data.MaxPortShareLevel.ValueString() == string(templateResp.MaxPortShareLevel) {
tflog.Info(ctx, "max port share level set to default, not updating")
Copy link
Member

Choose a reason for hiding this comment

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

not necessarily the default, just the current value

Copy link
Member Author

Choose a reason for hiding this comment

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

this only runs on Create, so the current value is always the default

@ethanndickson ethanndickson merged commit 1d19415 into main Feb 26, 2025
14 checks passed
@ethanndickson ethanndickson deleted the ethan/fix-default-port-level-error branch February 26, 2025 01:20
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.

Resource coderd_template setting port share level issues
2 participants