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

WIP: stream fallback #8080

Closed

Conversation

babbageclunk
Copy link
Contributor

Work in progress The stream fallback is done, but searching for agents across multiple datasources isn't yet.

Description of change

If someone bootstraps with a beta or with an explicitly set devel stream, we weren't then considering released agent binaries as possible candidates for upgrades (because they are on the released stream).
Change the metadata lookup so that we check the released stream if a controller is on the devel stream.

Similarly, if someone has configured an agent source, we should still be able to check the cloud datasource and the public streams for better binary versions.

QA steps

Bootstrap a controller with 2.2-beta3 (using a released 2.2 binary). Then run juju upgrade-juju -m controller. The controller should be upgraded to 2.2.6.

Documentation changes

It's possible this needs documentation? I couldn't find any documentation for how we find agent binaries in streams, but if there is we should add a mention of the fallback to it.

},
}
items, resolveInfo, err := simplestreams.GetMetadata(sources, params)
if len(cons.Streams) > 0 {
params.ValueParams.MirrorContentId = ToolsContentId(cons.Streams[0])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit unsure about this part. It feels odd to rely on the knowledge that the first stream will be the one we're officially on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not - the there will potentially be multiple mirror content ids. The one to use will coincide with the agent binary index actually used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean it's not right? So does that mean that ValueParams.MirrorContentId needs to be a []string as well? Or hmm, I guess it needs to be a func that takes the stream name and returns the corresponding content id?

@@ -99,18 +99,21 @@ func Fetch(
ValueTemplate: Metadata{},
},
}
items, resolveInfo, err := simplestreams.GetMetadata(src, params)
results, err := simplestreams.GetMetadata(src, params)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetMetadata should return NotFound if len(results) == 0
This simplifies all of the call sites to not require a separate error check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wilco.

if len(results) < 1 {
return nil, nil, errors.NotFoundf("simplestreams metadata results")
}
md := make([]*Metadata, len(results[0].Items))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why results[0]?
We should be iterating over all returned results

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In image downloads? We'll never pass UseAllSources=true here, why iterate through the results?

ids := make([]string, 0, nrArches*nrSeries*nrStreams)
for _, stream := range streams {
stream = idStream(stream)
for _, arch := range ic.Arches {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be pulled out to a separate func; inline would do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean pull the arch and ser loops into a local func? Why do that? (I guess it would reduce rightward drift?)

// onlySigned is false and no signed metadata is found in a source,
// the source is used to look for unsigned metadata. Each source is
// tried in turn - if AllResults is false then the results from the
// first signed (or unsigned) match are returned. If AllResults is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not so much "match" as the first datasource containing a valid index

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will update.


streams := []string{stream}
if fallback {
streams = streamFallbacks[stream]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if they pass in a stream that's not in fallbacks, we need to just use that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, makes sense.

If this is true, we'll look across streams when searching a source for
tools metadata. Change the fetching code to use stream fallback, while
the MergeMetadata path doesn't (since it already goes across streams,
and fallback here would introduce lots of duplicates).
This is a step towards allowing it to return results from more than one
source.
Rather than using a fallback flag on the ToolsConstraint.
Not including the MirrorContentId changes which will be more
substantial.
jujubot added a commit that referenced this pull request Nov 16, 2017
Find agent binaries using fallback across streams

### Description of change

If someone bootstraps with a beta or with an explicitly set devel stream, we weren't then considering released agent binaries as possible candidates for upgrades (because they are on the released stream). 
Change the metadata lookup so that we check the released stream if a controller is on the devel stream.

This is another go at #8080 without trying to change the simplestreams code - handling mirrors and resolve info was too involved. This version combines the results just above `tools/simplestreams/Fetch`, which means it handles mirrors right for each stream and doesn't need to combine resolve info because it's thrown away at that point anyway.

## QA steps

Bootstrap a controller with 2.2-beta3 (using a released 2.2 binary). Then run `juju upgrade-juju -m controller`. The controller should be upgraded to 2.2.6.

## Documentation changes

It's possible this needs documentation? I couldn't find any documentation for how we find agent binaries in streams, but if there is we should add a mention of the fallback to it.
@wallyworld wallyworld closed this Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants