Skip to content

Commit

Permalink
Vsock: Add protocol details for expose request type
Browse files Browse the repository at this point in the history
Since now gvisor-tap-vsock have the different protocol implementation
like `unixTotcp`, `unixTounix`, `tcpTotcp` so those details need to
be part of protocol type so that when check for the open port happen it
should match with expose request type.
  • Loading branch information
praveenkumar committed Feb 17, 2022
1 parent 650efe9 commit 281f3a2
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions pkg/crc/machine/vsock.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func unexposePorts() error {
return err
}
for _, port := range alreadyOpenedPorts {
if err := daemonClient.NetworkClient.Unexpose(&types.UnexposeRequest{Local: port.Local}); err != nil {
if err := daemonClient.NetworkClient.Unexpose(&types.UnexposeRequest{Protocol: port.Protocol, Local: port.Local}); err != nil {
mErr.Collect(errors.Wrapf(err, "failed to unexpose port %s ", port.Local))
}
}
Expand Down Expand Up @@ -83,30 +83,35 @@ const (
func vsockPorts(preset crcPreset.Preset) []types.ExposeRequest {
exposeRequest := []types.ExposeRequest{
{
Local: fmt.Sprintf("%s:%d", localIP, constants.VsockSSHPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, internalSSHPort),
Protocol: "tcp",
Local: fmt.Sprintf("%s:%d", localIP, constants.VsockSSHPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, internalSSHPort),
},
}
switch preset {
case crcPreset.OpenShift:
exposeRequest = append(exposeRequest,
types.ExposeRequest{
Local: fmt.Sprintf("%s:%d", localIP, apiPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, apiPort),
Protocol: "tcp",
Local: fmt.Sprintf("%s:%d", localIP, apiPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, apiPort),
},
types.ExposeRequest{
Local: fmt.Sprintf(":%d", httpsPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, httpsPort),
Protocol: "tcp",
Local: fmt.Sprintf(":%d", httpsPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, httpsPort),
},
types.ExposeRequest{
Local: fmt.Sprintf(":%d", httpPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, httpPort),
Protocol: "tcp",
Local: fmt.Sprintf(":%d", httpPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, httpPort),
})
case crcPreset.Podman:
exposeRequest = append(exposeRequest,
types.ExposeRequest{
Local: fmt.Sprintf("%s:%d", localIP, cockpitPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, cockpitPort),
Protocol: "tcp",
Local: fmt.Sprintf("%s:%d", localIP, cockpitPort),
Remote: fmt.Sprintf("%s:%d", virtualMachineIP, cockpitPort),
})
default:
logging.Errorf("Invalid preset: %s", preset)
Expand Down

0 comments on commit 281f3a2

Please sign in to comment.