eol

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package eol resolves the end-of-support dates of host operating systems.

Index

Constants

View Source
const (
	SourceEmbedded = "embedded"
	SourceRemote   = "endoflife.date"
)
View Source
const AlertType = "os_eol"

AlertType is the alert type every host end-of-support alert carries.

View Source
const ReasonAgentTooOld = "agent_too_old"

ReasonAgentTooOld marks an agent that never reported its operating system.

View Source
const WarningDays = 30

WarningDays is how many days before the end of security support the warning starts.

Variables

View Source
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.

func Match

func Match(id, versionID string) (product, cycle string, ok bool)

Match maps an os-release ID and VERSION_ID onto a product slug and a support cycle.

func OSJSON

func OSJSON(identity Identity, reportedAt *time.Time, support Support) map[string]any

OSJSON renders the operating system block the agents and updates APIs both serve.

func Validate

func Validate(t Table) error

Validate checks that a table covers every product and that its dates are ordered.

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 NewDate

func NewDate(year int, month time.Month, day int) Date

NewDate builds a Date from its calendar components.

func ParseDate

func ParseDate(s string) (Date, error)

ParseDate reads a YYYY-MM-DD day.

func (Date) After

func (d Date) After(other Date) bool

After reports whether d is a later day than other.

func (Date) DaysUntil

func (d Date) DaysUntil(today time.Time) int

DaysUntil returns the whole days from today to d, negative once d has passed.

func (Date) IsZero

func (d Date) IsZero() bool

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

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 Fetcher

type Fetcher struct {
	BaseURL   string
	Client    *http.Client
	UserAgent string
	Now       func() time.Time
}

Fetcher downloads the support cycles from the endoflife.date API.

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context) (Table, error)

Fetch downloads every tracked product; a single failure yields no table at all.

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"`
	UnavailableReason string `json:"unavailable_reason"`
}

Identity is the operating system an agent reports, as reported.

func IdentityOf

func IdentityOf(a agent.Agent) Identity

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 New

func New(deps Deps) (*Service, error)

New builds a service over the embedded support table.

func (*Service) Current

func (s *Service) Current() Table

Current returns the support table in use.

func (*Service) EvaluateAgent

func (s *Service) EvaluateAgent(ctx context.Context, agentID string) error

EvaluateAgent re-evaluates a single host.

func (*Service) EvaluateAll

func (s *Service) EvaluateAll(ctx context.Context) error

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

func (s *Service) Refresh(ctx context.Context) error

Refresh downloads the support cycles and replaces the table in one go; on failure the current table stands.

func (*Service) RefreshLocalOS

func (s *Service) RefreshLocalOS(ctx context.Context) error

RefreshLocalOS re-reads the server's own os-release and stores it under the local sentinel.

func (*Service) SeedSeverities

func (s *Service) SeedSeverities(active []alert.Alert)

SeedSeverities restores the last emitted severity per host from the active alerts.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

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.

func Evaluate

func Evaluate(identity Identity, table Table, today time.Time) Support

Evaluate resolves the support state of an identity against a table on a given day.

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"
)

type Table

type Table struct {
	Source    string             `json:"source"`
	FetchedAt time.Time          `json:"fetched_at"`
	Products  map[string][]Cycle `json:"products"`
}

Table holds the support cycles of every tracked product.

func LoadEmbedded

func LoadEmbedded() (Table, error)

LoadEmbedded reads the table shipped with the binary.

func (Table) Cycle

func (t Table) Cycle(product, name string) (Cycle, bool)

Cycle returns the cycle of a product by name.

type TableStatus

type TableStatus struct {
	Source           string    `json:"source"`
	FetchedAt        time.Time `json:"fetched_at"`
	RefreshEnabled   bool      `json:"refresh_enabled"`
	LastRefreshError string    `json:"last_refresh_error"`
}

TableStatus describes the support table currently in use.

Jump to

Keyboard shortcuts

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