fix(archieui): the Versions card compares against the running daemon, so an available update can be installed
This commit is contained in:
4 files changed
+44
-34
No files matched your search
@@ -9,13 +9,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
configtemplate "github.com/samcharles93/archie-core"
|
configtemplate "github.com/samcharles93/archie-core"
|
||||||
|
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||||
"github.com/samcharles93/archie-core/internal/buildinfo"
|
"github.com/samcharles93/archie-core/internal/buildinfo"
|
||||||
"github.com/samcharles93/archie-core/internal/channels/telegram"
|
"github.com/samcharles93/archie-core/internal/channels/telegram"
|
||||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
|
||||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
|
||||||
"github.com/samcharles93/archie-core/internal/releaseannounce"
|
"github.com/samcharles93/archie-core/internal/releaseannounce"
|
||||||
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
|
||||||
"github.com/samcharles93/archie-core/internal/secret"
|
"github.com/samcharles93/archie-core/internal/secret"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,7 +23,7 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon
|
|||||||
g.Version = gatewayVersionReporter(ctx, d.Chat, cfg.Options.DependencyTimeout)
|
g.Version = gatewayVersionReporter(ctx, d.Chat, cfg.Options.DependencyTimeout)
|
||||||
g.SetShowToolCalls(cfg.ShowToolCalls)
|
g.SetShowToolCalls(cfg.ShowToolCalls)
|
||||||
g.Reload = telegramReloader(cfg.Options, d.Secrets, d.Log)
|
g.Reload = telegramReloader(cfg.Options, d.Secrets, d.Log)
|
||||||
g.RunningVersions = runningVersions(ctx, d.Presence, cfg.Options.DependencyTimeout)
|
g.RunningVersions = servicekit.RunningVersions(ctx, d.Presence, cfg.Options.DependencyTimeout)
|
||||||
|
|
||||||
if d.Updates != nil {
|
if d.Updates != nil {
|
||||||
g.Updates = d.Updates
|
g.Updates = d.Updates
|
||||||
@@ -41,34 +39,6 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// runningVersions reports the daemon version archied's own presence record
|
|
||||||
// carries, so an update report is checked against what archied compiled in
|
|
||||||
// rather than this process's build. A down or unreachable daemon, or a
|
|
||||||
// missing store, leaves the daemon unverified. The agent stays unverified:
|
|
||||||
// only archied observes it.
|
|
||||||
func runningVersions(ctx context.Context, store storecontract.PresenceStore, timeout time.Duration) func() map[string]string {
|
|
||||||
return func() map[string]string {
|
|
||||||
if store == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if timeout <= 0 {
|
|
||||||
timeout = 5 * time.Second
|
|
||||||
}
|
|
||||||
callCtx, cancel := context.WithTimeout(ctx, timeout)
|
|
||||||
defer cancel()
|
|
||||||
records, err := store.ListPresence(callCtx)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
for _, service := range presence.Mesh(records, time.Now()) {
|
|
||||||
if service.Service == presence.Daemon && service.State != presence.StateDown {
|
|
||||||
return map[string]string{releaseupdate.ComponentDaemon: service.Version}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// gatewayVersionReporter renders /version from the Gateway's build info,
|
// gatewayVersionReporter renders /version from the Gateway's build info,
|
||||||
// fetched per call with a timeout.
|
// fetched per call with a timeout.
|
||||||
func gatewayVersionReporter(ctx context.Context, chat messaging.ChatContract, timeout time.Duration) func() string {
|
func gatewayVersionReporter(ctx context.Context, chat messaging.ChatContract, timeout time.Duration) func() string {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||||
"github.com/samcharles93/archie-core/internal/domain/access"
|
"github.com/samcharles93/archie-core/internal/domain/access"
|
||||||
"github.com/samcharles93/archie-core/internal/domain/health"
|
"github.com/samcharles93/archie-core/internal/domain/health"
|
||||||
@@ -50,7 +51,7 @@ type deps struct {
|
|||||||
|
|
||||||
// compose builds the dashboard server from contract-backed dependencies.
|
// compose builds the dashboard server from contract-backed dependencies.
|
||||||
// Unset fields answer 501/503 or empty.
|
// Unset fields answer 501/503 or empty.
|
||||||
func compose(d deps) *webui.Server {
|
func compose(ctx context.Context, d deps) *webui.Server {
|
||||||
srv := &webui.Server{
|
srv := &webui.Server{
|
||||||
Store: d.Store,
|
Store: d.Store,
|
||||||
Log: d.Log,
|
Log: d.Log,
|
||||||
@@ -90,6 +91,7 @@ func compose(d deps) *webui.Server {
|
|||||||
wireOrgSurface(srv, d.Store)
|
wireOrgSurface(srv, d.Store)
|
||||||
if presence, ok := d.Store.(storecontract.PresenceStore); ok {
|
if presence, ok := d.Store.(storecontract.PresenceStore); ok {
|
||||||
srv.Presence = presence
|
srv.Presence = presence
|
||||||
|
srv.RunningVersions = servicekit.RunningVersions(ctx, presence, 0)
|
||||||
}
|
}
|
||||||
if applyStatus, ok := d.Store.(storecontract.ApplyStatusStore); ok {
|
if applyStatus, ok := d.Store.(storecontract.ApplyStatusStore); ok {
|
||||||
srv.ApplyStatus = applyStatus
|
srv.ApplyStatus = applyStatus
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ func Run(ctx context.Context, options Options) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
srv := compose(deps{
|
srv := compose(ctx, deps{
|
||||||
Options: opts,
|
Options: opts,
|
||||||
Log: log,
|
Log: log,
|
||||||
Store: tasks,
|
Store: tasks,
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package servicekit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||||
|
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||||
|
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RunningVersions reports the daemon version archied's own presence record
|
||||||
|
// carries, so an update report is checked against what archied compiled in
|
||||||
|
// rather than this process's build. A down or unreachable daemon, or a
|
||||||
|
// missing store, leaves the daemon unverified. The agent stays unverified:
|
||||||
|
// only archied observes it.
|
||||||
|
func RunningVersions(ctx context.Context, store storecontract.PresenceStore, timeout time.Duration) func() map[string]string {
|
||||||
|
return func() map[string]string {
|
||||||
|
if store == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if timeout <= 0 {
|
||||||
|
timeout = 5 * time.Second
|
||||||
|
}
|
||||||
|
callCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
|
defer cancel()
|
||||||
|
records, err := store.ListPresence(callCtx)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for _, service := range presence.Mesh(records, time.Now()) {
|
||||||
|
if service.Service == presence.Daemon && service.State != presence.StateDown {
|
||||||
|
return map[string]string{releaseupdate.ComponentDaemon: service.Version}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user