Skip to content

Commit

Permalink
fix: daemon version bugs (#120)
Browse files Browse the repository at this point in the history
Fixes a bug where the daemon nix file path is incorrect causing errors
when reading and updating the version. Also fixed the server to properly
respond to the error returned by the daemon when this occurred. And
finally, fixed a bad comparison which was pointer compare instead of
attribute compare.
  • Loading branch information
jgkawell authored Dec 3, 2024
1 parent 70a5de1 commit 76a9371
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion services/platform/daemon/host/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NixosVarsFile() string {
}

func DaemonNixFile() string {
return FilePath(NixosRoot, "daemon/default.nix")
return FilePath(NixosRoot, "home-cloud/daemon/default.nix")
}

func NixosConfigsPath() string {
Expand Down
9 changes: 8 additions & 1 deletion services/platform/server/system/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func (c *controller) CheckForOSUpdates(ctx context.Context, logger chassis.Logge
// get the current daemon version from the daemon
listener = async.RegisterListener(ctx, c.broadcaster, &async.ListenerOptions[*dv1.CurrentDaemonVersion]{
Callback: func(event *dv1.CurrentDaemonVersion) (bool, error) {
if event.Error != nil {
logger.WithError(fmt.Errorf(event.Error.Error)).Error("failed to get current daemon version")
return true, fmt.Errorf(event.Error.Error)
}
response.DaemonVersions = &v1.DaemonVersions{
Current: &v1.DaemonVersion{
Version: event.Version,
Expand Down Expand Up @@ -149,7 +153,10 @@ func (u *controller) UpdateOS(ctx context.Context, logger chassis.Logger) error

// if the daemon needs updating, install it along with the os updates
// otherwise just install the os update
if updates.DaemonVersions.Current != updates.DaemonVersions.Latest {
if updates.DaemonVersions.Current.Version != updates.DaemonVersions.Latest.Version &&
updates.DaemonVersions.Current.SrcHash != updates.DaemonVersions.Latest.SrcHash &&
updates.DaemonVersions.Current.VendorHash != updates.DaemonVersions.Latest.VendorHash {
logger.Info("updating daemon along with os")
err = com.Send(&dv1.ServerMessage{
Message: &dv1.ServerMessage_ChangeDaemonVersionCommand{
ChangeDaemonVersionCommand: &dv1.ChangeDaemonVersionCommand{
Expand Down

0 comments on commit 76a9371

Please sign in to comment.