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

ROX-20713: Add log with connection details (External Entities in NWG) #8580

Merged
merged 5 commits into from
Nov 16, 2023

Conversation

vikin91
Copy link
Contributor

@vikin91 vikin91 commented Nov 10, 2023

Description

Currently, if customers see an edge connecting a container with External Entities on the network graph, then they have no information about this connection.

With this PR, we are adding a log line to Sensor with information about all external connections that are unknown. It means that we show source and destination of the connection (namespace + container name on one side, and IP address and port on the other side) for all cases when "External Entities" would appear on the graph.

Note that we will not show this log line, if the source/destination is external but belongs to the known CIDR ranges. In that case, we will show the name associated with the CIDR range on the graph and no log entry will be produced.

Checklist

  • Investigated and inspected CI test results

N/A

  • Unit test and regression tests added
  • Evaluated and added CHANGELOG entry if required
  • Determined and documented upgrade steps
  • Documented user facing changes (create PR based on openshift/openshift-docs and merge into rhacs-docs)

Testing Performed

Here I tell how I validated my change

  • I have deployed a cluster and triggered an edge to "External Entities" (stackrox has such edges by default)
  • Opened Sensor logs and visually confirmed that the log line appears.
(...) Warn: Outgoing connection from container stackrox/central to "169.254.169.254:80". Marking it as 'External Entities' in the network graph.
(...) Warn: Outgoing connection from container stackrox/central to "255.255.255.255:443". Marking it as 'External Entities' in the network graph.
(...) Warn: Incoming connection to container stackrox/central from "10.74.41.227:8443". Marking it as 'External Entities' in the network graph.

Screenshot 2023-11-10 at 12 27 36

Reminder for reviewers

In addition to reviewing code here, reviewers must also review testing and request further testing in case the
performed one does not seem sufficient. As a reviewer, you must not approve the change until you understand the
performed testing and you are satisfied with it.

@vikin91 vikin91 requested a review from a team as a code owner November 10, 2023 10:22
@vikin91 vikin91 changed the title ROX-20713: Add log line with details about a connection to/from external entities ROX-20713: Add log line with details when showing "external entities" in Nwg Nov 10, 2023
@vikin91 vikin91 changed the title ROX-20713: Add log line with details when showing "external entities" in Nwg ROX-20713: Add log with connection details for External Entities in NWG Nov 10, 2023
@vikin91 vikin91 changed the title ROX-20713: Add log with connection details for External Entities in NWG ROX-20713: Add log with connection details (External Entities in NWG) Nov 10, 2023
@ghost
Copy link

ghost commented Nov 10, 2023

Images are ready for the commit at b66d6cf.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.3.x-147-gb66d6cf868.

@vikin91
Copy link
Contributor Author

vikin91 commented Nov 10, 2023

/test gke-qa-e2e-tests

@vikin91 vikin91 requested a review from ovalenti November 10, 2023 15:37
Copy link
Contributor

@ovalenti ovalenti left a comment

Choose a reason for hiding this comment

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

As I understand it, the new log statements can display something else than 255.255.255.255 or ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff only when collector is configured with ROX_ENABLE_EXTERNAL_IPS. Is this correct ?

sensor/common/networkflow/manager/manager_impl.go Outdated Show resolved Hide resolved
Copy link
Contributor

@Maddosaurus Maddosaurus left a comment

Choose a reason for hiding this comment

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

LGTM!

Regarding the log output:
I don't know about v6 compatibility at this point, but we should maybe think about it as we investigate the NetworkGraph further.
Looking at this KCS, it seems OpenShift can run a v4/v6 DualStack, but runs v4 only by default.

@vikin91
Copy link
Contributor Author

vikin91 commented Nov 13, 2023

@Maddosaurus IPv6 is a good point, but I have not tested it on a cluster that would use it. I guess that for such cases, we would use the same structure:

type connection struct {
	local       net.NetworkPeerID
	remote      net.NumericEndpoint
	containerID string
	incoming    bool
}

The net.NumericEndpoint holds inside an IPAddress which // IPAddress represents an IP (v4 or v6) address.
I hope that this should be enough to cover both types of addresses.

@vikin91 vikin91 force-pushed the piotr/ROX-20713-ext-entity-diag branch from d52711c to d82ff02 Compare November 15, 2023 14:35
@vikin91
Copy link
Contributor Author

vikin91 commented Nov 15, 2023

Copy link
Contributor

@ovalenti ovalenti left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

I am just a bit concerned with the processing involved in formatting the strings. Lazy evaluation mechanism in Go seems to be planned for Go2 (golang/go#37739).
IP conversion to string and concatenation will seemingly always occur whatever the log level (https://github.com/stackrox/zap/blob/master/sugar.go#L218)

@vikin91 vikin91 merged commit 38aba04 into master Nov 16, 2023
@vikin91 vikin91 deleted the piotr/ROX-20713-ext-entity-diag branch November 16, 2023 10:15
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.

3 participants