Documentation
¶
Overview ¶
Package eol resolves the end-of-support dates of host operating systems.
Index ¶
- Constants
- Variables
- func CountStates(hosts []HostSupport) map[string]int
- func HostJSON(h HostSupport) map[string]any
- func Match(id, versionID string) (product, cycle string, ok bool)
- func OSJSON(identity Identity, reportedAt *time.Time, support Support) map[string]any
- func Validate(t Table) error
- type AgentStore
- type Cycle
- type Date
- type Deps
- type Fetcher
- type HostSupport
- type Identity
- type Service
- func (s *Service) Current() Table
- func (s *Service) EvaluateAgent(ctx context.Context, agentID string) error
- func (s *Service) EvaluateAll(ctx context.Context) error
- func (s *Service) HandleAgentHostOS(ctx context.Context, agentID string, ev *agentpb.HostOSMsg) error
- func (s *Service) HostSupports(ctx context.Context) ([]HostSupport, error)
- func (s *Service) Refresh(ctx context.Context) error
- func (s *Service) RefreshLocalOS(ctx context.Context) error
- func (s *Service) SeedSeverities(active []alert.Alert)
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Status() TableStatus
- type Support
- type SupportState
- type Table
- type TableStatus
Constants ¶
const ( SourceEmbedded = "embedded" SourceRemote = "endoflife.date" )
const AlertType = "os_eol"
AlertType is the alert type every host end-of-support alert carries.
const ReasonAgentTooOld = "agent_too_old"
ReasonAgentTooOld marks an agent that never reported its operating system.
const WarningDays = 30
WarningDays is how many days before the end of security support the warning starts.
Variables ¶
var Products = []string{"debian", "ubuntu", "rhel", "rocky-linux", "almalinux", "alpine-linux", "sles"}
Products lists the endoflife.date slugs the table covers.
Functions ¶
func CountStates ¶
func CountStates(hosts []HostSupport) map[string]int
CountStates counts hosts per state, security_only folded into supported.
func HostJSON ¶
func HostJSON(h HostSupport) map[string]any
HostJSON renders one host of HostSupports, without its connection state.
Types ¶
type AgentStore ¶
type AgentStore interface {
ListAgentsForEOL(ctx context.Context) ([]agent.Agent, error)
UpdateAgentOS(ctx context.Context, agentID string, os agent.OSIdentity, reportedAt time.Time) (bool, error)
}
AgentStore reads the agents to evaluate and writes the server's own identity.
type Cycle ¶
type Cycle struct {
Name string `json:"name"`
LTS bool `json:"lts"`
ActiveUntil *Date `json:"active_until,omitempty"`
SecurityUntil Date `json:"security_until"`
ExtendedUntil *Date `json:"extended_until,omitempty"`
}
Cycle is one release line of a product, with the dates its support ends.
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date is a calendar day, without time or zone.
func (Date) DaysUntil ¶
DaysUntil returns the whole days from today to d, negative once d has passed.
func (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
type Deps ¶
type Deps struct {
Store AgentStore
Fetcher *Fetcher
Emit func(alert.Event)
OnChanged func(ctx context.Context, agentID string)
ReadLocalOS func() hoststat.OSRelease
Now func() time.Time
Logger *slog.Logger
}
Deps carries what the service needs; a nil Fetcher disables the refresh.
type HostSupport ¶
type HostSupport struct {
AgentID string
Hostname string
Label string
IsLocal bool
Runtime string
Identity Identity
Support Support
ReportedAt *time.Time
LastSeenAt *time.Time
}
HostSupport is the support state of one host, as served to the interface.
type Identity ¶
type Identity struct {
ID string `json:"id"`
VersionID string `json:"version_id"`
PrettyName string `json:"pretty_name"`
Source string `json:"source"`
}
Identity is the operating system an agent reports, as reported.
func IdentityOf ¶
IdentityOf reads the operating system an agent reported, flagging as agent_too_old any agent but the sentinel that never reported one.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service evaluates host operating systems against the support table and keeps that table fresh.
func (*Service) EvaluateAgent ¶
EvaluateAgent re-evaluates a single host.
func (*Service) EvaluateAll ¶
EvaluateAll re-evaluates every active host and resolves the hosts that left the fleet.
func (*Service) HandleAgentHostOS ¶
func (s *Service) HandleAgentHostOS(ctx context.Context, agentID string, ev *agentpb.HostOSMsg) error
HandleAgentHostOS stores the operating system an agent reports for its host and, when it differs from the one already stored, re-evaluates that host.
func (*Service) HostSupports ¶
func (s *Service) HostSupports(ctx context.Context) ([]HostSupport, error)
HostSupports returns the support state of every active host, worst first.
func (*Service) Refresh ¶
Refresh downloads the support cycles and replaces the table in one go; on failure the current table stands.
func (*Service) RefreshLocalOS ¶
RefreshLocalOS re-reads the server's own os-release and stores it under the local sentinel.
func (*Service) SeedSeverities ¶
SeedSeverities restores the last emitted severity per host from the active alerts.
func (*Service) Start ¶
Start refreshes the table, re-reads the server's own os-release and evaluates every host, daily.
func (*Service) Status ¶
func (s *Service) Status() TableStatus
Status reports where the support table comes from and how the last refresh went.
type Support ¶
type Support struct {
State SupportState `json:"state"`
Product string `json:"product"`
Cycle string `json:"cycle"`
ActiveUntil *Date `json:"active_until"`
SecurityUntil *Date `json:"security_until"`
ExtendedUntil *Date `json:"extended_until"`
DaysRemaining *int `json:"days_remaining"`
TableSource string `json:"table_source"`
}
Support is the evaluated support state of one host.
type SupportState ¶
type SupportState string
SupportState is where a host stands in its operating system support cycle.
const ( StateUnknown SupportState = "unknown" StateUntracked SupportState = "untracked" StateSupported SupportState = "supported" StateSecurityOnly SupportState = "security_only" StateEndingSoon SupportState = "ending_soon" StateEnded SupportState = "ended" )