client

package
v0.7.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client provides HTCondor API client implementations using the CEDAR protocol.

This package will eventually contain clients for various HTCondor operations, starting with a condor_status equivalent.

Index

Constants

View Source
const DefaultDialerFallbackDelay = 150 * time.Millisecond

DefaultDialerFallbackDelay is the IPv6→IPv4 happy-eyeballs switch-over time used when ClientConfig.FallbackDelay is zero. 150 ms matches the typical higher-level cross-collector race stagger so the two failover mechanisms compose without one drowning the other in concurrent socket attempts.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	// Address is the HTCondor daemon address. Can be:
	// - "host:port" for direct TCP connection
	// - "host:port?sock=daemon_id" for shared port connection
	// - "<host:port?sock=daemon_id>" for shared port connection (HTCondor format)
	Address string

	// Deprecated: Use Address field instead
	Host string
	// Deprecated: Use Address field instead
	Port int

	// Timeout for connection establishment (default: 30 seconds)
	Timeout time.Duration

	// FallbackDelay controls the IPv6/IPv4 "happy eyeballs" race
	// inside net.Dialer.DialContext when the resolved hostname has
	// both AAAA and A records. Go's default is 300 ms; we drop it
	// to 150 ms so failover off a dead IPv6 path stays snappy.
	// Pass a negative value to disable the inner race (matches
	// net.Dialer's documented contract for negative FallbackDelay).
	// Zero = use DefaultDialerFallbackDelay.
	FallbackDelay time.Duration

	// ClientName for shared port connections (for debugging)
	ClientName string

	Security *security.SecurityConfig

	// CCBReturnAddr, if set, enables streaming/proxy mode for CCB sinful
	// addresses: it is this client's own CCB sinful (carrying a ccbid), used
	// when the client is itself behind CCB and cannot accept a direct reverse
	// connection.
	CCBReturnAddr string

	// CCBRequireStreaming makes streaming mode mandatory for CCB addresses
	// (fail fast if the broker does not support it).
	CCBRequireStreaming bool

	// CCBReverseListener, when set, supplies the inbound path for a standard-mode
	// CCB dial instead of a private TCP listen socket -- see
	// ccb.DialOptions.ReverseListener. It lets a client with no port of its own
	// still accept connection reversal, by being reachable on a port it shares
	// (e.g. an in-process shared-port router, server/sharedport).
	//
	// It has no effect when CCBReturnAddr or CCBRequireStreaming select
	// streaming mode: in streaming mode the broker relays on the request socket
	// and nothing reverses. Set one or the other, not both.
	CCBReverseListener ccb.ReverseListenerFunc

	// KeepAlive controls TCP keepalive probing on the dialed connection. When
	// nil, DefaultKeepAliveConfig is used (SO_KEEPALIVE on with HTCondor's
	// idle=360s / interval=5s / count=5 defaults), so a silently-dead peer is
	// detected instead of blocking a goroutine in Read forever. Set a pointer
	// to an explicitly-configured value to override, or to a disabled config
	// (Enable=false) to turn keepalives off.
	KeepAlive *stream.KeepAliveConfig

	// DialControl, if set, is installed as net.Dialer.Control on every outbound
	// TCP connection Connect makes: the direct dial to the daemon, the dial to
	// a shared-port server, and the dials to CCB brokers. It is called after
	// name resolution with the concrete "ip:port" about to be connected to
	// (once per address tried, e.g. per family in the IPv6/IPv4 race), so a
	// caller can refuse a destination by its real IP -- an SSRF guard that a
	// check on the hostname alone cannot provide. Returning an error aborts
	// that connection attempt.
	//
	// For a CCB address the hook sees only the broker connections: the target
	// is never dialed by this client (it connects back, or the broker relays).
	DialControl func(network, address string, c syscall.RawConn) error

	// TraceCommand, if set, is called by ConnectAndAuthenticateWithConfig
	// before it connects, so the embedder can record the command as a span.
	// The context it returns is the one the dial and the handshake run under:
	// return the caller's ctx with the new span on it, and set
	// Security.TraceContext to read the span back, and the server's span for
	// the command becomes its child.
	//
	// The returned function, if non-nil, is called exactly once with what the
	// command did (see TraceResult): by ConnectAndAuthenticateWithConfig
	// when it fails, otherwise by the first Close, so that it covers the whole
	// exchange and counts its bytes. A client that is never closed never
	// reports.
	//
	// Leaving it nil adds nothing to a connection, not even an allocation.
	// Connect alone does not call it. It must not block.
	TraceCommand func(ctx context.Context, cmd TracedCommand) (context.Context, func(TraceResult))
}

ClientConfig holds configuration for HTCondor client connections

type DialInfo added in v0.7.19

type DialInfo struct {
	// Route is how the daemon was reached.
	Route Route

	// Address is what was dialed: the daemon's "host:port" for a direct
	// connection, the shared_port server's for a shared-port one, and the
	// daemon's sinful string for CCB, where the broker that answered is not
	// recorded.
	Address string

	// SharedPortID is the daemon's shared-port socket name, for RouteSharedPort.
	SharedPortID string

	// Duration is the time Connect took: the TCP connection, plus the
	// shared-port hand-off or the CCB request and reversal.
	Duration time.Duration

	// CCB is how a RouteCCB dial went: the winning broker, the mode, and the
	// time to the broker's reply and to the reverse connection.
	CCB ccb.DialInfo

	// Attempts is how many connections ConnectAndAuthenticateWithConfig
	// opened: 2 when a cached session failed to resume and a full handshake
	// followed on a new connection. Connect alone leaves it 0.
	Attempts int
}

