Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tailscale/resource_acl: relax policy validation during plan steps#554

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
mcoulombe wants to merge1 commit intomain
base:main
Choose a base branch
Loading
frommax/relax-acl-plan-validations

Conversation

@mcoulombe
Copy link
Contributor

@mcoulombemcoulombe commentedOct 3, 2025
edited
Loading

What this PR does / why we need it:

Some resources like SCIM groups can be created and added as a reference to the policy file in the same run. The eager validation causes otherwise valid runs to fail at the plan step because the references do not exist yet.

We are relaxing the plan validation logic to avoid such false positives. The full validation results are still available in debug logs in case this is useful. Note that the validation is done in full during an apply before the policy file is changed so this does not bypass the full breath of validations taking place before the policy is modified.

Which issue this PR fixes(usefixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged):

Fixes#546

Example of a validation error for a failed test in the debug logs:

2025-10-03T14:07:54.620-0400 [DEBUG] provider.terraform-provider-tailscale: ACL validation unsuccessful due to advisory error: tf_resource_type=tailscale_acl tf_rpc=PlanResourceChange @module=provider tf_provider_addr=provider error="ACL validation failed: test(s) failed; [{insecure@example.com [[acl test error]: address \"1.2.3.4:80\" (protocol \"tcp\"): want: Drop, got: Accept]}]" tf_req_id=4a4b79ad-9fb5-fe55-1ab8-961f4e20b4af @caller=/Users/maxc/Documents/projects/terraform-provider-tailscale/tailscale/resource_acl.go:54 timestamp=2025-10-03T14:07:54.620-0400

Resulting apply if the user ignores or does not check the validation logs before an apply:

Do you want to perform these actions?  Terraform will perform the actions described above.  Only 'yes' will be accepted to approve.  Enter a value: yestailscale_acl.as_hujson: Modifying... [id=acl]╷│ Error: Failed to set ACL│ │   with tailscale_acl.as_hujson,│   on main.tf line 15, in resource "tailscale_acl" "as_hujson":│   15: resource "tailscale_acl" "as_hujson" {│ │ test(s) failed (400)╵╷│ Error: user: insecure@example.com│ error: [acl test error]: address "1.2.3.4:80" (protocol "tcp"): want: Drop, got: Accept│ │   with tailscale_acl.as_hujson,│   on main.tf line 15, in resource "tailscale_acl" "as_hujson":│   15: resource "tailscale_acl" "as_hujson" {│ ╵

ports = ["*:*"],
"src": ["*"],
"dst": ["*"],
"ip": ["*"],
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Drive-by, the HuJSON example was not valid. Switching from the ACL to the Grant syntax at the same time.

// non-syntax errors are logged but do not fail the plan operation
tflog.Debug(ctx,"ACL validation unsuccessful due to advisory error",map[string]interface{}{"error":err})
returnnil
}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

From our conversations, warnings might be counterproductive and confuse people, but we should not make the information completely unavailable.

oxtoacart reacted with thumbs up emoji
Some resources like SCIM groups can be created and added as a reference to the policy file in the same run. The eager validation causes otherwise valid runs to fail at the plan step because the references do not exist yet.We are relaxing the plan validation logic to avoid such false positives. The full validation results are still available in debug logs in case this is useful. Note that the validation is done in full during an apply before the policy file is changed so this does not permit a tailnet policy to be in an invalid state.Fixes#546Signed-off-by: mcoulombe <max@tailscale.com>
@mcoulombemcoulombeforce-pushed themax/relax-acl-plan-validations branch from5e104df toc70357aCompareOctober 3, 2025 18:15
Copy link
Collaborator

@oxtoacartoxtoacart left a comment

Choose a reason for hiding this comment

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

Code LGTM, just a couple of suggestions.

returnerr
}elseiferr!=nil {
// non-syntax errors are logged but do not fail the plan operation
tflog.Debug(ctx,"ACL validation unsuccessful due to advisory error",map[string]interface{}{"error":err})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tflog.Debug(ctx,"ACL validation unsuccessful due to advisoryerror",map[string]interface{}{"error":err})
tflog.Debug(ctx,"ACL validation unsuccessful due to advisorywarning, apply may fail if dependencies are unmet",map[string]interface{}{"error":err})

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I can soften the wording and call them warnings, but the validation failures are not necessarily undefined dependencies. The provider should not characterize what caused the error if it just forwards what the BE returned, which can change in the future.

oxtoacart reacted with thumbs up emoji
Copy link
Collaborator

Choose a reason for hiding this comment

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

are not necessarily

Hence the use of "may"

// TODO: use an exported variable when https://github.com/hashicorp/terraform-plugin-sdk/issues/803 has been addressed.
constUnknownVariableValue="74D93920-ED26-11E3-AC10-0800200C9A66"

varsyntaxErrorMessage=regexp.MustCompile(`^ACL validation failed: line \d+, column \d+:`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe include a comment about what assumptions this makes about the control server.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

What do you mean by assumptions about the control server?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The assumption that all syntax errors present as an error in this form, and that if this change, the logic breaks.

@oxtoacart
Copy link
Collaborator

@mcoulombe Should we just close this one?

@mcoulombe
Copy link
ContributorAuthor

@mcoulombe Should we just close this one?

Once I'm done with the WIF work my plan is to add error codes on the validate endpoint and use that code here instead of the error message format, it seems reasonable to me to update this PR once the BE is ready instead of opening a new one.

oxtoacart reacted with thumbs up emoji

@mcoulombemcoulombe marked this pull request as draftOctober 14, 2025 18:23
@mcoulombe
Copy link
ContributorAuthor

mcoulombe commentedOct 14, 2025
edited
Loading

Converting to draft since it requires downstream BE changes and has been a bit deprioritized to get some internal projects over the finish line. I'll come back to it as soon when possible

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@oxtoacartoxtoacartoxtoacart approved these changes

@mpminardimpminardiAwaiting requested review from mpminardi

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Allow bypassing ACL validation for groups

2 participants

@mcoulombe@oxtoacart

[8]ページ先頭

©2009-2025 Movatter.jp