Allow NetworkService to be used without an explicit SSH username - #1863
Allow NetworkService to be used without an explicit SSH username#1863ozan956 wants to merge 2 commits into
NetworkService to be used without an explicit SSH username#1863Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1863 +/- ##
========================================
+ Coverage 61.0% 61.1% +0.1%
========================================
Files 182 182
Lines 14882 14903 +21
========================================
+ Hits 9083 9118 +35
+ Misses 5799 5785 -14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Emantor
left a comment
There was a problem hiding this comment.
This is going to be a breaking change for the remote infrastructure, older labgrid will expect the now optional username parameter. IMO we should still use None instead of "" which works around that.
7560f6c to
8408809
Compare
Thanks for the review! I resolved them all now. Sorry for late response. |
So far, `NetworkService.username` was required and `SSHDriver` always passed it to `ssh` and `scp`. This prevented setups where the SSH username is intentionally resolved through the user's SSH configuration or by the default SSH user selection. This change makes `NetworkService.username` optional and updates `SSHDriver` to only pass `-l <username>` or `user@host` when a username is explicitly set. In addition, the client-side fallback `NetworkService` creation path no longer forces `username="root"` and now instantiates the resource with `name=None`, so ad-hoc SSH access can use the normal SSH configuration of the user. This improves compatibility with existing SSH setups and avoids hardcoding a username when it is not actually required. Add regression tests covering the no-username path in SSHDriver and the client-side fallback NetworkService creation. Signed-off-by: Ozan Durgut <ozan.durgut@analog.com>
Clarify that `NetworkService.username` is optional. If no username is configured on `NetworkService` or `SSHDriver`, labgrid lets SSH resolve the username through the local SSH configuration or the default SSH user selection. Signed-off-by: Ozan Durgut <ozan.durgut@analog.com>
8408809 to
579db71
Compare
|
We use |
That is a fair point. For a NetworkService declared in a test environment, I agree that the username should normally be explicit so that test suites behave identically for different users. My use case is shared lab usage rather than making test suites depend on client-side configuration. Several users consume the same environment for ad-hoc ssh/scp operations, and using one fixed Unix account forces them to share the same remote home directory. This can lead to interference between users. Making the username optional allows this shared environment to leave account selection to each user's SSH configuration. Explicitly configured usernames continue to behave exactly as before. Also with #1889, we are going to sharing the envs remotely. So not having a username there would be better I guess. Users gonna anyways having ssh configs at their end. |
|
So in your case, each developer/lab user has their own user account on the target/device-under-test? |
Now we are using a shared user, especially since the ci is the main consumer of it. But once many more people start to use the boards, we cannot control what these all consumers doing with all those available commands. And something like this can happen: user#1 sends u-boot binares to home directory, working on board#1. at the same time user#2 sends their binaries to same home directory for board#2. So they going to be overriden. Since we dont wanna "lock' the directories, I believe the easiest thing is to seperate users. I am open to any other suggestions to get rid of that race condition as well. |
Allow
NetworkServiceto be used without an explicit SSH username.Until now,
NetworkService.usernamewas required andSSHDriveralways passedit through to
ssh,scp, etc. That prevented setups where the SSH user shouldcome from the local SSH configuration or the default SSH user resolution.
This change makes
NetworkService.usernameoptional and updatesSSHDrivertoonly pass
-l <username>oruser@hostwhen a username is explicitly set.The client-side fallback path in
labgrid.remote.clientalso no longer forcesusername="root". While adding regression coverage for that path, this alsosurfaced that the fallback resource creation needs
name=None, which is nowpassed explicitly.
I verified the change with some tests called
test_run_no_username,test_put_get_no_usernameandtest_get_ssh_no_usernamefor the no-username paths.Checklist