Documentation
¶
Overview ¶
Package logclient reads container logs from the platform's central log service.
A sandbox's Pod holds its logs only while it exists. Once the sandbox is released the Pod is recycled and the Kubernetes log API has nothing left to return — but the lines were shipped to the central service, which is where anyone asking "what did that run print" has to be sent. The dashboard has queried it since the log integration landed; this is the same query from the worker, so the API can answer for a sandbox that has already ended.
Every failure here looks the same ¶
The service answers a query that matches nothing with 200 and an empty body. So "that pod printed nothing", "this cluster is not scoped into the query", "the wrong log store was asked" and "this cluster ships no container output at all" are one indistinguishable outcome. Nothing in this package can tell them apart, which is why QueryOptions.Scope exists: callers report what they asked alongside what came back, and someone reading the result can see which of the four it was.
Index ¶
Constants ¶
const ( // TenantNamespacePrefix marks a namespace as belonging to a tenant. TenantNamespacePrefix = "t-" // TenantProject holds tenant namespaces' output on a sharded deployment. TenantProject = "default" // PlatformProject holds everything else on a sharded deployment. PlatformProject = "internal" )
Log-store sharding, for deployments whose central service splits container output across more than one store.
Where it is in use, the split is by namespace: tenant workloads land in one store and everything else — platform components, system namespaces — in another. Which clusters do this is deployment configuration (ClusterEntry.Logs.SplitProject), because a cluster that does not shard will return an empty result for the store it does not use, with a 200 and no error to say so.
Variables ¶
This section is empty.
Functions ¶
func CloneFilters ¶
CloneFilters returns a copy safe to hand to a query.
func ProjectFor ¶ added in v0.0.11
ProjectFor picks the log store to query for one namespace.
Returns the empty string when the cluster is not sharded, which leaves the endpoint's own `project` (or Config.Project) in force — the single-store case, and the one every cluster looked like before sharding existed.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client queries the central log service.
func New ¶
New returns a Client. An empty URL or Token leaves it unconfigured; callers must check Ready.
func (*Client) DefaultProject ¶ added in v0.0.11
DefaultProject returns the log store used when a query names none. Callers report it alongside an empty result, which is otherwise indistinguishable from having asked the wrong store.
type Config ¶
type Config struct {
// URL is the download endpoint, e.g.
// https://op.example.com/api/v1/rms/logging/download
URL string
// AppID selects the authentication scheme: set it for the signed scheme
// (Signature/AppID/Timestamp/Randstr), leave it empty for Bearer.
AppID string
// Token is the signing token, or the bearer token when AppID is empty.
Token string
// Project scopes the query on gateways that require it; empty omits it.
Project string
// Timeout bounds one query.
Timeout time.Duration
}
Config addresses the central log service.
type QueryOptions ¶ added in v0.0.11
type QueryOptions struct {
// PodName is the pod whose output is wanted.
PodName string
// Filters scope the query to one cluster (region / cluster labels). They are
// not optional in practice: pod names are unique per cluster, not globally,
// so an unscoped query can return another cluster's output for the same name.
Filters map[string]string
// Container narrows the query to one container of the Pod. Empty returns
// every container the collector shipped — which for a sandbox Pod means the
// egress proxy's per-connection lines mixed in with the sandbox's own.
Container string
// Project overrides the configured log store for this query. Empty uses
// Config.Project. A deployment that shards its store by namespace needs a
// different value per query, not per process — see ProjectFor.
Project string
// Start and End bound the query window.
Start, End time.Time
// Limit caps the returned entries; 0 means no cap.
Limit int
}
QueryOptions addresses one central-log query.
func (QueryOptions) Scope ¶ added in v0.0.11
func (o QueryOptions) Scope(defaultProject string) string
Scope describes, in one line, what a query actually asked for.
A query that matches nothing returns 200 with an empty body, so "no rows" and "you asked the wrong question" are indistinguishable at the transport. The caller has to be able to show what it asked, or every empty result turns into the same unanswerable ticket.