Upgrade k8s package verison (#5358)
* upgrade k8s package version Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> * Script upgrade and code formatting. Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>
This commit is contained in:
381
vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client/client.go
generated
vendored
381
vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client/client.go
generated
vendored
@@ -24,6 +24,7 @@ import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
@@ -35,25 +36,101 @@ import (
|
||||
type Tunnel interface {
|
||||
// Dial connects to the address on the named network, similar to
|
||||
// what net.Dial does. The only supported protocol is tcp.
|
||||
Dial(protocol, address string) (net.Conn, error)
|
||||
DialContext(requestCtx context.Context, protocol, address string) (net.Conn, error)
|
||||
// Done returns a channel that is closed when the tunnel is no longer serving any connections,
|
||||
// and can no longer be used.
|
||||
Done() <-chan struct{}
|
||||
}
|
||||
|
||||
type dialResult struct {
|
||||
err string
|
||||
err *dialFailure
|
||||
connid int64
|
||||
}
|
||||
|
||||
type pendingDial struct {
|
||||
// resultCh is the channel to send the dial result to
|
||||
resultCh chan<- dialResult
|
||||
// cancelCh is the channel closed when resultCh no longer has a receiver
|
||||
cancelCh <-chan struct{}
|
||||
}
|
||||
|
||||
// TODO: Replace with a generic implementation once it is safe to assume the client is built with go1.18+
|
||||
type pendingDialManager struct {
|
||||
pendingDials map[int64]pendingDial
|
||||
mutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (p *pendingDialManager) add(dialID int64, pd pendingDial) {
|
||||
p.mutex.Lock()
|
||||
defer p.mutex.Unlock()
|
||||
p.pendingDials[dialID] = pd
|
||||
}
|
||||
|
||||
func (p *pendingDialManager) remove(dialID int64) {
|
||||
p.mutex.Lock()
|
||||
defer p.mutex.Unlock()
|
||||
delete(p.pendingDials, dialID)
|
||||
}
|
||||
|
||||
func (p *pendingDialManager) get(dialID int64) (pendingDial, bool) {
|
||||
p.mutex.RLock()
|
||||
defer p.mutex.RUnlock()
|
||||
pd, ok := p.pendingDials[dialID]
|
||||
return pd, ok
|
||||
}
|
||||
|
||||
// TODO: Replace with a generic implementation once it is safe to assume the client is built with go1.18+
|
||||
type connectionManager struct {
|
||||
conns map[int64]*conn
|
||||
mutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (cm *connectionManager) add(connID int64, c *conn) {
|
||||
cm.mutex.Lock()
|
||||
defer cm.mutex.Unlock()
|
||||
cm.conns[connID] = c
|
||||
}
|
||||
|
||||
func (cm *connectionManager) remove(connID int64) {
|
||||
cm.mutex.Lock()
|
||||
defer cm.mutex.Unlock()
|
||||
delete(cm.conns, connID)
|
||||
}
|
||||
|
||||
func (cm *connectionManager) get(connID int64) (*conn, bool) {
|
||||
cm.mutex.RLock()
|
||||
defer cm.mutex.RUnlock()
|
||||
c, ok := cm.conns[connID]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
func (cm *connectionManager) closeAll() {
|
||||
cm.mutex.Lock()
|
||||
defer cm.mutex.Unlock()
|
||||
for _, conn := range cm.conns {
|
||||
close(conn.readCh)
|
||||
}
|
||||
}
|
||||
|
||||
// grpcTunnel implements Tunnel
|
||||
type grpcTunnel struct {
|
||||
stream client.ProxyService_ProxyClient
|
||||
pendingDial map[int64]chan<- dialResult
|
||||
conns map[int64]*conn
|
||||
pendingDialLock sync.RWMutex
|
||||
connsLock sync.RWMutex
|
||||
stream client.ProxyService_ProxyClient
|
||||
clientConn clientConn
|
||||
pendingDial pendingDialManager
|
||||
conns connectionManager
|
||||
|
||||
// The tunnel will be closed if the caller fails to read via conn.Read()
|
||||
// more than readTimeoutSeconds after a packet has been received.
|
||||
readTimeoutSeconds int
|
||||
|
||||
// The done channel is closed after the tunnel has cleaned up all connections and is no longer
|
||||
// serving.
|
||||
done chan struct{}
|
||||
|
||||
// closing is an atomic bool represented as a 0 or 1, and set to true when the tunnel is being closed.
|
||||
// closing should only be accessed through atomic methods.
|
||||
// TODO: switch this to an atomic.Bool once the client is exclusively buit with go1.19+
|
||||
closing uint32
|
||||
}
|
||||
|
||||
type clientConn interface {
|
||||
@@ -66,37 +143,65 @@ var _ clientConn = &grpc.ClientConn{}
|
||||
// gRPC based proxy service.
|
||||
// Currently, a single tunnel supports a single connection, and the tunnel is closed when the connection is terminated
|
||||
// The Dial() method of the returned tunnel should only be called once
|
||||
func CreateSingleUseGrpcTunnel(address string, opts ...grpc.DialOption) (Tunnel, error) {
|
||||
c, err := grpc.Dial(address, opts...)
|
||||
// Deprecated 2022-06-07: use CreateSingleUseGrpcTunnelWithContext
|
||||
func CreateSingleUseGrpcTunnel(tunnelCtx context.Context, address string, opts ...grpc.DialOption) (Tunnel, error) {
|
||||
return CreateSingleUseGrpcTunnelWithContext(context.TODO(), tunnelCtx, address, opts...)
|
||||
}
|
||||
|
||||
// CreateSingleUseGrpcTunnelWithContext creates a Tunnel to dial to a remote server through a
|
||||
// gRPC based proxy service.
|
||||
// Currently, a single tunnel supports a single connection.
|
||||
// The tunnel is normally closed when the connection is terminated.
|
||||
// If createCtx is cancelled before tunnel creation, an error will be returned.
|
||||
// If tunnelCtx is cancelled while the tunnel is still in use, the tunnel (and any in flight connections) will be closed.
|
||||
// The Dial() method of the returned tunnel should only be called once
|
||||
func CreateSingleUseGrpcTunnelWithContext(createCtx, tunnelCtx context.Context, address string, opts ...grpc.DialOption) (Tunnel, error) {
|
||||
c, err := grpc.DialContext(createCtx, address, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
grpcClient := client.NewProxyServiceClient(c)
|
||||
|
||||
stream, err := grpcClient.Proxy(context.Background())
|
||||
stream, err := grpcClient.Proxy(tunnelCtx)
|
||||
if err != nil {
|
||||
c.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tunnel := &grpcTunnel{
|
||||
stream: stream,
|
||||
pendingDial: make(map[int64]chan<- dialResult),
|
||||
conns: make(map[int64]*conn),
|
||||
readTimeoutSeconds: 10,
|
||||
}
|
||||
tunnel := newUnstartedTunnel(stream, c)
|
||||
|
||||
go tunnel.serve(c)
|
||||
go tunnel.serve(tunnelCtx)
|
||||
|
||||
return tunnel, nil
|
||||
}
|
||||
|
||||
func (t *grpcTunnel) serve(c clientConn) {
|
||||
defer c.Close()
|
||||
func newUnstartedTunnel(stream client.ProxyService_ProxyClient, c clientConn) *grpcTunnel {
|
||||
return &grpcTunnel{
|
||||
stream: stream,
|
||||
clientConn: c,
|
||||
pendingDial: pendingDialManager{pendingDials: make(map[int64]pendingDial)},
|
||||
conns: connectionManager{conns: make(map[int64]*conn)},
|
||||
readTimeoutSeconds: 10,
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (t *grpcTunnel) serve(tunnelCtx context.Context) {
|
||||
defer func() {
|
||||
t.clientConn.Close()
|
||||
|
||||
// A connection in t.conns after serve() returns means
|
||||
// we never received a CLOSE_RSP for it, so we need to
|
||||
// close any channels remaining for these connections.
|
||||
t.conns.closeAll()
|
||||
|
||||
close(t.done)
|
||||
}()
|
||||
|
||||
for {
|
||||
pkt, err := t.stream.Recv()
|
||||
if err == io.EOF {
|
||||
if err == io.EOF || t.isClosing() {
|
||||
return
|
||||
}
|
||||
if err != nil || pkt == nil {
|
||||
@@ -109,24 +214,35 @@ func (t *grpcTunnel) serve(c clientConn) {
|
||||
switch pkt.Type {
|
||||
case client.PacketType_DIAL_RSP:
|
||||
resp := pkt.GetDialResponse()
|
||||
t.pendingDialLock.RLock()
|
||||
ch, ok := t.pendingDial[resp.Random]
|
||||
t.pendingDialLock.RUnlock()
|
||||
pendingDial, ok := t.pendingDial.get(resp.Random)
|
||||
|
||||
if !ok {
|
||||
klog.V(1).Infoln("DialResp not recognized; dropped")
|
||||
} else {
|
||||
result := dialResult{
|
||||
err: resp.Error,
|
||||
connid: resp.ConnectID,
|
||||
}
|
||||
select {
|
||||
case ch <- result:
|
||||
default:
|
||||
klog.ErrorS(fmt.Errorf("blocked pending channel"), "Received second dial response for connection request", "connectionID", resp.ConnectID, "dialID", resp.Random)
|
||||
// On multiple dial responses, avoid leaking serve goroutine.
|
||||
return
|
||||
}
|
||||
// If the DIAL_RSP does not match a pending dial, it means one of two things:
|
||||
// 1. There was a second DIAL_RSP for the connection request (this is very unlikely but possible)
|
||||
// 2. grpcTunnel.DialContext() returned early due to a dial timeout or the client canceling the context
|
||||
//
|
||||
// In either scenario, we should return here and close the tunnel as it is no longer needed.
|
||||
klog.V(1).InfoS("DialResp not recognized; dropped", "connectionID", resp.ConnectID, "dialID", resp.Random)
|
||||
return
|
||||
}
|
||||
|
||||
result := dialResult{connid: resp.ConnectID}
|
||||
if resp.Error != "" {
|
||||
result.err = &dialFailure{resp.Error, DialFailureEndpoint}
|
||||
}
|
||||
select {
|
||||
// try to send to the result channel
|
||||
case pendingDial.resultCh <- result:
|
||||
// unblock if the cancel channel is closed
|
||||
case <-pendingDial.cancelCh:
|
||||
// Note: this condition can only be hit by a race condition where the
|
||||
// DialContext() returns early (timeout) after the pendingDial is already
|
||||
// fetched here, but before the result is sent.
|
||||
klog.V(1).InfoS("Pending dial has been cancelled; dropped", "connectionID", resp.ConnectID, "dialID", resp.Random)
|
||||
return
|
||||
case <-tunnelCtx.Done():
|
||||
klog.V(1).InfoS("Tunnel has been closed; dropped", "connectionID", resp.ConnectID, "dialID", resp.Random)
|
||||
return
|
||||
}
|
||||
|
||||
if resp.Error != "" {
|
||||
@@ -134,62 +250,93 @@ func (t *grpcTunnel) serve(c clientConn) {
|
||||
return
|
||||
}
|
||||
|
||||
case client.PacketType_DIAL_CLS:
|
||||
resp := pkt.GetCloseDial()
|
||||
pendingDial, ok := t.pendingDial.get(resp.Random)
|
||||
|
||||
if !ok {
|
||||
// If the DIAL_CLS does not match a pending dial, it means one of two things:
|
||||
// 1. There was a DIAL_CLS receieved after a DIAL_RSP (unlikely but possible)
|
||||
// 2. grpcTunnel.DialContext() returned early due to a dial timeout or the client canceling the context
|
||||
//
|
||||
// In either scenario, we should return here and close the tunnel as it is no longer needed.
|
||||
klog.V(1).InfoS("DIAL_CLS after dial finished", "dialID", resp.Random)
|
||||
} else {
|
||||
result := dialResult{
|
||||
err: &dialFailure{"dial closed", DialFailureDialClosed},
|
||||
}
|
||||
select {
|
||||
case pendingDial.resultCh <- result:
|
||||
case <-pendingDial.cancelCh:
|
||||
// Note: this condition can only be hit by a race condition where the
|
||||
// DialContext() returns early (timeout) after the pendingDial is already
|
||||
// fetched here, but before the result is sent.
|
||||
case <-tunnelCtx.Done():
|
||||
}
|
||||
}
|
||||
return // Stop serving & close the tunnel.
|
||||
|
||||
case client.PacketType_DATA:
|
||||
resp := pkt.GetData()
|
||||
// TODO: flow control
|
||||
t.connsLock.RLock()
|
||||
conn, ok := t.conns[resp.ConnectID]
|
||||
t.connsLock.RUnlock()
|
||||
conn, ok := t.conns.get(resp.ConnectID)
|
||||
|
||||
if ok {
|
||||
timer := time.NewTimer((time.Duration)(t.readTimeoutSeconds) * time.Second)
|
||||
select {
|
||||
case conn.readCh <- resp.Data:
|
||||
timer.Stop()
|
||||
case <-timer.C:
|
||||
klog.ErrorS(fmt.Errorf("timeout"), "readTimeout has been reached, the grpc connection to the proxy server will be closed", "connectionID", conn.connID, "readTimeoutSeconds", t.readTimeoutSeconds)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
klog.V(1).InfoS("connection not recognized", "connectionID", resp.ConnectID)
|
||||
if !ok {
|
||||
klog.V(1).InfoS("Connection not recognized", "connectionID", resp.ConnectID)
|
||||
continue
|
||||
}
|
||||
timer := time.NewTimer((time.Duration)(t.readTimeoutSeconds) * time.Second)
|
||||
select {
|
||||
case conn.readCh <- resp.Data:
|
||||
timer.Stop()
|
||||
case <-timer.C:
|
||||
klog.ErrorS(fmt.Errorf("timeout"), "readTimeout has been reached, the grpc connection to the proxy server will be closed", "connectionID", conn.connID, "readTimeoutSeconds", t.readTimeoutSeconds)
|
||||
return
|
||||
case <-tunnelCtx.Done():
|
||||
klog.V(1).InfoS("Tunnel has been closed, the grpc connection to the proxy server will be closed", "connectionID", conn.connID)
|
||||
}
|
||||
|
||||
case client.PacketType_CLOSE_RSP:
|
||||
resp := pkt.GetCloseResponse()
|
||||
t.connsLock.RLock()
|
||||
conn, ok := t.conns[resp.ConnectID]
|
||||
t.connsLock.RUnlock()
|
||||
conn, ok := t.conns.get(resp.ConnectID)
|
||||
|
||||
if ok {
|
||||
close(conn.readCh)
|
||||
conn.closeCh <- resp.Error
|
||||
close(conn.closeCh)
|
||||
t.connsLock.Lock()
|
||||
delete(t.conns, resp.ConnectID)
|
||||
t.connsLock.Unlock()
|
||||
return
|
||||
if !ok {
|
||||
klog.V(1).InfoS("Connection not recognized", "connectionID", resp.ConnectID)
|
||||
continue
|
||||
}
|
||||
klog.V(1).InfoS("connection not recognized", "connectionID", resp.ConnectID)
|
||||
close(conn.readCh)
|
||||
conn.closeCh <- resp.Error
|
||||
close(conn.closeCh)
|
||||
t.conns.remove(resp.ConnectID)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dial connects to the address on the named network, similar to
|
||||
// what net.Dial does. The only supported protocol is tcp.
|
||||
func (t *grpcTunnel) Dial(protocol, address string) (net.Conn, error) {
|
||||
func (t *grpcTunnel) DialContext(requestCtx context.Context, protocol, address string) (net.Conn, error) {
|
||||
select {
|
||||
case <-t.done:
|
||||
return nil, errors.New("tunnel is closed")
|
||||
default: // Tunnel is open, carry on.
|
||||
}
|
||||
|
||||
if protocol != "tcp" {
|
||||
return nil, errors.New("protocol not supported")
|
||||
}
|
||||
|
||||
random := rand.Int63() /* #nosec G404 */
|
||||
resCh := make(chan dialResult, 1)
|
||||
t.pendingDialLock.Lock()
|
||||
t.pendingDial[random] = resCh
|
||||
t.pendingDialLock.Unlock()
|
||||
defer func() {
|
||||
t.pendingDialLock.Lock()
|
||||
delete(t.pendingDial, random)
|
||||
t.pendingDialLock.Unlock()
|
||||
}()
|
||||
|
||||
// This channel is closed once we're returning and no longer waiting on resultCh
|
||||
cancelCh := make(chan struct{})
|
||||
defer close(cancelCh)
|
||||
|
||||
// This channel MUST NOT be buffered. The sender needs to know when we are not receiving things, so they can abort.
|
||||
resCh := make(chan dialResult)
|
||||
|
||||
t.pendingDial.add(random, pendingDial{resultCh: resCh, cancelCh: cancelCh})
|
||||
defer t.pendingDial.remove(random)
|
||||
|
||||
req := &client.Packet{
|
||||
Type: client.PacketType_DIAL_REQ,
|
||||
@@ -210,22 +357,98 @@ func (t *grpcTunnel) Dial(protocol, address string) (net.Conn, error) {
|
||||
|
||||
klog.V(5).Infoln("DIAL_REQ sent to proxy server")
|
||||
|
||||
c := &conn{stream: t.stream}
|
||||
c := &conn{
|
||||
stream: t.stream,
|
||||
random: random,
|
||||
closeTunnel: t.closeTunnel,
|
||||
}
|
||||
|
||||
select {
|
||||
case res := <-resCh:
|
||||
if res.err != "" {
|
||||
return nil, errors.New(res.err)
|
||||
if res.err != nil {
|
||||
return nil, res.err
|
||||
}
|
||||
c.connID = res.connid
|
||||
c.readCh = make(chan []byte, 10)
|
||||
c.closeCh = make(chan string, 1)
|
||||
t.connsLock.Lock()
|
||||
t.conns[res.connid] = c
|
||||
t.connsLock.Unlock()
|
||||
t.conns.add(res.connid, c)
|
||||
case <-time.After(30 * time.Second):
|
||||
return nil, errors.New("dial timeout")
|
||||
klog.V(5).InfoS("Timed out waiting for DialResp", "dialID", random)
|
||||
go t.closeDial(random)
|
||||
return nil, &dialFailure{"dial timeout, backstop", DialFailureTimeout}
|
||||
case <-requestCtx.Done():
|
||||
klog.V(5).InfoS("Context canceled waiting for DialResp", "ctxErr", requestCtx.Err(), "dialID", random)
|
||||
go t.closeDial(random)
|
||||
return nil, &dialFailure{"dial timeout, context", DialFailureContext}
|
||||
case <-t.done:
|
||||
klog.V(5).InfoS("Tunnel closed while waiting for DialResp", "dialID", random)
|
||||
return nil, &dialFailure{"tunnel closed", DialFailureTunnelClosed}
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (t *grpcTunnel) Done() <-chan struct{} {
|
||||
return t.done
|
||||
}
|
||||
|
||||
// Send a best-effort DIAL_CLS request for the given dial ID.
|
||||
func (t *grpcTunnel) closeDial(dialID int64) {
|
||||
req := &client.Packet{
|
||||
Type: client.PacketType_DIAL_CLS,
|
||||
Payload: &client.Packet_CloseDial{
|
||||
CloseDial: &client.CloseDial{
|
||||
Random: dialID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := t.stream.Send(req); err != nil {
|
||||
klog.V(5).InfoS("Failed to send DIAL_CLS", "err", err, "dialID", dialID)
|
||||
}
|
||||
t.closeTunnel()
|
||||
}
|
||||
|
||||
func (t *grpcTunnel) closeTunnel() {
|
||||
atomic.StoreUint32(&t.closing, 1)
|
||||
t.clientConn.Close()
|
||||
}
|
||||
|
||||
func (t *grpcTunnel) isClosing() bool {
|
||||
return atomic.LoadUint32(&t.closing) != 0
|
||||
}
|
||||
|
||||
func GetDialFailureReason(err error) (isDialFailure bool, reason DialFailureReason) {
|
||||
var df *dialFailure
|
||||
if errors.As(err, &df) {
|
||||
return true, df.reason
|
||||
}
|
||||
return false, DialFailureUnknown
|
||||
}
|
||||
|
||||
type dialFailure struct {
|
||||
msg string
|
||||
reason DialFailureReason
|
||||
}
|
||||
|
||||
func (df *dialFailure) Error() string {
|
||||
return df.msg
|
||||
}
|
||||
|
||||
type DialFailureReason string
|
||||
|
||||
const (
|
||||
DialFailureUnknown DialFailureReason = "unknown"
|
||||
// DialFailureTimeout indicates the hard 30 second timeout was hit.
|
||||
DialFailureTimeout DialFailureReason = "timeout"
|
||||
// DialFailureContext indicates that the context was cancelled or reached it's deadline before
|
||||
// the dial response was returned.
|
||||
DialFailureContext DialFailureReason = "context"
|
||||
// DialFailureEndpoint indicates that the konnectivity-agent was unable to reach the backend endpoint.
|
||||
DialFailureEndpoint DialFailureReason = "endpoint"
|
||||
// DialFailureDialClosed indicates that the client received a CloseDial response, indicating the
|
||||
// connection was closed before the dial could complete.
|
||||
DialFailureDialClosed DialFailureReason = "dialclosed"
|
||||
// DialFailureTunnelClosed indicates that the client connection was closed before the dial could
|
||||
// complete.
|
||||
DialFailureTunnelClosed DialFailureReason = "tunnelclosed"
|
||||
)
|
||||
|
||||
37
vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client/conn.go
generated
vendored
37
vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client/conn.go
generated
vendored
@@ -30,14 +30,20 @@ import (
|
||||
// successful delivery of CLOSE_REQ.
|
||||
const CloseTimeout = 10 * time.Second
|
||||
|
||||
var errConnCloseTimeout = errors.New("close timeout")
|
||||
|
||||
// conn is an implementation of net.Conn, where the data is transported
|
||||
// over an established tunnel defined by a gRPC service ProxyService.
|
||||
type conn struct {
|
||||
stream client.ProxyService_ProxyClient
|
||||
connID int64
|
||||
random int64
|
||||
readCh chan []byte
|
||||
closeCh chan string
|
||||
rdata []byte
|
||||
|
||||
// closeTunnel is an optional callback to close the underlying grpc connection.
|
||||
closeTunnel func()
|
||||
}
|
||||
|
||||
var _ net.Conn = &conn{}
|
||||
@@ -113,13 +119,30 @@ func (c *conn) SetWriteDeadline(t time.Time) error {
|
||||
// proxy service to notify remote to drop the connection.
|
||||
func (c *conn) Close() error {
|
||||
klog.V(4).Infoln("closing connection")
|
||||
req := &client.Packet{
|
||||
Type: client.PacketType_CLOSE_REQ,
|
||||
Payload: &client.Packet_CloseRequest{
|
||||
CloseRequest: &client.CloseRequest{
|
||||
ConnectID: c.connID,
|
||||
if c.closeTunnel != nil {
|
||||
defer c.closeTunnel()
|
||||
}
|
||||
|
||||
var req *client.Packet
|
||||
if c.connID != 0 {
|
||||
req = &client.Packet{
|
||||
Type: client.PacketType_CLOSE_REQ,
|
||||
Payload: &client.Packet_CloseRequest{
|
||||
CloseRequest: &client.CloseRequest{
|
||||
ConnectID: c.connID,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
} else {
|
||||
// Never received a DIAL response so no connection ID.
|
||||
req = &client.Packet{
|
||||
Type: client.PacketType_DIAL_CLS,
|
||||
Payload: &client.Packet_CloseDial{
|
||||
CloseDial: &client.CloseDial{
|
||||
Random: c.random,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
klog.V(5).InfoS("[tracing] send req", "type", req.Type)
|
||||
@@ -137,5 +160,5 @@ func (c *conn) Close() error {
|
||||
case <-time.After(CloseTimeout):
|
||||
}
|
||||
|
||||
return errors.New("close timeout")
|
||||
return errConnCloseTimeout
|
||||
}
|
||||
|
||||
125
vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client/client.pb.go
generated
vendored
125
vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client/client.pb.go
generated
vendored
@@ -47,6 +47,7 @@ const (
|
||||
PacketType_CLOSE_REQ PacketType = 2
|
||||
PacketType_CLOSE_RSP PacketType = 3
|
||||
PacketType_DATA PacketType = 4
|
||||
PacketType_DIAL_CLS PacketType = 5
|
||||
)
|
||||
|
||||
var PacketType_name = map[int32]string{
|
||||
@@ -55,6 +56,7 @@ var PacketType_name = map[int32]string{
|
||||
2: "CLOSE_REQ",
|
||||
3: "CLOSE_RSP",
|
||||
4: "DATA",
|
||||
5: "DIAL_CLS",
|
||||
}
|
||||
|
||||
var PacketType_value = map[string]int32{
|
||||
@@ -63,6 +65,7 @@ var PacketType_value = map[string]int32{
|
||||
"CLOSE_REQ": 2,
|
||||
"CLOSE_RSP": 3,
|
||||
"DATA": 4,
|
||||
"DIAL_CLS": 5,
|
||||
}
|
||||
|
||||
func (x PacketType) String() string {
|
||||
@@ -103,6 +106,7 @@ type Packet struct {
|
||||
// *Packet_Data
|
||||
// *Packet_CloseRequest
|
||||
// *Packet_CloseResponse
|
||||
// *Packet_CloseDial
|
||||
Payload isPacket_Payload `protobuf_oneof:"payload"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
@@ -165,6 +169,10 @@ type Packet_CloseResponse struct {
|
||||
CloseResponse *CloseResponse `protobuf:"bytes,6,opt,name=closeResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Packet_CloseDial struct {
|
||||
CloseDial *CloseDial `protobuf:"bytes,7,opt,name=closeDial,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*Packet_DialRequest) isPacket_Payload() {}
|
||||
|
||||
func (*Packet_DialResponse) isPacket_Payload() {}
|
||||
@@ -175,6 +183,8 @@ func (*Packet_CloseRequest) isPacket_Payload() {}
|
||||
|
||||
func (*Packet_CloseResponse) isPacket_Payload() {}
|
||||
|
||||
func (*Packet_CloseDial) isPacket_Payload() {}
|
||||
|
||||
func (m *Packet) GetPayload() isPacket_Payload {
|
||||
if m != nil {
|
||||
return m.Payload
|
||||
@@ -217,6 +227,13 @@ func (m *Packet) GetCloseResponse() *CloseResponse {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Packet) GetCloseDial() *CloseDial {
|
||||
if x, ok := m.GetPayload().(*Packet_CloseDial); ok {
|
||||
return x.CloseDial
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX_OneofWrappers is for the internal use of the proto package.
|
||||
func (*Packet) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
@@ -225,6 +242,7 @@ func (*Packet) XXX_OneofWrappers() []interface{} {
|
||||
(*Packet_Data)(nil),
|
||||
(*Packet_CloseRequest)(nil),
|
||||
(*Packet_CloseResponse)(nil),
|
||||
(*Packet_CloseDial)(nil),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,6 +451,46 @@ func (m *CloseResponse) GetConnectID() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
type CloseDial struct {
|
||||
// random id of the DialRequest
|
||||
Random int64 `protobuf:"varint,1,opt,name=random,proto3" json:"random,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CloseDial) Reset() { *m = CloseDial{} }
|
||||
func (m *CloseDial) String() string { return proto.CompactTextString(m) }
|
||||
func (*CloseDial) ProtoMessage() {}
|
||||
func (*CloseDial) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_fec4258d9ecd175d, []int{5}
|
||||
}
|
||||
|
||||
func (m *CloseDial) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_CloseDial.Unmarshal(m, b)
|
||||
}
|
||||
func (m *CloseDial) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_CloseDial.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *CloseDial) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_CloseDial.Merge(m, src)
|
||||
}
|
||||
func (m *CloseDial) XXX_Size() int {
|
||||
return xxx_messageInfo_CloseDial.Size(m)
|
||||
}
|
||||
func (m *CloseDial) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_CloseDial.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_CloseDial proto.InternalMessageInfo
|
||||
|
||||
func (m *CloseDial) GetRandom() int64 {
|
||||
if m != nil {
|
||||
return m.Random
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
// connectID to connect to
|
||||
ConnectID int64 `protobuf:"varint,1,opt,name=connectID,proto3" json:"connectID,omitempty"`
|
||||
@@ -449,7 +507,7 @@ func (m *Data) Reset() { *m = Data{} }
|
||||
func (m *Data) String() string { return proto.CompactTextString(m) }
|
||||
func (*Data) ProtoMessage() {}
|
||||
func (*Data) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_fec4258d9ecd175d, []int{5}
|
||||
return fileDescriptor_fec4258d9ecd175d, []int{6}
|
||||
}
|
||||
|
||||
func (m *Data) XXX_Unmarshal(b []byte) error {
|
||||
@@ -499,6 +557,7 @@ func init() {
|
||||
proto.RegisterType((*DialResponse)(nil), "DialResponse")
|
||||
proto.RegisterType((*CloseRequest)(nil), "CloseRequest")
|
||||
proto.RegisterType((*CloseResponse)(nil), "CloseResponse")
|
||||
proto.RegisterType((*CloseDial)(nil), "CloseDial")
|
||||
proto.RegisterType((*Data)(nil), "Data")
|
||||
}
|
||||
|
||||
@@ -507,37 +566,39 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_fec4258d9ecd175d = []byte{
|
||||
// 472 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xd1, 0x6e, 0x9b, 0x30,
|
||||
0x14, 0x85, 0x00, 0x49, 0xb8, 0x21, 0x15, 0xb2, 0xa6, 0x09, 0x75, 0x93, 0x5a, 0xf1, 0x14, 0x55,
|
||||
0x0b, 0x54, 0xa9, 0x34, 0xed, 0x35, 0x0d, 0xa9, 0x52, 0xa9, 0x5a, 0x99, 0xd3, 0xa7, 0xee, 0x61,
|
||||
0xf2, 0xc0, 0x9a, 0x50, 0x18, 0x66, 0xb6, 0x97, 0x8d, 0x0f, 0xda, 0x7f, 0x4e, 0x18, 0x52, 0xc8,
|
||||
0xa4, 0x6d, 0x52, 0x9f, 0xe0, 0x1c, 0xdf, 0x73, 0x7c, 0x7d, 0xae, 0x0d, 0xf3, 0x1d, 0x2b, 0x0a,
|
||||
0x9a, 0xc8, 0x6c, 0x9f, 0xc9, 0x6a, 0x9e, 0xe4, 0x19, 0x2d, 0x64, 0x58, 0x72, 0x26, 0x59, 0xd8,
|
||||
0x82, 0xe6, 0x13, 0x28, 0xce, 0xff, 0x35, 0x80, 0x61, 0x4c, 0x92, 0x1d, 0x95, 0xe8, 0x0c, 0x4c,
|
||||
0x59, 0x95, 0xd4, 0xd3, 0xcf, 0xf5, 0xd9, 0xc9, 0x62, 0x12, 0x34, 0xf4, 0x43, 0x55, 0x52, 0xac,
|
||||
0x16, 0xd0, 0x25, 0x4c, 0xd2, 0x8c, 0xe4, 0x98, 0x7e, 0xfb, 0x4e, 0x85, 0xf4, 0x06, 0xe7, 0xfa,
|
||||
0x6c, 0xb2, 0x70, 0x82, 0xa8, 0xe3, 0x36, 0x1a, 0xee, 0x97, 0xa0, 0x2b, 0x70, 0x1a, 0x28, 0x4a,
|
||||
0x56, 0x08, 0xea, 0x19, 0x4a, 0x32, 0x6d, 0x25, 0x0d, 0xb9, 0xd1, 0xf0, 0x51, 0x11, 0x7a, 0x05,
|
||||
0x66, 0x4a, 0x24, 0xf1, 0x4c, 0x55, 0x6c, 0x05, 0x11, 0x91, 0x64, 0xa3, 0x61, 0x45, 0xd6, 0x8e,
|
||||
0x49, 0xce, 0x04, 0x3d, 0x34, 0x61, 0xb5, 0x8e, 0xab, 0x1e, 0x59, 0x3b, 0xf6, 0x8b, 0xd0, 0x5b,
|
||||
0x98, 0xb6, 0xb8, 0xed, 0x63, 0xa8, 0x54, 0x27, 0x07, 0xd5, 0x53, 0x23, 0xc7, 0x65, 0xd7, 0x36,
|
||||
0x8c, 0x4a, 0x52, 0xe5, 0x8c, 0xa4, 0xfe, 0x47, 0x98, 0xf4, 0xce, 0x89, 0x4e, 0x61, 0xac, 0xf2,
|
||||
0x4b, 0x58, 0xae, 0xf2, 0xb2, 0xf1, 0x13, 0x46, 0x1e, 0x8c, 0x48, 0x9a, 0x72, 0x2a, 0x84, 0x8a,
|
||||
0xc8, 0xc6, 0x07, 0x88, 0x5e, 0xc2, 0x90, 0x93, 0x22, 0x65, 0x5f, 0x55, 0x10, 0x06, 0x6e, 0x91,
|
||||
0xff, 0x08, 0x4e, 0x3f, 0x11, 0xf4, 0x02, 0x2c, 0xca, 0x39, 0xe3, 0xad, 0x75, 0x03, 0xd0, 0x6b,
|
||||
0xb0, 0x93, 0x66, 0xb6, 0xb7, 0x91, 0x72, 0x36, 0x70, 0x47, 0xfc, 0xd5, 0xfb, 0x0d, 0x38, 0xfd,
|
||||
0x6c, 0x8e, 0x5d, 0xf4, 0x3f, 0x5c, 0xfc, 0x15, 0x4c, 0x8f, 0x32, 0x79, 0x4e, 0x2b, 0xfe, 0x7b,
|
||||
0x30, 0xeb, 0x99, 0xfd, 0x7b, 0xab, 0xce, 0x79, 0xd0, 0x77, 0x46, 0xed, 0xf0, 0xeb, 0x43, 0x38,
|
||||
0xcd, 0xcc, 0x2f, 0x62, 0x80, 0xee, 0x2e, 0x22, 0x07, 0xc6, 0xd1, 0xed, 0xf2, 0xee, 0x13, 0x5e,
|
||||
0x7f, 0x70, 0xb5, 0x0e, 0x6d, 0x63, 0x57, 0x47, 0x53, 0xb0, 0x57, 0x77, 0xf7, 0xdb, 0xb5, 0x5a,
|
||||
0x1c, 0xf4, 0xe0, 0x36, 0x76, 0x0d, 0x34, 0x06, 0x33, 0x5a, 0x3e, 0x2c, 0x5d, 0xf3, 0xc2, 0x05,
|
||||
0x6b, 0xad, 0xb6, 0x1b, 0x81, 0xb1, 0xbe, 0xbf, 0x71, 0xb5, 0x45, 0x08, 0x4e, 0xcc, 0xd9, 0xcf,
|
||||
0x6a, 0x4b, 0xf9, 0x3e, 0x4b, 0x28, 0x3a, 0x03, 0x4b, 0x61, 0x34, 0x6a, 0xdf, 0xc1, 0xe9, 0xe1,
|
||||
0xc7, 0xd7, 0x66, 0xfa, 0xa5, 0x7e, 0x7d, 0xf3, 0x18, 0x89, 0xec, 0x8b, 0x08, 0x76, 0xef, 0x44,
|
||||
0x90, 0xb1, 0x90, 0x94, 0x99, 0xa0, 0x7c, 0x4f, 0xf9, 0xbc, 0xa0, 0xf2, 0x07, 0xe3, 0xbb, 0x79,
|
||||
0x59, 0xcb, 0xc3, 0xff, 0xbd, 0xc6, 0xcf, 0x43, 0x85, 0xae, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff,
|
||||
0x64, 0xe0, 0x62, 0xbe, 0xb8, 0x03, 0x00, 0x00,
|
||||
// 505 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x51, 0x8b, 0xd3, 0x40,
|
||||
0x18, 0x4c, 0xda, 0xa4, 0x6d, 0xbe, 0xa6, 0x47, 0x58, 0x44, 0xc2, 0x29, 0xdc, 0x11, 0x5f, 0x4a,
|
||||
0xb1, 0xe9, 0xd1, 0x03, 0xf1, 0xb5, 0xd7, 0xf4, 0xe8, 0x41, 0xf1, 0xea, 0xf6, 0x9e, 0x4e, 0x50,
|
||||
0xd6, 0x64, 0x91, 0xd0, 0x98, 0x8d, 0xbb, 0x6b, 0x35, 0x3f, 0xd3, 0x7f, 0x24, 0xd9, 0xa4, 0x4d,
|
||||
0x22, 0xa8, 0x70, 0x4f, 0xed, 0xcc, 0x7e, 0x33, 0x3b, 0x19, 0xbe, 0x85, 0xe9, 0x9e, 0xa5, 0x29,
|
||||
0x0d, 0x65, 0x7c, 0x88, 0x65, 0x3e, 0x0d, 0x93, 0x98, 0xa6, 0x72, 0x96, 0x71, 0x26, 0xd9, 0xac,
|
||||
0x02, 0xe5, 0x8f, 0xaf, 0x38, 0xef, 0x57, 0x07, 0x7a, 0x5b, 0x12, 0xee, 0xa9, 0x44, 0x17, 0x60,
|
||||
0xc8, 0x3c, 0xa3, 0xae, 0x7e, 0xa9, 0x8f, 0xcf, 0xe6, 0x43, 0xbf, 0xa4, 0x1f, 0xf2, 0x8c, 0x62,
|
||||
0x75, 0x80, 0xae, 0x60, 0x18, 0xc5, 0x24, 0xc1, 0xf4, 0xdb, 0x77, 0x2a, 0xa4, 0xdb, 0xb9, 0xd4,
|
||||
0xc7, 0xc3, 0xb9, 0xed, 0x07, 0x35, 0xb7, 0xd6, 0x70, 0x73, 0x04, 0x5d, 0x83, 0x5d, 0x42, 0x91,
|
||||
0xb1, 0x54, 0x50, 0xb7, 0xab, 0x24, 0xa3, 0x4a, 0x52, 0x92, 0x6b, 0x0d, 0xb7, 0x86, 0xd0, 0x0b,
|
||||
0x30, 0x22, 0x22, 0x89, 0x6b, 0xa8, 0x61, 0xd3, 0x0f, 0x88, 0x24, 0x6b, 0x0d, 0x2b, 0xb2, 0x70,
|
||||
0x0c, 0x13, 0x26, 0xe8, 0x31, 0x84, 0x59, 0x39, 0x2e, 0x1b, 0x64, 0xe1, 0xd8, 0x1c, 0x42, 0x6f,
|
||||
0x60, 0x54, 0xe1, 0x2a, 0x47, 0x4f, 0xa9, 0xce, 0x8e, 0xaa, 0x53, 0x90, 0xf6, 0x18, 0x9a, 0x80,
|
||||
0xa5, 0x88, 0x22, 0xae, 0xdb, 0x57, 0x1a, 0x28, 0x35, 0x05, 0xb3, 0xd6, 0x70, 0x7d, 0x7c, 0x63,
|
||||
0x41, 0x3f, 0x23, 0x79, 0xc2, 0x48, 0xe4, 0x7d, 0x80, 0x61, 0xa3, 0x13, 0x74, 0x0e, 0x03, 0xd5,
|
||||
0x75, 0xc8, 0x12, 0xd5, 0xad, 0x85, 0x4f, 0x18, 0xb9, 0xd0, 0x27, 0x51, 0xc4, 0xa9, 0x10, 0xaa,
|
||||
0x4e, 0x0b, 0x1f, 0x21, 0x7a, 0x0e, 0x3d, 0x4e, 0xd2, 0x88, 0x7d, 0x55, 0xa5, 0x75, 0x71, 0x85,
|
||||
0xbc, 0x47, 0xb0, 0x9b, 0xed, 0xa1, 0x67, 0x60, 0x52, 0xce, 0x19, 0xaf, 0xac, 0x4b, 0x80, 0x5e,
|
||||
0x82, 0x15, 0x96, 0x7b, 0x70, 0x17, 0x28, 0xe7, 0x2e, 0xae, 0x89, 0xbf, 0x7a, 0xbf, 0x06, 0xbb,
|
||||
0xd9, 0x63, 0xdb, 0x45, 0xff, 0xc3, 0xc5, 0x5b, 0xc2, 0xa8, 0xd5, 0xdf, 0x53, 0xa2, 0x78, 0xaf,
|
||||
0xc0, 0x3a, 0x15, 0xda, 0xc8, 0xa5, 0xb7, 0x72, 0xbd, 0x03, 0xa3, 0x58, 0x82, 0x7f, 0xe7, 0xa9,
|
||||
0xaf, 0xef, 0x34, 0xaf, 0x47, 0xd5, 0x36, 0x15, 0x5f, 0x6a, 0x97, 0x4b, 0x34, 0xf9, 0x08, 0x50,
|
||||
0x2f, 0x37, 0xb2, 0x61, 0x10, 0xdc, 0x2d, 0x36, 0x9f, 0xf0, 0xea, 0xbd, 0xa3, 0xd5, 0x68, 0xb7,
|
||||
0x75, 0x74, 0x34, 0x02, 0x6b, 0xb9, 0xb9, 0xdf, 0xad, 0xd4, 0x61, 0xa7, 0x01, 0x77, 0x5b, 0xa7,
|
||||
0x8b, 0x06, 0x60, 0x04, 0x8b, 0x87, 0x85, 0x63, 0x9c, 0x54, 0xcb, 0xcd, 0xce, 0x31, 0x27, 0x0e,
|
||||
0x98, 0x2b, 0x75, 0x79, 0x1f, 0xba, 0xab, 0xfb, 0x5b, 0x47, 0x9b, 0xcf, 0xc0, 0xde, 0x72, 0xf6,
|
||||
0x33, 0xdf, 0x51, 0x7e, 0x88, 0x43, 0x8a, 0x2e, 0xc0, 0x54, 0x18, 0xf5, 0xab, 0x67, 0x76, 0x7e,
|
||||
0xfc, 0xe3, 0x69, 0x63, 0xfd, 0x4a, 0xbf, 0xb9, 0x7d, 0x0c, 0x44, 0xfc, 0x45, 0xf8, 0xfb, 0xb7,
|
||||
0xc2, 0x8f, 0xd9, 0x8c, 0x64, 0xb1, 0xa0, 0xfc, 0x40, 0xf9, 0x34, 0xa5, 0xf2, 0x07, 0xe3, 0xfb,
|
||||
0x69, 0x56, 0xc8, 0x67, 0xff, 0x7b, 0xec, 0x9f, 0x7b, 0x0a, 0x5d, 0xff, 0x0e, 0x00, 0x00, 0xff,
|
||||
0xff, 0x38, 0x1b, 0xf6, 0x4f, 0x17, 0x04, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
||||
@@ -29,6 +29,7 @@ enum PacketType {
|
||||
CLOSE_REQ = 2;
|
||||
CLOSE_RSP = 3;
|
||||
DATA = 4;
|
||||
DIAL_CLS = 5;
|
||||
}
|
||||
|
||||
enum Error {
|
||||
@@ -45,6 +46,7 @@ message Packet {
|
||||
Data data = 4;
|
||||
CloseRequest closeRequest = 5;
|
||||
CloseResponse closeResponse = 6;
|
||||
CloseDial closeDial = 7;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +85,11 @@ message CloseResponse {
|
||||
int64 connectID = 2;
|
||||
}
|
||||
|
||||
message CloseDial {
|
||||
// random id of the DialRequest
|
||||
int64 random = 1;
|
||||
}
|
||||
|
||||
message Data {
|
||||
// connectID to connect to
|
||||
int64 connectID = 1;
|
||||
|
||||
Reference in New Issue
Block a user