-
Notifications
You must be signed in to change notification settings - Fork 154
Use container UUID instead of IP address for tracking agent #4470
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
Conversation
Problem: In some cases, a Pod's IP address may not actually be the IP of the Pod. It could be the IP of the node it's running on. This makes verification and tracking difficult to impossible. Solution: Use the UUID of the Pod instead of the IP address, and loosen the validation to not care about the address that connects to the control plane. Also needed to fix the agent's ability to identify us as a container, because otherwise the UUId was of the node, not the container. This involved reverting a previous fix that was added after removing the default service account directory, which agent looked for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR changes the agent tracking mechanism from using Pod IP addresses to using Pod UUIDs to address scenarios where a Pod's IP address may not accurately represent the Pod (e.g., when it's actually the node's IP). The change relaxes validation requirements and fixes the agent's container identification by creating an empty /run/.containerenv file in Docker images.
- Replaced IP-based tracking with UUID-based tracking across the gRPC interceptor and command/file services
- Removed IP address validation logic in favor of UUID validation
- Added
/run/.containerenvfile creation in Dockerfiles to ensure proper container identification
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/controller/nginx/agent/grpc/interceptor/interceptor.go |
Replaced IP address extraction from peer data with UUID from metadata; removed IP-based pod filtering |
internal/controller/nginx/agent/grpc/interceptor/interceptor_test.go |
Updated tests to remove peer/IP validation and use UUID-based tracking |
internal/controller/nginx/agent/grpc/context/context.go |
Changed GrpcInfo struct to use UUID field instead of IPAddress |
internal/controller/nginx/agent/grpc/context/context_test.go |
Updated test to use Token field instead of IPAddress |
internal/controller/nginx/agent/command.go |
Replaced all IPAddress references with UUID for connection tracking |
internal/controller/nginx/agent/command_test.go |
Updated tests to use UUID-based tracking and removed hostname fallback test |
internal/controller/nginx/agent/file.go |
Changed file service methods to use UUID instead of IPAddress |
internal/controller/nginx/agent/file_test.go |
Updated all test contexts to use UUID instead of IPAddress |
build/Dockerfile.nginx |
Added creation of /run/.containerenv file for container identification |
build/Dockerfile.nginxplus |
Added creation of /run/.containerenv file for container identification |
build/ubi/Dockerfile.nginx |
Added creation of /run/.containerenv file for container identification |
build/ubi/Dockerfile.nginxplus |
Added creation of /run/.containerenv file for container identification |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4470 +/- ##
==========================================
- Coverage 86.24% 86.23% -0.01%
==========================================
Files 132 132
Lines 14566 14557 -9
Branches 35 35
==========================================
- Hits 12562 12553 -9
Misses 1791 1791
Partials 213 213 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Problem: In some cases, a Pod's IP address may not actually be the IP of the Pod. It could be the IP of the node it's running on. This makes verification and tracking difficult to impossible. Solution: Use the UUID of the container instead of the IP address, and loosen the validation to not care about the address that connects to the control plane. Also needed to fix the agent's ability to identify us as a container, because otherwise the UUID was of the node, not the container. This involved reverting a previous fix that was added after removing the default service account directory, which agent looked for.
Problem: In some cases, a Pod's IP address may not actually be the IP of the Pod. It could be the IP of the node it's running on. This makes verification and tracking difficult to impossible. Solution: Use the UUID of the container instead of the IP address, and loosen the validation to not care about the address that connects to the control plane. Also needed to fix the agent's ability to identify us as a container, because otherwise the UUID was of the node, not the container. This involved reverting a previous fix that was added after removing the default service account directory, which agent looked for.
Problem: In some cases, a Pod's IP address may not actually be the IP of the Pod. It could be the IP of the node it's running on. This makes verification and tracking difficult to impossible.
Solution: Use the UUID of the container instead of the IP address, and loosen the validation to not care about the address that connects to the control plane.
Also needed to fix the agent's ability to identify us as a container, because otherwise the UUId was of the node, not the container. This involved reverting a previous fix that was added after removing the default service account directory, which agent looked for.
Testing: Verified that everything still works when not using the IP address as the key.
Partially addresses #4426
Checklist
Before creating a PR, run through this checklist and mark each as complete.
Release notes
If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.