@@ -21,8 +21,10 @@ import (
2121 "net/http"
2222 "os"
2323 "os/signal"
24+ "strconv"
2425 "syscall"
2526
27+ "github.com/containerd/containerd/namespaces"
2628 "github.com/sirupsen/logrus"
2729 "golang.org/x/sync/errgroup"
2830
@@ -33,13 +35,15 @@ import (
3335
3436var (
3537 port int
38+ remotePort int
3639 containerdSockPath string
3740 logger * logrus.Logger
3841)
3942
4043func init () {
4144 flag .IntVar (& port , "port" , 10001 , "service port for address resolver" )
4245 flag .StringVar (& containerdSockPath , "containerdSocket" , "/run/firecracker-containerd/containerd.sock" , "filepath to the containerd socket" )
46+ flag .IntVar (& remotePort , "remotePort" , 10000 , "the remote port on which the remote snapshotter is listening" )
4347 logger = logrus .New ()
4448}
4549
@@ -71,7 +75,7 @@ func main() {
7175
7276 http .HandleFunc ("/address" , queryAddress )
7377 httpServer := & http.Server {
74- Addr : fmt .Sprintf (":%d" , port ),
78+ Addr : fmt .Sprintf ("127.0.0.1 :%d" , port ),
7579 }
7680
7781 logger .Info (fmt .Sprintf ("http resolver serving at port %d" , port ))
@@ -117,7 +121,8 @@ func queryAddress(writ http.ResponseWriter, req *http.Request) {
117121 }
118122 defer fcClient .Close ()
119123
120- vmInfo , err := fcClient .GetVMInfo (req .Context (), & proto.GetVMInfoRequest {VMID : namespace })
124+ ctx := namespaces .WithNamespace (req .Context (), namespace )
125+ vmInfo , err := fcClient .GetVMInfo (ctx , & proto.GetVMInfoRequest {VMID : namespace })
121126 if err != nil {
122127 logger .WithField ("VMID" , namespace ).WithError (err ).Error ("unable to retrieve VM Info" )
123128 http .Error (writ , "Internal server error" , http .StatusInternalServerError )
@@ -127,8 +132,9 @@ func queryAddress(writ http.ResponseWriter, req *http.Request) {
127132 writ .WriteHeader (http .StatusOK )
128133
129134 response , err := json .Marshal (proxyaddress.Response {
130- Network : "unix" ,
131- Address : vmInfo .VSockPath ,
135+ Network : "unix" ,
136+ Address : vmInfo .VSockPath ,
137+ SnapshotterPort : strconv .Itoa (remotePort ),
132138 })
133139 if err != nil {
134140 http .Error (writ , "Internal server error" , http .StatusInternalServerError )
0 commit comments