Skip to content

cmd/containerboot: ensure that --advertise-routes can be unset - #10734

Merged
irbekrm merged 1 commit into
mainfrom
irbekrm/containerboot_subnetrouter
Jan 4, 2024
Merged

irbekrm merged 1 commit into
mainfrom
irbekrm/containerboot_subnetrouter

Conversation

@irbekrm

@irbekrm irbekrm commented Jan 3, 2024 •

Copy link
Copy Markdown
Contributor

A Tailnet node can be told to stop advertise subnets by passing an empty string to --advertise-routes flag to tailscale up/tailscale set.
containerboot currently ignores TS_ROUTES if it's set to empty string, which means that the only way to stop a containerised tailscale with TS_AUTH_ONCE set to true would be to recreate it (if it's not created with TS_AUTH_ONCE this can probably be achieved by passing --advertise-routes to TS_EXTRA_ARGS instead (?)).
This would cause issues for #10724 where we need to be able to update a Tailnet node corresponding to a Connector custom resource to be/not be a subnet router as users update Connector spec.

This PR ensures that if TS_ROUTES is explicitly set to an empty value a --advertise-routes= is passed to tailscale up/tailscale set so that if the node is currently acting as a subnet router it will no longer do that.

Updates #10708

@irbekrm
irbekrm force-pushed the irbekrm/containerboot_subnetrouter branch 3 times, most recently from 5eb9086 to c46940e Compare January 3, 2024 21:31
@irbekrm
irbekrm requested a review from maisem January 3, 2024 21:46
Comment thread cmd/containerboot/main.go Resolved
Comment thread cmd/containerboot/main.go Outdated
@@ -651,6 +651,8 @@ func tailscaleUp(ctx context.Context, cfg *settings) error {
}
if cfg.Routes != "" {

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.

Could also convert this into a pointer and have the three states. Unset, set and empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about sth like that, but then that would be inconsistent with the acceptDNS for example where, if it's unset we treat it the same as explicitly set to false. Or is that not a good comparison

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.

just thinking about the backwards compat problem, not sure if its applicable here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can't think of a standard flow where this would be set once and not again. Maybe there is some mystery reason for someone to, instead of providing the value via env var, to ssh to the container at a specific point in time and expose a route that way, not sure why anyone would do that, but we'd probably break that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, I guess there isn't a particular reason to unset the subnet routes if the env var is not provided because we again assume that the standard flow would have all config opts. So maybe it's more valuable to have the 3 values for backwards compat

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should be better now

@irbekrm
irbekrm force-pushed the irbekrm/containerboot_subnetrouter branch 3 times, most recently from 6ce669b to 90fbce1 Compare January 4, 2024 08:28
A Tailnet node can be told to stop advertise subnets by passing
an empty string to --advertise-routes flag.
Respect an explicitly passed empty value to TS_ROUTES env var
so that users have a way to stop containerboot acting as a subnet
router without recreating it.
Distinguish between TS_ROUTES being unset and empty.

Updates #10708

Signed-off-by: Irbe Krumina <[email protected]>
@irbekrm
irbekrm force-pushed the irbekrm/containerboot_subnetrouter branch from 90fbce1 to fdbbf9e Compare January 4, 2024 08:44
@irbekrm
irbekrm merged commit 5a2eb26 into main Jan 4, 2024
@irbekrm
irbekrm deleted the irbekrm/containerboot_subnetrouter branch January 4, 2024 09:17
chen8945 pushed a commit to Ckid-Home/tailscale that referenced this pull request Jul 31, 2024
…#10734)

A Tailnet node can be told to stop advertise subnets by passing
an empty string to --advertise-routes flag.
Respect an explicitly passed empty value to TS_ROUTES env var
so that users have a way to stop containerboot acting as a subnet
router without recreating it.
Distinguish between TS_ROUTES being unset and empty.

Updates tailscale#10708

Signed-off-by: Irbe Krumina <[email protected]>
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.

2 participants