@@ -21,8 +21,10 @@ import (
21
21
"net/http"
22
22
"os"
23
23
"os/signal"
24
+ "strconv"
24
25
"syscall"
25
26
27
+ "github.com/containerd/containerd/namespaces"
26
28
"github.com/sirupsen/logrus"
27
29
"golang.org/x/sync/errgroup"
28
30
@@ -33,13 +35,15 @@ import (
33
35
34
36
var (
35
37
port int
38
+ remotePort int
36
39
containerdSockPath string
37
40
logger * logrus.Logger
38
41
)
39
42
40
43
func init () {
41
44
flag .IntVar (& port , "port" , 10001 , "service port for address resolver" )
42
45
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" )
43
47
logger = logrus .New ()
44
48
}
45
49
@@ -71,7 +75,7 @@ func main() {
71
75
72
76
http .HandleFunc ("/address" , queryAddress )
73
77
httpServer := & http.Server {
74
- Addr : fmt .Sprintf (":%d" , port ),
78
+ Addr : fmt .Sprintf ("127.0.0.1 :%d" , port ),
75
79
}
76
80
77
81
logger .Info (fmt .Sprintf ("http resolver serving at port %d" , port ))
@@ -117,7 +121,8 @@ func queryAddress(writ http.ResponseWriter, req *http.Request) {
117
121
}
118
122
defer fcClient .Close ()
119
123
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 })
121
126
if err != nil {
122
127
logger .WithField ("VMID" , namespace ).WithError (err ).Error ("unable to retrieve VM Info" )
123
128
http .Error (writ , "Internal server error" , http .StatusInternalServerError )
@@ -127,8 +132,9 @@ func queryAddress(writ http.ResponseWriter, req *http.Request) {
127
132
writ .WriteHeader (http .StatusOK )
128
133
129
134
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 ),
132
138
})
133
139
if err != nil {
134
140
http .Error (writ , "Internal server error" , http .StatusInternalServerError )
0 commit comments