Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the rest of pkg/autoupdate #1679

Merged
merged 15 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading