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 bootstrap Authenticator and CSR registration #510

Merged
merged 6 commits into from
May 4, 2022
Merged

Add bootstrap Authenticator and CSR registration #510

merged 6 commits into from
May 4, 2022

Conversation

dharmjit
Copy link
Contributor

What this PR does / why we need it:
This PR implements CSR registration and BootstrapAuthenticator controller as per the design for feature #484.
Both CSR registration/BootstrapAuthenticator Controller logic is disabled by default and will be kept behind the SecureAccess feature flag, which can be enabled explicitly while starting the HostAgent.

Which issue(s) this PR fixes :
Fixes #508 #509(partially)

@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2022

Codecov Report

Merging #510 (ac03f57) into main (6ba32a1) will decrease coverage by 3.35%.
The diff coverage is 53.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #510      +/-   ##
==========================================
- Coverage   67.32%   63.97%   -3.36%     
==========================================
  Files          22       25       +3     
  Lines        1732     1904     +172     
==========================================
+ Hits         1166     1218      +52     
- Misses        494      608     +114     
- Partials       72       78       +6     
Impacted Files Coverage Δ
agent/main.go 13.79% <0.00%> (-1.70%) ⬇️
agent/authenticator/bootstrap_authenticator.go 65.38% <65.38%> (ø)
agent/registration/csr.go 66.03% <66.03%> (ø)
agent/registration/host_registrar.go 0.00% <0.00%> (ø)

agent/authenticator/authenticator_test.go Outdated Show resolved Hide resolved
agent/registration/registration_test.go Outdated Show resolved Hide resolved
agent/registration/registration_test.go Outdated Show resolved Hide resolved
agent/registration/registration_test.go Outdated Show resolved Hide resolved
agent/registration/registration_test.go Outdated Show resolved Hide resolved
agent/registration/csr.go Show resolved Hide resolved
agent/host_agent_test.go Outdated Show resolved Hide resolved
agent/host_agent_test.go Show resolved Hide resolved
agent/host_agent_test.go Show resolved Hide resolved
@anusha94
Copy link
Contributor

Dharmjit Singh added 3 commits April 26, 2022 17:11
CSR registration wnd BootstrapAuthenticator will be handled behind SecureAccess feature flag.
CSR resource will be created in the management cluster on the start of
the HostAgent.
BootstrapAuthenticator controller will watch the CSR resources.
Currently placeholders are created for different flows and the
implementation will be raised in differemt PRs
@dharmjit
Copy link
Contributor Author

Also, this part of the code is untested? https://app.codecov.io/gh/vmware-tanzu/cluster-api-provider-bringyourownhost/compare/510/tree/agent/main.go#D1L227

There is already a test case added should create BYOHost CSR in the management cluster, and the code block is only initializing struct type and calling some methods.

agent/registration/csr.go Show resolved Hide resolved
agent/registration/csr_test.go Outdated Show resolved Hide resolved
agent/registration/registration_test.go Outdated Show resolved Hide resolved
@pshail
Copy link
Contributor

pshail commented Apr 27, 2022

Codecov Report

Merging #510 (1e8f8bc) into main (6ba32a1) will decrease coverage by 3.75%.
The diff coverage is 49.49%.

❗ Current head 1e8f8bc differs from pull request most recent head e73f193. Consider uploading reports for the commit e73f193 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #510      +/-   ##
==========================================
- Coverage   67.32%   63.56%   -3.76%     
==========================================
  Files          22       25       +3     
  Lines        1732     1894     +162     
==========================================
+ Hits         1166     1204      +38     
- Misses        494      611     +117     
- Partials       72       79       +7     

Impacted Files Coverage Δ
agent/main.go 14.11% <0.00%> (-1.37%) ⬇️
agent/authenticator/bootstrap_authenticator.go 50.00% <50.00%> (ø)
agent/registration/csr.go 66.66% <66.66%> (ø)
agent/reconciler/host_reconciler.go 79.23% <0.00%> (-2.25%) ⬇️
agent/registration/host_registrar.go 0.00% <0.00%> (ø)

💭 We should try to keep the coverage as is and not reduce it from achieved higher value 💭

The CSR naming is changed to byoh-csr-<hostname> so that the same can be
picked in ByoAdmisisonController.
As CSR is clusterscoped resource, usage of namespace is removed.
EnvTest k8s version is updated to 1.23.3 as ExpirationSeconds is
supported after v1.22.x
@dharmjit
Copy link
Contributor Author

We should try to keep the coverage as is and not reduce it from achieved a higher value

@pshail, I agree. Currently, the code coverage is less

  1. bootstrap_authenticator.go is mostly bootstrap code and once we implement more CSR workflows (approved, denied, etc.), the code coverage will improve for this file.
  2. Similarly for agent/main.go it is mostly variable initialization code.

Copy link
Contributor

@anusha94 anusha94 left a comment

Choose a reason for hiding this comment

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

minor nits. LGTM otherwise.

agent/authenticator/authenticator_suite_test.go Outdated Show resolved Hide resolved
agent/authenticator/authenticator_test.go Outdated Show resolved Hide resolved
agent/registration/csr.go Show resolved Hide resolved
agent/registration/csr.go Show resolved Hide resolved
Copy link
Contributor

@anusha94 anusha94 left a comment

Choose a reason for hiding this comment

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

lgtm

@dharmjit dharmjit requested a review from shubham14bajpai May 4, 2022 04:30
Copy link
Contributor

@pshail pshail left a comment

Choose a reason for hiding this comment

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

Overall LGTM just need clarity on main error handling related to CSR creation failure(s)

agent/host_agent_test.go Show resolved Hide resolved
agent/main.go Show resolved Hide resolved
agent/main.go Show resolved Hide resolved
agent/main.go Show resolved Hide resolved
Copy link
Contributor

@pshail pshail left a comment

Choose a reason for hiding this comment

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

LGTM

@dharmjit dharmjit merged commit cd30026 into vmware-tanzu:main May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Host CSR registration in HostAgent
5 participants