DialInfo describes how Connect reached the daemon. Its strings are the ones Connect already held, so recording it allocates nothing.

type HTCondorClient

type HTCondorClient struct {
	// contains filtered or unexported fields
}

HTCondorClient represents a client connection to an HTCondor daemon

func ConnectAndAuthenticate

func ConnectAndAuthenticate(ctx context.Context, address string, securityConfig *security.SecurityConfig) (*HTCondorClient, error)

ConnectAndAuthenticate establishes a connection and performs authentication handshake with automatic retry on session resumption failures. This is the recommended method for establishing authenticated connections to HTCondor daemons.

If session resumption fails (e.g., SID_NOT_FOUND), the function will: 1. Close the current connection 2. Establish a new connection 3. Retry the handshake (which will perform full authentication)

This ensures that failed session resumption attempts don't leave the stream in an unusable state.

func ConnectAndAuthenticateWithConfig

func ConnectAndAuthenticateWithConfig(ctx context.Context, config *ClientConfig) (*HTCondorClient, error)

ConnectAndAuthenticateWithConfig is like ConnectAndAuthenticate but accepts a full ClientConfig

func ConnectToAddress

func ConnectToAddress(ctx context.Context, address string) (*HTCondorClient, error)

ConnectToAddress is a convenience method that creates a client and connects to the specified address

func NewClient

func NewClient(config *ClientConfig) *HTCondorClient

NewClient creates a new HTCondor client

func (*HTCondorClient) BytesReceived added in v0.7.19

func (c *HTCondorClient) BytesReceived() uint64

BytesReceived returns the bytes read from the daemon over this connection; 0 before Connect.

func (*HTCondorClient) BytesSent added in v0.7.19

func (c *HTCondorClient) BytesSent() uint64

BytesSent returns the bytes written to the daemon over this connection, counted as stream.Stream.BytesSent counts them; 0 before Connect.

func (*HTCondorClient) Close

func (c *HTCondorClient) Close() error

Close closes the client connection. For a client whose command is traced (ClientConfig.TraceCommand), the first Close reports it.

func (*HTCondorClient) Connect

func (c *HTCondorClient) Connect(ctx context.Context) error

Connect establishes a connection to the HTCondor daemon

func (*HTCondorClient) DialInfo added in v0.7.19

func (c *HTCondorClient) DialInfo() DialInfo

DialInfo returns how the last Connect reached the daemon. It is the zero value before Connect.

func (*HTCondorClient) GetSecurityNegotiation

func (c *HTCondorClient) GetSecurityNegotiation() *security.SecurityNegotiation

GetSecurityNegotiation returns the security negotiation outcome from the authentication handshake. Returns nil if no authentication was performed.

func (*HTCondorClient) GetStream

func (c *HTCondorClient) GetStream() *stream.Stream

GetStream returns the underlying CEDAR stream for advanced operations

func (*HTCondorClient) IsConnected

func (c *HTCondorClient) IsConnected() bool

IsConnected returns true if the client is connected to a daemon

func (*HTCondorClient) SessionAttr

func (c *HTCondorClient) SessionAttr(name string) (string, bool)

SessionAttr returns one application attribute the peer advertised in its post-authentication ad, for a name this client asked for in SecurityConfig.WantSessionAttrs. A resumed session answers as the handshake that created it did.

ok is false when the peer said nothing under that name, which a caller must read as the oldest behaviour it supports: a peer too old to advertise and a peer that chose not to are the same answer here.

type Route added in v0.7.19

type Route uint8

Route is how Connect reached the daemon.

const (
	// RouteDirect is a TCP connection to the daemon's own port.
	RouteDirect Route = iota
	// RouteSharedPort is a TCP connection to a shared_port server, which
	// passed it to the daemon named by the address's sock= parameter.
	RouteSharedPort
	// RouteCCB is a connection brokered by CCB: the daemon connected back,
	// or the broker relays.
	RouteCCB
)

func (Route) String added in v0.7.19

func (r Route) String() string

type TraceResult added in v0.7.19

type TraceResult struct {
	// Class is the outcome; Err is the error behind it, nil for ErrorNone.
	Class rpctrace.ErrorClass
	Err   error

	// Dial is how the daemon was reached; see DialInfo. For a command that
	// failed to connect its Route and Address are the ones tried.
	Dial DialInfo

	// Negotiation is the security handshake's outcome -- whether the session
	// was resumed, the authentication method, the handshake time, the trace
	// context sent -- or nil when the handshake did not complete or there was
	// no security config.
	Negotiation *security.SecurityNegotiation

	// BytesSent and BytesReceived count the bytes exchanged over the last
	// connection, from the handshake to Close.
	BytesSent     uint64
	BytesReceived uint64
}

TraceResult is what a traced command did, passed to the function ClientConfig.TraceCommand returned.

type TracedCommand added in v0.7.19

type TracedCommand struct {
	// Command is the command the handshake carries (SecurityConfig.Command),
	// or security.NoCommand for no security config.
	Command int
	// Address is ClientConfig.Address.
	Address string
}

TracedCommand describes a command ConnectAndAuthenticateWithConfig is about to send, for ClientConfig.TraceCommand.

Directories

Path Synopsis
Package sharedport provides client functionality for HTCondor's shared port protocol.
Package sharedport provides client functionality for HTCondor's shared port protocol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL