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

connect: endpoints controller deletes ACL token when service is deregistered #571

Merged
merged 5 commits into from
Jul 29, 2021

Conversation

ishustava
Copy link
Contributor

@ishustava ishustava commented Jul 27, 2021

Fixes #540

Changes proposed in this PR:

  • Modify endpoints controller to delete ACL tokens for each service instance that it deregisters
  • Remove TLS+ACLs table tests from endpoints controller tests. These tests were testing that endpoints controller works with a client configured to have TLS and ACLs. I thought this test was not necessary because there isn't any code in the controller that behaves differently if the consul client is configured with any of those and as a result there's no way these tests could fail. The tests testing to the new ACL logic are there but they are only testing the logic that was added and configure test agent to accommodate for that.
  • Create test package under helper and move GenerateServerCerts function from subcommand/common there because it was used outside of subcommand.
  • Create a helper test function to set up auth methods and refactor existing connect-init command tests to use that function.
  • Minor editing fixes of comments etc.

How I've tested this PR:

How I expect reviewers to test this PR:

  • code review

Checklist:

  • Tests added
  • CHANGELOG entry added (HashiCorp engineers only, community PRs should not add a changelog entry)

@ishustava ishustava force-pushed the delete-acl-token branch 2 times, most recently from 5b0b946 to a817f77 Compare July 27, 2021 03:04
@ishustava ishustava marked this pull request as ready for review July 27, 2021 03:26
@ishustava ishustava requested review from a team, ndhanushkodi and thisisnotashwin and removed request for a team July 27, 2021 04:59
Copy link
Contributor

@thisisnotashwin thisisnotashwin left a comment

Choose a reason for hiding this comment

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

It took a while to read but this is an excellent PR!! I'm surprised that we only had to make changes to the endpoints controller in order for the ACL deletion to work (along with the acl write policy). Have a few suggestions but this looks excellent!

I havent tested this myself though.

connect-inject/endpoints_controller.go Show resolved Hide resolved
connect-inject/endpoints_controller_ent_test.go Outdated Show resolved Hide resolved
connect-inject/endpoints_controller_ent_test.go Outdated Show resolved Hide resolved
subcommand/connect-init/command_ent_test.go Show resolved Hide resolved
helper/test/test_util.go Show resolved Hide resolved
Co-authored-by: Ashwin Venkatesh <ashwin@hashicorp.com>
@ishustava
Copy link
Contributor Author

Thank you so much for the review @thisisnotashwin 🙏 🙏 I know it was a bit of a handful to read with all the refactors!

Copy link
Contributor

@ndhanushkodi ndhanushkodi left a comment

Choose a reason for hiding this comment

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

Wow this touches a lot of places and makes it so nice and clean to read! I especially like that you pulled the K8sAuthMethod functions out into test_util. Awesome work, and I just had a few questions.

connect-inject/endpoints_controller.go Outdated Show resolved Hide resolved
Comment on lines -2062 to -2064
c.CAFile = caFile
c.CertFile = certFile
c.KeyFile = keyFile
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this removed because it's just a test and what we care about is the ACL behaviour and not whether the traffic is TLS?

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'm removing because there isn't any behavior in the endpoints controller that's specific to TLS. Since we're passing the consul client to the endpoints controller struct, so long as that client is configured correctly, everything will work. We're configuring that client in the test as well, and so there's no way this test could ever fail. Since it can't fail, I don't think it's that useful to us.

What triggered it though is that with TLS and ACL table tests, adding new tests was getting a hard. At first, I was thinking of separating those tests and refactoring to make them a bit more readable with the new ACL tests added. But then realized that they can't fail, and so we should probably just remove them.

@ishustava ishustava merged commit 81c05aa into master Jul 29, 2021
@ishustava ishustava deleted the delete-acl-token branch July 29, 2021 00:50
ndhanushkodi pushed a commit to ndhanushkodi/consul-k8s that referenced this pull request Aug 5, 2021
* adding terminating gw test without tls/acls

Co-authored-by: Luke Kysow <1034429+lkysow@users.noreply.github.com>
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.

Kubernetes PreStop hook failing to deregister ACLs and service instances
3 participants