Skip to content

Commit

Permalink
Remove the rest of pkg/autoupdate (#1679)
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany authored May 28, 2024
1 parent 6d5be3c commit b70b79b
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 979 deletions.
5 changes: 2 additions & 3 deletions cmd/launcher/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/kolide/launcher/ee/agent/knapsack"
"github.com/kolide/launcher/ee/agent/storage/inmemory"
"github.com/kolide/launcher/ee/tuf"
"github.com/kolide/launcher/pkg/autoupdate"
"github.com/kolide/launcher/pkg/launcher"
"github.com/kolide/launcher/pkg/log/multislogger"
"github.com/kolide/launcher/pkg/osquery/interactive"
Expand Down Expand Up @@ -50,8 +49,8 @@ func runInteractive(systemMultiSlogger *multislogger.MultiSlogger, args []string
if opts.OsquerydPath == "" {
return errors.New("could not find osqueryd binary")
}
// Fall back to old autoupdate library
opts.OsquerydPath = autoupdate.FindNewest(context.Background(), opts.OsquerydPath)

return fmt.Errorf("finding osqueryd binary: %w", err)
} else {
opts.OsquerydPath = latestOsquerydBinary.Path
}
Expand Down
1 change: 0 additions & 1 deletion cmd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ func runLauncher(ctx context.Context, cancel func(), multiSlogger, systemMultiSl
osqueryRunner := osqueryruntime.New(
k,
osqueryruntime.WithKnapsack(k),
osqueryruntime.WithOsquerydBinary(k.OsquerydPath()),
osqueryruntime.WithRootDirectory(k.RootDirectory()),
osqueryruntime.WithOsqueryExtensionPlugins(table.LauncherTables(k)...),
osqueryruntime.WithSlogger(k.Slogger().With("component", "osquery_instance")),
Expand Down
14 changes: 2 additions & 12 deletions cmd/launcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/kolide/kit/logutil"
"github.com/kolide/kit/version"
"github.com/kolide/launcher/ee/tuf"
"github.com/kolide/launcher/pkg/autoupdate"
"github.com/kolide/launcher/pkg/contexts/ctxlog"
"github.com/kolide/launcher/pkg/execwrapper"
"github.com/kolide/launcher/pkg/launcher"
Expand Down Expand Up @@ -203,19 +202,10 @@ func runNewerLauncherIfAvailable(ctx context.Context, slogger *slog.Logger) erro
newerBinary, err := latestLauncherPath(ctx, slogger)
if err != nil {
slogger.Log(ctx, slog.LevelError,
"could not check out latest launcher, will fall back to old autoupdate library",
"could not check out latest launcher",
"err", err,
)

// Fall back to legacy autoupdate library
newerBinary, err = autoupdate.FindNewestSelf(ctx)
if err != nil {
slogger.Log(ctx, slog.LevelError,
"could not check out latest launcher from legacy autoupdate library",
"err", err,
)
return nil
}
return nil
}

if newerBinary == "" {
Expand Down
15 changes: 0 additions & 15 deletions cmd/launcher/svc_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/kolide/kit/logutil"
"github.com/kolide/kit/version"
"github.com/kolide/launcher/ee/gowrapper"
"github.com/kolide/launcher/pkg/autoupdate"
"github.com/kolide/launcher/pkg/contexts/ctxlog"
"github.com/kolide/launcher/pkg/launcher"
"github.com/kolide/launcher/pkg/log/locallogger"
Expand Down Expand Up @@ -66,20 +65,6 @@ func runWindowsSvc(systemSlogger *multislogger.MultiSlogger, args []string) erro
systemSlogger.AddHandler(localSloggerHandler)
}

// Use the FindNewest mechanism to delete old
// updates. We do this here, as windows will pick up
// the update in main, which does not delete. Note
// that this will likely produce non-fatal errors when
// it tries to delete the running one.
go func() {
time.Sleep(15 * time.Second)
_ = autoupdate.FindNewest(
context.TODO(),
os.Args[0],
autoupdate.DeleteOldUpdates(),
)
}()

// Confirm that service configuration is up-to-date
checkServiceConfiguration(systemSlogger.Logger, opts)

Expand Down
3 changes: 1 addition & 2 deletions ee/agent/knapsack/knapsack.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/kolide/launcher/ee/agent/storage"
"github.com/kolide/launcher/ee/agent/types"
"github.com/kolide/launcher/ee/tuf"
"github.com/kolide/launcher/pkg/autoupdate"
"github.com/kolide/launcher/pkg/log/multislogger"
"go.etcd.io/bbolt"
)
Expand Down Expand Up @@ -149,7 +148,7 @@ func (k *knapsack) getKVStore(storeType storage.Store) types.KVStore {
func (k *knapsack) LatestOsquerydPath(ctx context.Context) string {
latestBin, err := tuf.CheckOutLatest(ctx, "osqueryd", k.RootDirectory(), k.UpdateDirectory(), k.PinnedOsquerydVersion(), k.UpdateChannel(), k.Slogger())
if err != nil {
return autoupdate.FindNewest(ctx, k.OsquerydPath())
return k.OsquerydPath()
}

return latestBin.Path
Expand Down
Loading

0 comments on commit b70b79b

Please sign in to comment.