Giter VIP home page Giter VIP logo

Comments (14)

justincormack avatar justincormack commented on May 22, 2024

I dont think it is a Go issue, network namespaces should be ok in Go. However, I don't believe network configuration is transferred when interfaces are moved into a new namespace (as the config belongs to the other network stack) so you always need to configure after moving to the new namespace.

from opengcs.

rn avatar rn commented on May 22, 2024

My reading of the code is that, eth0 get's configured in the root namespace via configureNetworkAdapter() and that works fine from my logging. @justincormack you are right in that the current config gets lost when the adapter is moved into the new namespace, but moveAdapterIntoNamespace() gathers the current configuration of eth0, moves the interface into the new namespace, and then re-applies the configuration in the new namespace.

The article linked in the OP seems to suggest that, even if one does a runtime.LockOSThread()(as suggested in the netns package, it's still possible, if blocking system calls are executed, the code get executed afterwards on a different thread which is not in the new namespace. libnetwork also seems to bend over backwards to re-exec in some case to execute some code in the new namespace.

from opengcs.

justincormack avatar justincormack commented on May 22, 2024

Oh I see. Yes in that case it will be an issue, yes. Starting another process is easiest then.

from opengcs.

lowenna avatar lowenna commented on May 22, 2024

@beweedon

from opengcs.

rn avatar rn commented on May 22, 2024

FYI, I have been working on a fix, it compiles, now I need test :)

https://github.com/rn/opengcs/tree/net

from opengcs.

beweedon avatar beweedon commented on May 22, 2024

Thanks for root causing this bug! That's a really interesting (and annoying in this case) quirk of the Go runtime. Let me know if you need any help with the fix! I'd be happy to look it over at any point during development!

from opengcs.

rn avatar rn commented on May 22, 2024

I've force pushed an update. I was able to test the new binary manually on a standard Linux system (with a veth pair) and it works without a problem.

However, the integration with gcs does not work and I get an error when trying to run, but there is no meaningful error in the daemon logs. Is there way of getting at /tmp/gcs.log? The utility VM is already gone, so hcsdiag is of no help...

from opengcs.

beweedon avatar beweedon commented on May 22, 2024

Try setting this key to the given value (value 1). It should keep the utility VM alive even on error.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Containers\Debug]
"PreserveVmOnErrorDestruct"=dword:00000001

from opengcs.

rn avatar rn commented on May 22, 2024

@beweedon I tried:

$regPath="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Containers\Debug\"
New-Item -Path $regPath -Force
New-ItemProperty -Path $regPath -Name PreserveVmOnErrorDestruct -PropertyType DWORD -Value 1

And the VM does not stick around. I've also rebooted, just to make sure. I'm on insider build: 16241.1001. Any idea?

from opengcs.

beweedon avatar beweedon commented on May 22, 2024

Oh, ugh, that registry key might not work in this case. Do you have the ability to attach WinDbg and break on C++ errors (Debug > Event Filters, then set C++ EH to enabled)? This should break in before the VM is destructed.

from opengcs.

rn avatar rn commented on May 22, 2024

It's been two years since I last used windbg and that was for remote kernel/driver debug. I may need some more details...but generally yes

from opengcs.

rn avatar rn commented on May 22, 2024

NM thanks to a colleague I managed to get windbg to work and got an intriguing error. debugging

from opengcs.

rn avatar rn commented on May 22, 2024

Ah, it turns out there was an additional issue with the code, namely the netlink Link object may change after the interface was moved to the new namespace in https://github.com/Microsoft/opengcs/blob/master/service/gcs/core/gcs/networking.go#L208

Interfaces are indexed by number and numbers are namespaced too. With a very simple setup you may get lucky that eth0 happens to be index 2 in both the root namespace and the new container namespace. With the LinuxKit kernel that was not the case so we gathered all the info for, say eth0 and then tried to re-apply them to a different interface once the namespace was entered.

from opengcs.

beweedon avatar beweedon commented on May 22, 2024

Thanks so much for figuring out this problem! I'm reviewing your changes now!

from opengcs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.