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

Initial code for NetworkScope - filter outbound listener/routes #9361

Merged
merged 37 commits into from
Dec 7, 2018

Conversation

costinm
Copy link
Contributor

@costinm costinm commented Oct 16, 2018

Enable namespace isolation - the services used in generating outbound listeners and routes will
include only local namespace and explicitly defined imports.

This seems the simplest approach for the current code - we can optimize it further.

Separate PRs will add the import, once the API is finalized - but this setting can already be
used on larger clusters if most namespaces only receive requests from gateways.
For Clusters/EDS we'll build a list based on Listeners/Routes - in a separate PR.

@istio-testing istio-testing added the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Oct 16, 2018
@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Oct 21, 2018
@codecov
Copy link

codecov bot commented Oct 25, 2018

Codecov Report

Merging #9361 into release-1.1 will increase coverage by 7%.
The diff coverage is 69%.

Impacted file tree graph

@@              Coverage Diff               @@
##           release-1.1   #9361      +/-   ##
==============================================
+ Coverage           63%     70%      +7%     
==============================================
  Files              559     436     -123     
  Lines            51528   39652   -11876     
==============================================
- Hits             32384   27492    -4892     
+ Misses           17285   10911    -6374     
+ Partials          1859    1249     -610
Impacted Files Coverage Δ
pkg/mcp/creds/watcher.go 89% <ø> (+1%) ⬆️
pilot/pkg/proxy/envoy/v2/eds.go 79% <ø> (-3%) ⬇️
pilot/pkg/networking/core/v1alpha3/listener.go 82% <ø> (+7%) ⬆️
pilot/pkg/proxy/envoy/v2/discovery.go 72% <ø> (-7%) ⬇️
pilot/pkg/proxy/envoy/v2/ep_filters.go 83% <ø> (-2%) ⬇️
pilot/pkg/proxy/envoy/v2/lds.go 43% <ø> (-14%) ⬇️
pilot/pkg/kube/inject/webhook.go 83% <0%> (+1%) ⬆️
pilot/pkg/networking/core/v1alpha3/httproute.go 92% <100%> (+1%) ⬆️
pilot/pkg/kube/inject/inject.go 79% <50%> (-1%) ⬇️
pilot/pkg/model/context.go 68% <65%> (-1%) ⬇️
... and 232 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a363120...4d8dab5. Read the comment docs.

@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label Oct 25, 2018
# example: '{"start_time": "%START_TIME%", "req_method": "%REQ(:METHOD)%"}'
# Leave empty to use default log format
accessLogFormat: '{{ .Values.global.proxy.accessLogFormat }}'

Copy link
Member

Choose a reason for hiding this comment

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

more bad merge?

// The list will be populated either from explicit declarations or using 'on-demand'
// feature, before generation takes place. Each node may have a different list, based on
// the requests handled by envoy.
serviceDependencies []*Service
Copy link
Member

Choose a reason for hiding this comment

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

A question: how this field can be updated? I can not find.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OnConnect

// egress and other mesh services to only hosts defined in same namespace or
// 'admin' namespaces. Using services from any other namespaces will require the new NetworkScope
// config. In most cases 'istio-system' should be included.
NetworkScopes = os.Getenv("DEFAULT_NAMESPACE_DEPENDENCIES")
Copy link
Member

Choose a reason for hiding this comment

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

Have more comments like format "ns1,ns2,ns3"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok ( this is a short-lived env - will be replaced by values.yaml before release - but should have comments)

// NodeMetadataNetwork defines the network the node belongs to. It is an optional metadata,
// set at injection time. When set, the Endpoints returned to a note and not on same network
// will be replaced with the gateway defined in the settings.
NodeMetadataNetwork = "NETWORK"
Copy link
Member

Choose a reason for hiding this comment

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

I planed to do this kind of work 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sharing work is good :-)

@@ -734,6 +734,8 @@ func (c *Controller) AppendInstanceHandler(f func(*model.ServiceInstance, model.
return nil
}
c.updateEDS(ep)

log.Debugf("Handle endpoint %s in namespace %s", ep.Name, ep.Namespace)
Copy link
Member

Choose a reason for hiding this comment

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

In c.updateEDS there is already a log of this.

Copy link
Member

Choose a reason for hiding this comment

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

remove that looks good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, it moved. Ok.

// Not logging full request, can be very long.
adsLog.Debugf("ADS:RDS: ACK %s %s (%s) %s %s", peerAddr, con.ConID, con.modelNode.ID, discReq.VersionInfo, discReq.ResponseNonce)
// Already got a list of routes to watch and has same length as the request, this is an ack
if discReq.ResponseNonce != "" {
if discReq.ErrorDetail == nil && discReq.ResponseNonce != "" {
Copy link
Member

Choose a reason for hiding this comment

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

no need this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -511,11 +496,11 @@ func (s *DiscoveryServer) StreamAggregatedResources(stream ads.AggregatedDiscove
sort.Strings(routes)
sort.Strings(con.Routes)

if reflect.DeepEqual(con.Routes, routes) {
if reflect.DeepEqual(con.Routes, routes) || len(routes) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

no need too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The 'ack' handling is pretty strange and may change with 'on-demand' - better to be safe.
My understanding is that 'on-demand' will use an ack that has only status code, doesn't include full routes. But I can move this to separate PR.

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 see it was moved up ( had to resolve some conflicts when merging - I think that's the old code.)

res = append(res, s)
}
}
proxy.serviceDependencies = res
Copy link
Member

Choose a reason for hiding this comment

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

Since OnConnect is only called once per proxy, IIUC, serviceDependencies is set once and never updated.

Then this is not accurate.

Copy link
Member

Choose a reason for hiding this comment

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

Like, we create a ServiceEntry, how can this updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, will fix in separate PR ( I have a TODO in pushConnection )

@costinm
Copy link
Contributor Author

costinm commented Dec 6, 2018

/test istio-pilot-e2e-envoyv2-v1alpha3

@rshriram
Copy link
Member

rshriram commented Dec 6, 2018

/lgtm

@istio-testing
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: costinm, rshriram

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@istio-release-robot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs.
Review the full test history for this PR.
/lgtm cancel will stop retrying.

@hzxuzhonghu
Copy link
Member

/hold

initConnectionNode--> OnConnect --> serviceDependencies set, but when no new proxy connect, then serviceDependencies can not be updated.

@istio-testing istio-testing added the do-not-merge/hold Block automatic merging of a PR. label Dec 7, 2018
@hzxuzhonghu
Copy link
Member

@istio-testing istio-testing removed the do-not-merge/hold Block automatic merging of a PR. label Dec 7, 2018
@hzxuzhonghu
Copy link
Member

/test e2e-dashboard

@rshriram rshriram merged commit f30e345 into istio:release-1.1 Dec 7, 2018
@istio-testing
Copy link
Collaborator

@costinm: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
prow/e2e-simpleTests-cni.sh 69a64fe link /test e2e-simpleTests-cni
prow/build-tests.sh 69a64fe link /test build-tests
prow/istio-integ-k8s-tests.sh 99b914b link /test istio-integ-k8s-tests
prow/e2e-mixer-no_auth-mcp.sh d753538 link /test e2e-mixer-no_auth-mcp
prow/istio-pilot-multicluster-e2e.sh 4d8dab5 link /test istio-pilot-multicluster-e2e

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

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.

7 participants