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

Reduce permission of antrea-agent service account #3691

Merged
merged 1 commit into from May 6, 2022

Conversation

xliuxu
Copy link
Contributor

@xliuxu xliuxu commented Apr 27, 2022

Remove the update permission for services/status of antrea-agent
service account. Remove the optimization for ExternalTrafficPolicy
setting to Local cases in ServiceExternalIP feature accordingly.

Signed-off-by: Xu Liu xliu2@vmware.com

tnqn
tnqn previously approved these changes Apr 27, 2022
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn tnqn requested a review from antoninbas April 27, 2022 05:20
@tnqn tnqn added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. action/release-note Indicates a PR that should be included in release notes. action/backport Indicates a PR that requires backports. labels Apr 27, 2022
@xliuxu
Copy link
Contributor Author

xliuxu commented Apr 27, 2022

@tnqn The e2e test failed because with this change the testing code cannot determine which Node owns the external IP. Most of the test cases will need to check the assigned Node by the hostname field in the status of a Service. I cannot find an easy way to figure out which Node owns the IP as they are not physically assigned. Do you think it is OK to remove all related test cases until we have a new API for assigned Node checking?

@antoninbas
Copy link
Contributor

@tnqn The e2e test failed because with this change the testing code cannot determine which Node owns the external IP. Most of the test cases will need to check the assigned Node by the hostname field in the status of a Service. I cannot find an easy way to figure out which Node owns the IP as they are not physically assigned. Do you think it is OK to remove all related test cases until we have a new API for assigned Node checking?

@xliuxu we don't assign the IP to the transport interface?

@xliuxu
Copy link
Contributor Author

xliuxu commented Apr 28, 2022

@antoninbas No. For LB IP of Services, we do not assign IP to any interfaces on the Node. Otherwise, it will conflict with the implementation of proxyAll feature. We use userspace ARP/NDP responders to handle ARP/NDP queries instead.

@tnqn
Copy link
Member

tnqn commented Apr 28, 2022

@xliuxu we need a way to check which Node owns the IP for troubleshooting anyway. Could we add a antctl get serviceexternalip command to agent mode to dump something like the following? Ideally, every Node should have consistent result eventually. If the result is not consistent, we could use this command/API for troubleshooting too.

NAMESPACE  NAME        EXTERNAL-IP   NODE
default    service-1   1.1.1.1       worker-1
default    service-2   1.1.1.2       worker-2

@xliuxu xliuxu force-pushed the permission_agent_service_status branch 2 times, most recently from ddb269f to ccbc603 Compare April 29, 2022 08:56
@xliuxu
Copy link
Contributor Author

xliuxu commented Apr 29, 2022

@tnqn Thanks for the suggestion. I have added a new command antctl get serviceexternalip for checking the status of the assigned Node and adjusted the e2e codes.

@xliuxu xliuxu requested a review from tnqn April 29, 2022 08:58
@codecov-commenter
Copy link

codecov-commenter commented Apr 29, 2022

Codecov Report

Merging #3691 (fea1ef5) into main (2065919) will decrease coverage by 6.68%.
The diff coverage is 82.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3691      +/-   ##
==========================================
- Coverage   64.60%   57.91%   -6.69%     
==========================================
  Files         278      393     +115     
  Lines       39640    56425   +16785     
==========================================
+ Hits        25608    32678    +7070     
- Misses      12043    21257    +9214     
- Partials     1989     2490     +501     
Flag Coverage Δ
e2e-tests 46.09% <80.82%> (?)
integration-tests 38.34% <ø> (?)
kind-e2e-tests 53.30% <80.82%> (+0.27%) ⬆️
unit-tests 43.79% <88.09%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/antctl/antctl.go 50.00% <ø> (ø)
pkg/querier/querier.go 55.00% <ø> (ø)
...nt/apiserver/handlers/serviceexternalip/handler.go 51.85% <51.85%> (ø)
pkg/agent/apiserver/apiserver.go 66.66% <100.00%> (+0.36%) ⬆️
...g/agent/controller/serviceexternalip/controller.go 81.56% <100.00%> (+0.19%) ⬆️
pkg/agent/multicast/mcast_controller.go 45.98% <0.00%> (-21.47%) ⬇️
pkg/controller/networkpolicy/tier.go 50.00% <0.00%> (-5.00%) ⬇️
pkg/controller/serviceexternalip/controller.go 68.67% <0.00%> (-4.82%) ⬇️
...ntroller/networkpolicy/networkpolicy_controller.go 70.17% <0.00%> (-0.88%) ⬇️
pkg/agent/openflow/framework.go 86.27% <0.00%> (-0.73%) ⬇️
... and 138 more

@xliuxu xliuxu force-pushed the permission_agent_service_status branch from ccbc603 to 0be085e Compare April 29, 2022 12:05
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM overall

cmd/antrea-agent/agent.go Outdated Show resolved Hide resolved
pkg/querier/querier.go Outdated Show resolved Hide resolved
test/e2e/service_externalip_test.go Outdated Show resolved Hide resolved
@xliuxu xliuxu force-pushed the permission_agent_service_status branch 3 times, most recently from 7448c54 to 28d0dac Compare April 29, 2022 15:56
tnqn
tnqn previously approved these changes May 5, 2022
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented May 5, 2022

/test-all

@tnqn
Copy link
Member

tnqn commented May 5, 2022

@antoninbas will you take another look?

Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

some small comments and questions, but overall LGTM

pkg/agent/controller/serviceexternalip/controller.go Outdated Show resolved Hide resolved
pkg/antctl/antctl.go Outdated Show resolved Hide resolved
pkg/antctl/antctl.go Outdated Show resolved Hide resolved
pkg/antctl/antctl.go Outdated Show resolved Hide resolved
@@ -82,6 +83,7 @@ func installHandlers(aq agentquerier.AgentQuerier, npq querier.AgentNetworkPolic
s.Handler.NonGoRestfulMux.HandleFunc("/addressgroups", addressgroup.HandleFunc(npq))
s.Handler.NonGoRestfulMux.HandleFunc("/ovsflows", ovsflows.HandleFunc(aq))
s.Handler.NonGoRestfulMux.HandleFunc("/ovstracing", ovstracing.HandleFunc(aq))
s.Handler.NonGoRestfulMux.HandleFunc("/serviceexternalip", serviceexternalip.HandleFunc(seipq))
Copy link
Contributor

Choose a reason for hiding this comment

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

you may want to add the /serviceexternalip URL to the antctl RBAC ClusterRole, just for consistency (and in case someone is using the antctl ServiceAccount token to access antrea APIs directly)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added.

Comment on lines 445 to 454
info := make([]querier.ServiceExternalIPInfo, len(c.externalIPStates))
idx := 0
for k, v := range c.externalIPStates {
info[idx].ServiceName = k.Name
info[idx].Namespace = k.Namespace
info[idx].ExternalIP = v.ip
info[idx].ExternalIPPool = v.ipPool
info[idx].AssignedNode = v.assignedNode
idx++
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think something like this is more elegant:

info := make([]querier.ServiceExternalIPInfo, 0, len(c.externalIPStates))
for k, v := range c.externalIPStates {
    info = append(info, querier.ServiceExternalIPInfo{
        ServiceName: k.Name,
        // ...
    })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. updated.

@@ -71,7 +71,7 @@ type ServiceExternalIPController struct {

queue workqueue.RateLimitingInterface

externalIPStates map[apimachinerytypes.NamespacedName]externalIPState
externalIPStates map[apimachinerytypes.NamespacedName]*externalIPState
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason for making this is a pointer? Based on usage in GetServiceExternalIPStatus, it doesn't seem 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.

It is just for the defer statement to save the externalIPState. I have reverted this change since it is not necessary and can also be achieved by changing the signature of func saveServiceState.

@xliuxu xliuxu force-pushed the permission_agent_service_status branch 3 times, most recently from 157d878 to 03b44ae Compare May 6, 2022 01:46
tnqn
tnqn previously approved these changes May 6, 2022
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

Remove the update permission for services/status of antrea-agent
service account. Remove the optimization for ExternalTrafficPolicy
setting to Local cases in ServiceExternalIP feature accordingly.
Introduce "antctl get serviceexternalip" command for the agent to
make checking the assigned Node of external IPs easier.

Signed-off-by: Xu Liu <xliu2@vmware.com>
@@ -113,7 +113,7 @@ func testAntctlAgentLocalAccess(t *testing.T, data *TestData) {
cmd := strings.Join(args, " ")
t.Run(cmd, func(t *testing.T) {
stdout, stderr, err := runAntctl(podName, args, data)
if err != nil {
if err != nil && !strings.HasSuffix(stderr, "not enabled\n") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tnqn I just pushed a new commit with a single line change here to fix the e2e error for antctl.

@tnqn
Copy link
Member

tnqn commented May 6, 2022

/test-all
/test-ipv6-all
/test-ipv6-only-all
/test-windows-all

@xliuxu
Copy link
Contributor Author

xliuxu commented May 6, 2022

/test-networkpolicy
/test-windows-conformance
/test-ipv6-only-networkpolicy
/test-ipv6-e2e

@antoninbas
Copy link
Contributor

@xliuxu please cherry-pick this to release-1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/backport Indicates a PR that requires backports. action/release-note Indicates a PR that should be included in release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants