Documentation
¶
Overview ¶
Package sessionrecord records the hub's proxy sessions durably (Task 20383): the git proxy's lease-path and workspace sessions, the Kubernetes monitor's sessions and every run's egress session, in statedb's proxy_sessions (migrations/0058_proxy_sessions.sql), so the hub process that adopts a run after the one serving it stops can restore them; and the CI relay's sessions, in ci_sessions (migrations/0060_ci_sessions.sql, Task 20390), so the hub process that receives a job's next call after the one serving it stops can restore the job's session.
It is the seam between three registries that must not know about the database — pkg/gitproxy, pkg/kubeguard, pkg/egressbroker each define a SessionStore — and the table. Each store writes as the hub process its Holder names, the cluster member id the run's lease is recorded under, and every write after the insert is fenced on it: a session another process took over with its run is that process's to extend, checkpoint and close.
What goes in a row is what the registries keep in memory instead of a credential: the SHA-256 of the token a sandbox presents, and the scope the session enforces. The record types it is handed have no field a credential could travel in, and tests/security scans the table after a realistic run for anything that did.
Index ¶
- Variables
- func EgressCounters(row statedb.ProxySessionRow) egressbroker.SessionCounters
- func EgressRecord(row statedb.ProxySessionRow) (egressbroker.SessionRecord, error)
- func GitRecord(row statedb.ProxySessionRow) (gitproxy.SessionRecord, error)
- func KubeRecord(row statedb.ProxySessionRow) (kubeguard.SessionRecord, error)
- type CIProvenance
- type CIStore
- type EgressScope
- type EgressStore
- func (e EgressStore) CheckpointSession(id string, c egressbroker.SessionCounters) error
- func (e EgressStore) CloseSession(id, reason string, at time.Time, c egressbroker.SessionCounters) error
- func (e EgressStore) ExtendSession(id string, expiresAt time.Time) error
- func (e EgressStore) SaveSession(rec egressbroker.SessionRecord) error
- type GitScope
- type GitStore
- type KubeScope
- type KubeStore
Constants ¶
This section is empty.
Variables ¶
var ErrNoHolder = errors.New("this hub process has no cluster member id to record sessions under")
ErrNoHolder: the process has no cluster member id to record a session under, so nothing could take it over.
Functions ¶
func EgressCounters ¶
func EgressCounters(row statedb.ProxySessionRow) egressbroker.SessionCounters
EgressCounters decodes an egress row's counters, zero when they do not parse.
func EgressRecord ¶
func EgressRecord(row statedb.ProxySessionRow) (egressbroker.SessionRecord, error)
EgressRecord reads a row back into what egressbroker.Broker.RestoreSession takes.
func GitRecord ¶
func GitRecord(row statedb.ProxySessionRow) (gitproxy.SessionRecord, error)
GitRecord reads a row back into what gitproxy.Registry.Restore takes.
func KubeRecord ¶
func KubeRecord(row statedb.ProxySessionRow) (kubeguard.SessionRecord, error)
KubeRecord reads a row back into what kubeguard.Registry.Restore takes.
Types ¶
type CIProvenance ¶
type CIProvenance struct {
RuleName string `json:"rule_name,omitempty"`
Project string `json:"project,omitempty"`
Subject string `json:"subject,omitempty"`
Repository string `json:"repository,omitempty"`
Ref string `json:"ref,omitempty"`
Workflow string `json:"workflow,omitempty"`
Actor string `json:"actor,omitempty"`
RunID string `json:"run_id,omitempty"`
RunURL string `json:"run_url,omitempty"`
Claims json.RawMessage `json:"claims,omitempty"`
}
CIProvenance is a CI relay session's provenance_json (Task 20390): which pipeline its rule admitted. Claims is the verified payload of the OIDC token the session was minted for — the job's identity, not a credential: the token's signature is not kept, so nothing here can be exchanged again.
func CIRecord ¶
func CIRecord(row statedb.CISessionRow) (claudeproxy.SessionRecord, CIProvenance, error)
CIRecord reads a row back into what claudeproxy.Registry.Restore takes, and its provenance.
type CIStore ¶
type CIStore struct {
// contains filtered or unexported fields
}
CIStore is a claudeproxy.SessionStore over the control plane's database, recording CI relay sessions in ci_sessions (Task 20390). Its writes after the insert are fenced on the holder, like the other stores'.
func NewCIStore ¶
func NewCIStore(db *statedb.DB, holder func() string, instance string, onError func(kind, id, what string, err error)) CIStore
NewCIStore returns a store writing as holder, for the hub instance named instance.
func (CIStore) CheckpointSession ¶
CheckpointSession implements claudeproxy.SessionStore. A checkpoint that lands on no row is an error, so the registry writes it again next time rather than believing the record holds it.
func (CIStore) CloseSession ¶
CloseSession implements claudeproxy.SessionStore.
func (CIStore) SaveSession ¶
func (c CIStore) SaveSession(rec claudeproxy.SessionRecord) error
SaveSession implements claudeproxy.SessionStore.
type EgressScope ¶
type EgressScope struct {
Grant egressbroker.Grant `json:"grant"`
Labels map[string]string `json:"labels,omitempty"`
}
EgressScope is an egress session's scope_json.
type EgressStore ¶
type EgressStore struct {
// contains filtered or unexported fields
}
EgressStore is an egressbroker.SessionStore over the control plane's database.
func NewEgressStore ¶
func NewEgressStore(db *statedb.DB, holder func() string, onError func(kind, id, what string, err error)) EgressStore
NewEgressStore returns a store writing as holder.
func (EgressStore) CheckpointSession ¶
func (e EgressStore) CheckpointSession(id string, c egressbroker.SessionCounters) error
CheckpointSession implements egressbroker.SessionStore. A checkpoint that lands on no row is an error, so the broker writes it again next time rather than believing the record holds it.
func (EgressStore) CloseSession ¶
func (e EgressStore) CloseSession(id, reason string, at time.Time, c egressbroker.SessionCounters) error
CloseSession implements egressbroker.SessionStore.
func (EgressStore) ExtendSession ¶
func (e EgressStore) ExtendSession(id string, expiresAt time.Time) error
ExtendSession implements egressbroker.SessionStore.
func (EgressStore) SaveSession ¶
func (e EgressStore) SaveSession(rec egressbroker.SessionRecord) error
SaveSession implements egressbroker.SessionStore.
type GitScope ¶
type GitScope struct {
RepoPath string `json:"repo_path,omitempty"`
RepoPatterns []string `json:"repo_patterns,omitempty"`
Upstream string `json:"upstream"`
Policy gitproxy.Policy `json:"policy"`
}
GitScope is a git session's scope_json.
func GitScopeOf ¶
func GitScopeOf(row statedb.ProxySessionRow) (GitScope, error)
GitScopeOf decodes a git row's scope.
type GitStore ¶
type GitStore struct {
// contains filtered or unexported fields
}
GitStore is a gitproxy.SessionStore over the control plane's database.
func NewGitStore ¶
func NewGitStore(db *statedb.DB, holder func() string, onError func(kind, id, what string, err error)) GitStore
NewGitStore returns a store writing as holder.
func (GitStore) CloseSession ¶
CloseSession implements gitproxy.SessionStore.
func (GitStore) SaveSession ¶
func (g GitStore) SaveSession(rec gitproxy.SessionRecord) error
SaveSession implements gitproxy.SessionStore.
type KubeScope ¶
type KubeScope struct {
ClusterURL string `json:"cluster_url"`
Context string `json:"context,omitempty"`
Policy kubeguard.Policy `json:"policy"`
}
KubeScope is a Kubernetes monitor session's scope_json.
func KubeScopeOf ¶
func KubeScopeOf(row statedb.ProxySessionRow) (KubeScope, error)
KubeScopeOf decodes a kube row's scope.
type KubeStore ¶
type KubeStore struct {
// contains filtered or unexported fields
}
KubeStore is a kubeguard.SessionStore over the control plane's database.
func NewKubeStore ¶
func NewKubeStore(db *statedb.DB, holder func() string, onError func(kind, id, what string, err error)) KubeStore
NewKubeStore returns a store writing as holder.
func (KubeStore) CloseSession ¶
CloseSession implements kubeguard.SessionStore.
func (KubeStore) SaveSession ¶
func (k KubeStore) SaveSession(rec kubeguard.SessionRecord) error
SaveSession implements kubeguard.SessionStore.