Skip to content

Conversation

sankalpatimilsina12
Copy link

@sankalpatimilsina12 sankalpatimilsina12 commented Feb 28, 2025

This adds a dockerized trace collection service.

  1. The directory has been renamed from the original ndntdump-exp-2023 to generic traces which will be present on the host and will contain collected traces.
  2. The image is under ghcr, tagged and is under a username, happy to upload elsewhere.

Source repository: https://github.com/tntech-ngin/ndn-traffic-capture-scripts/tree/feature/docker

Copy link
Member

@Pesa Pesa left a comment

Choose a reason for hiding this comment

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

Please squash the commits.

volumes:
- /home/.ssh:/root/.ssh:ro
- /home/ndnops/traces:/dump
- ${PWD}/dist/nlsr:/config
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need write access to the ${PWD}/dist/nlsr folder?

Copy link
Author

@sankalpatimilsina12 sankalpatimilsina12 Feb 28, 2025

Choose a reason for hiding this comment

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

I was trying to figure this out, we need the nlsr.conf file, but the read access should be enough.

Copy link
Member

Choose a reason for hiding this comment

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

This was a semi-hack we had in the old scripts to get a unique "node name", IIRC. I think we can do better now with the new framework, e.g. pass the name to the container via env or something...

Copy link
Member

Choose a reason for hiding this comment

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

@pulsejet what's the easiest way to pass the site from host_vars to the container?

Copy link
Contributor

Choose a reason for hiding this comment

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

Create a new config template, have the container read off it.

Choose a reason for hiding this comment

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

The latest commit has an entrypoint.sh.j2 template which directly reads site name.

@yoursunny
Copy link
Member

As discussed in 2025-02-28 meeting, the SSH key pair should be handled as follows:

  • trace-collector should not use the SSH key pair that belongs to the operator or assume its existence.
  • trace-collector should mount a Docker volume that contains its own SSH key pair (for convenience, it could be mounted at /root/.ssh).
  • The public key of the trace-collector's key pair should be published through file-server. This could be achieved by mounting a sub-directory of what's served by the file-server (for example, ${PWD}/dist/file-server/trace-collector-pubkey).

Upon service start, the entrypoint script should perform the following:

  1. If the SSH key pair does not exist in the mountpoint of the Docker volume, generate a key pair noninteractively.
  2. Copy the public key to a directory published by the file-server. This should be done unconditionally, even if the key pair wasn't generated in this session, because it is possible that last time the container crashed between key pair generation and copying.
  3. Invoke the main script.

After the first run of the service, the public key of a router shall be retrievable with ndncat command:

ndncat get-segmented /ndn/edu/neu/file-server/trace-collector-pubkey/id_ed25519.pub

@sankalpatimilsina12 sankalpatimilsina12 force-pushed the feature/trace-collector-service branch from 1199061 to 6d82848 Compare March 28, 2025 15:12
@sankalpatimilsina12
Copy link
Author

sankalpatimilsina12 commented Mar 28, 2025

The entrypoint.sh.j2 has the included flow as discussed. I have added two persistent volume claims for dump and ssh storage, which were added for preserving keys and dumps. The flow was locally verified at my end.

  1. Site is read in the template and cleaned. Eg. /edu/memphis get converted to edu_memphis.
  2. Ssh keys are generated if not already present and copied to fileserver's subdirectory for trace-collector.
  3. Main script is then invoked with the cleaned site name.
  4. Commits squashed.

If we just mount ssh and dump subdirectories under the trace-collector ($PWD/dist/trace-collector/.ssh, etc.), it probably should be enough instead of asking persistent volumes. Please suggest what's best. @pulsejet

Comment on lines +12 to +14
# Ensure permissions
mkdir -p "$SSH_DIR"
chmod 700 "$SSH_DIR"
Copy link
Member

Choose a reason for hiding this comment

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

ssh-keygen should already take care of this, no?

# Generate SSH key pair if not already present
if [[ ! -f "$PRIVATE_KEY" || ! -f "$PUBLIC_KEY" ]]; then
echo "[trace-collector] No SSH key pair found. Generating a new one..."
ssh-keygen -t rsa -b 4096 -N "" -f "$PRIVATE_KEY"
Copy link
Member

Choose a reason for hiding this comment

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

can we use ed25519 instead of rsa?

SSH_DIR="/root/.ssh"
PRIVATE_KEY="$SSH_DIR/id_rsa"
PUBLIC_KEY="$SSH_DIR/id_rsa.pub"
PUBKEY_EXPORT_PATH="/file-server/trace-collector-pubkey/id_rsa.pub"
Copy link
Member

Choose a reason for hiding this comment

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

Just set this to the directory instead of the file name, it seems simpler. The file name should just be the standard one used by openssh (e.g. id_rsa.pub or id_ed25519.pub).

The same applies to the previous two variables. Specifying the file name seems pointless unless there's a way to pass a different identity to the container. If we don't have a use case for this, just keep it simple and use the default openssh naming conventions.

Choose a reason for hiding this comment

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

The file name has been referenced multiple times in the script: Checking existence, non-interactive generation with the file name specified, and during copying. Should we keep the private and public key variables? The export path I believe can just be a directory name.

Copy link
Member

Choose a reason for hiding this comment

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

Should we keep the private and public key variables?

If you prefer to use a variable, that's fine. But one variable for the private key should be enough, the public key name should always be privatekey + .pub per openssh conventions.

The export path I believe can just be a directory name.

On second thought, we should really avoid using a dot in the NDN name of the pubkey (e.g. id_rsa.pub) because one dot becomes four dots in NDN URI syntax, which is quite ugly. I'd say just use the directory name trace-collector-pubkey as the actual key name. I don't think we need a subdir for this.

Copy link
Member

Choose a reason for hiding this comment

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

one dot becomes four dots in NDN URI syntax

False.
One dot becomes four dots only if the component consists solely of dots.

Choose a reason for hiding this comment

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

If you prefer to use a variable, that's fine. But one variable for the private key should be enough, the public key name should always be privatekey + .pub per openssh conventions.

Sure.

restart: unless-stopped
depends_on:
nfd: { condition: service_healthy }
file-server: { condition: service_healthy }
Copy link
Member

Choose a reason for hiding this comment

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

is there an actual dependency on the file server?

Choose a reason for hiding this comment

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

I put this there I think from a documentary perspective, there is no actual dependency. It should be just nfd.

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.

4 participants