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

[Ingest Manager] Always try snapshot repo for agent upgrade #21951

Merged
merged 4 commits into from
Oct 20, 2020
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
4 changes: 2 additions & 2 deletions x-pack/elastic-agent/pkg/agent/application/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func streamFactory(ctx context.Context, cfg *configuration.SettingsConfig, srv *
}

func newOperator(ctx context.Context, log *logger.Logger, id routingKey, config *configuration.SettingsConfig, srv *server.Server, r state.Reporter, m monitoring.Monitor) (*operation.Operator, error) {
fetcher := downloader.NewDownloader(log, config.DownloadConfig)
fetcher := downloader.NewDownloader(log, config.DownloadConfig, false)
allowEmptyPgp, pgp := release.PGP()
verifier, err := downloader.NewVerifier(log, config.DownloadConfig, allowEmptyPgp, pgp)
verifier, err := downloader.NewVerifier(log, config.DownloadConfig, allowEmptyPgp, pgp, false)
if err != nil {
return nil, errors.New(err, "initiating verifier")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ func (u *Upgrader) downloadArtifact(ctx context.Context, version, sourceURI stri
}

allowEmptyPgp, pgp := release.PGP()
verifier, err := downloader.NewVerifier(u.log, &settings, allowEmptyPgp, pgp)
verifier, err := downloader.NewVerifier(u.log, &settings, allowEmptyPgp, pgp, true)
if err != nil {
return "", errors.New(err, "initiating verifier")
}

fetcher := downloader.NewDownloader(u.log, &settings)
fetcher := downloader.NewDownloader(u.log, &settings, true)
path, err := fetcher.Download(ctx, agentName, agentArtifactName, version)
if err != nil {
return "", errors.New(err, "failed upgrade of agent binary")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ func (u *Upgrader) Ack(ctx context.Context) error {
}

func (u *Upgrader) sourceURI(version, retrievedURI string) (string, error) {
if strings.HasSuffix(version, "-SNAPSHOT") && retrievedURI == "" {
return "", errors.New("snapshot upgrade requires source uri", errors.TypeConfig)
}
if retrievedURI != "" {
return retrievedURI, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (

// NewDownloader creates a downloader which first checks local directory
// and then fallbacks to remote if configured.
func NewDownloader(log *logger.Logger, config *artifact.Config) download.Downloader {
func NewDownloader(log *logger.Logger, config *artifact.Config, forceSnapshot bool) download.Downloader {
downloaders := make([]download.Downloader, 0, 3)
downloaders = append(downloaders, fs.NewDownloader(config))

// try snapshot repo before official
if release.Snapshot() {
if release.Snapshot() || forceSnapshot {
snapDownloader, err := snapshot.NewDownloader(config)
if err != nil {
log.Error(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// NewVerifier creates a downloader which first checks local directory
// and then fallbacks to remote if configured.
func NewVerifier(log *logger.Logger, config *artifact.Config, allowEmptyPgp bool, pgp []byte) (download.Verifier, error) {
func NewVerifier(log *logger.Logger, config *artifact.Config, allowEmptyPgp bool, pgp []byte, forceSnapshot bool) (download.Verifier, error) {
verifiers := make([]download.Verifier, 0, 3)

fsVer, err := fs.NewVerifier(config, allowEmptyPgp, pgp)
Expand All @@ -27,7 +27,7 @@ func NewVerifier(log *logger.Logger, config *artifact.Config, allowEmptyPgp bool
verifiers = append(verifiers, fsVer)

// try snapshot repo before official
if release.Snapshot() {
if release.Snapshot() || forceSnapshot {
snapshotVerifier, err := snapshot.NewVerifier(config, allowEmptyPgp, pgp)
if err != nil {
log.Error(err)
Expand Down