Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(796)

Issue 61510049: Fixes to upgrade infrastructure (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by wallyworld
Modified:
10 years, 2 months ago
Reviewers:
dimitern, mp+205897, rog
Visibility:
Public.

Description

Fixes to upgrade infrastructure The initial upgrade framework was including steps for the current version by mistake. Additional tests also added. https://code.launchpad.net/~wallyworld/juju-core/upgrade-framework-fixes/+merge/205897 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : Fixes to upgrade infrastructure #

Patch Set 3 : Fixes to upgrade infrastructure #

Patch Set 4 : Fixes to upgrade infrastructure #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+87 lines, -27 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M upgrades/upgrade.go View 1 2 6 chunks +13 lines, -10 lines 4 comments Download
M upgrades/upgrade_test.go View 1 2 5 chunks +42 lines, -15 lines 0 comments Download
M version/version.go View 2 chunks +11 lines, -1 line 2 comments Download
M version/version_test.go View 2 chunks +19 lines, -1 line 0 comments Download

Messages

Total messages: 7
wallyworld
Please take a look.
10 years, 2 months ago (2014-02-12 05:03:46 UTC) #1
wallyworld
Please take a look.
10 years, 2 months ago (2014-02-12 07:02:31 UTC) #2
wallyworld
Please take a look.
10 years, 2 months ago (2014-02-12 07:25:44 UTC) #3
dimitern
Please repropose the diff is screwed.
10 years, 2 months ago (2014-02-12 08:55:05 UTC) #4
wallyworld
Please take a look.
10 years, 2 months ago (2014-02-12 09:07:29 UTC) #5
dimitern
LGTM https://codereview.appspot.com/61510049/diff/60001/upgrades/upgrade.go File upgrades/upgrade.go (right): https://codereview.appspot.com/61510049/diff/60001/upgrades/upgrade.go#newcode16 upgrades/upgrade.go:16: // Description is a human readable description of ...
10 years, 2 months ago (2014-02-12 09:30:01 UTC) #6
rog
10 years, 2 months ago (2014-02-13 09:26:29 UTC) #7
A nice direction, but could be a tad simpler, I think.

https://codereview.appspot.com/61510049/diff/60001/upgrades/upgrade.go
File upgrades/upgrade.go (right):

https://codereview.appspot.com/61510049/diff/60001/upgrades/upgrade.go#newcode15
upgrades/upgrade.go:15: type UpgradeStep interface {
Given that this is the upgrades package, perhaps
"Step" would be an appropriate name and saves
stuttering ("upgrades.Step"
reads quite well). Similarly, Operation instead 
of UpgradeOperation and Target instead
of UpgradeTarget, below.

https://codereview.appspot.com/61510049/diff/60001/upgrades/upgrade.go#newcode65
upgrades/upgrade.go:65: type Context interface {
I don't really see the point of defining both this interface and
the UpgradeContext struct together

I think that the struct would be sufficient for both
use cases - it's just a bag of stuff - we're not attaching behaviour to it.

Alternatively just define the Context interface here and
rely on clients to implement it.

Similarly for UpgradeStep and UpgradeOperation - they're essentially data
descriptions of stuff to do, and could easily be:

type UpgradeStep struct {
    Description string
    Targets []UpgradeTarget
    Run func(context Context) error
}

type UpgradeOperation struct {
    TargetVersion version.Number
    Steps []UpgradeStep
}

This would quite a bit of boilerplate code without
any particular loss of generality that I can see.

https://codereview.appspot.com/61510049/diff/60001/version/version.go
File version/version.go (right):

https://codereview.appspot.com/61510049/diff/60001/version/version.go#newcode208
version/version.go:208: func (v Number) lessMaybeEqual(w Number, wantEqual bool)
bool {
Rather than this, how about a slightly more
general function?

// Compare returns -1, 0 or 1 depending
// on whether v is less than, equal to or greater
// than w.
func (v Number) Compare(w Number) int {
    if v == w {
        return 0
    }
    switch {
    case v.Major != w.Major:
        less = v.Major < w.Major
    case v.Minor != w.Minor:
        less = v.Minor < w.Minor
    case v.Patch != w.Patch:
        less = v.Patch < w.Patch
    case v.Build != w.Build:
        less = v.Build < w.Build
    }
    if less {
        return -1
    }
    return 1
}

func (v Number) Less(w Number) bool {
    return v.Compare(w) < 0
}

?

Then we can use v.Compare(w) <= 0 instead
of LessEqual, etc.

bytes.Compare is precedent for this.

https://codereview.appspot.com/61510049/diff/60001/version/version.go#newcode208
version/version.go:208: func (v Number) lessMaybeEqual(w Number, wantEqual bool)
bool {
Rather than this, how about:

// Compare returns -1, 0 or 1 depending
// on whether v is less than, equal to or greater
// than w.
func (v Number) Compare(w Number) int {

    switch {
    case v.Major != w.Major:
        return v.Major < w.Major
    case v.Minor != w.Minor:
        return v.Minor < w.Minor
    case v.Patch != w.Patch:
        return v.Patch < w.Patch
    case v.Build != w.Build:
        return v.Build < w.Build
    }
    return wantEqual
}
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b