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

Add command to force tags on nodes and list tags #558

Merged
merged 51 commits into from
May 16, 2022

Conversation

restanrm
Copy link
Contributor

@restanrm restanrm commented Apr 21, 2022

  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

This PR will fix #356 and fix #525

Work to be done before finalisation of this PR

  • Handle validation errors or normalisation of the name of the tags (tags must start with the tag: prefix)
    this means that we should define a way to return errors in the protobuf. Should we define status and message ?
  • replace add/del in CLI by set
  • make a generic contains function
  • change updateDBMachine to UpdateTags
  • add integration tests
  • add documentation

image

Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

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

I think this looks quite reasonable, some questions, some design.

gen/go/headscale/v1/headscale.pb.go Show resolved Hide resolved
grpcv1.go Outdated Show resolved Hide resolved
machine.go Outdated Show resolved Hide resolved
cmd/headscale/cli/tags.go Outdated Show resolved Hide resolved
cmd/headscale/cli/tags.go Outdated Show resolved Hide resolved
cmd/headscale/cli/tags.go Outdated Show resolved Hide resolved
acls_test.go Show resolved Hide resolved
machine.go Outdated
validTagMap := make(map[string]bool)
invalidTagMap := make(map[string]bool)
for _, tag := range machine.HostInfo.RequestTags {
owners, err := expandTagOwners(aclPolicy, tag, stripEmailDomain)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This whole part of the invalidTagMap really confuses me, and I cant really test what happens from the tests, could you try to elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is bothering you ? The fact that I use a map or the concept of invalidTags ? I'm using a map to remove duplicated tags at insertion. It is possible for a machine to have multiple times the same tag (declared in tailscale up).

Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesnt necessary bother me, I just dont think I understand, what is an invalid and what is a valid?

Copy link
Contributor Author

@restanrm restanrm Apr 25, 2022

Choose a reason for hiding this comment

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

Right, so an invalid tag is a tag added by a user that does'nt have permission to add tags. If joe (a simple user) can setup his computer to be a server (just because he is root on his laptop and added --advertise-tags=tag:server), then he can talk to the database directly even if he should not. So the validation of the tags are made with the TagOwners in the ACL file. The documentation of this feature has not been made yet. It seems necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel that we need to explain this somewhere. Do you have any good location for this ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, maybe in the signature of the function 🤔

@kradalby
Copy link
Collaborator

And we will want some integration tests

@restanrm restanrm marked this pull request as ready for review May 13, 2022 09:58
@restanrm restanrm requested a review from juanfont as a code owner May 13, 2022 09:58
Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

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

I think this looks reasonable. Happy to get this in when things passes :)

utils.go Show resolved Hide resolved
machine.go Outdated
validTagMap := make(map[string]bool)
invalidTagMap := make(map[string]bool)
for _, tag := range machine.HostInfo.RequestTags {
owners, err := expandTagOwners(aclPolicy, tag, stripEmailDomain)
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, maybe in the signature of the function 🤔

kradalby and others added 11 commits May 15, 2022 12:11
When running in CI, I obtained the following error:

```
  Running [/home/runner/golangci-lint-1.41.0-linux-amd64/golangci-lint run --out-format=github-actions --new-from-patch=/tmp/tmp-1795-28vaWZek2jfM/pull.patch --new=false --new-from-rev=] in [] ...
  level=error msg="Running error: unknown linters: 'ireturn,maintidx', run 'golangci-lint linters' to see the list of supported linters"
```
@restanrm restanrm force-pushed the feat-list-tags-of-machines branch from 3000742 to 1158210 Compare May 16, 2022 13:26
@kradalby
Copy link
Collaborator

Let's merge this, but can you open a pr or issue with the golang ci snippets that's removed to we can debug that separately ?

I don't want to remove it, but we can remove and then add it back in.

@restanrm
Copy link
Contributor Author

Let's merge this, but can you open a pr or issue with the golang ci snippets that's removed to we can debug that separately ?

I don't want to remove it, but we can remove and then add it back in.

You mean the version pinning in the GithubAction and the ignored linters ?

@kradalby
Copy link
Collaborator

You mean the version pinning in the GithubAction and the ignored linters ?

9f08212

This one

@kradalby kradalby merged commit 747d64c into juanfont:main May 16, 2022
@restanrm
Copy link
Contributor Author

oh, ok it didn't work anyway…

@anuragbhatia
Copy link

Can someone please share exact command for listing nodes?

headscale nodes list

Gives me nodes list but not the tags. Tried few others like headscale nodes tag list but did not work either.

@blargg
Copy link

blargg commented May 13, 2023

headscale node list --tags will list the nodes with tag information. It's not shown in the default node list (without --tags).

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.

Manually add tags to nodes from headscale View Tags
4 participants