-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupgrade.go
More file actions
107 lines (84 loc) · 2.84 KB
/
upgrade.go
File metadata and controls
107 lines (84 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package cmd
import (
"fmt"
"sync"
"github.com/deis/deis/deisctl/backend"
"github.com/deis/deis/deisctl/config"
"github.com/deis/deis/deisctl/config/model"
)
// UpgradePrep stops and uninstalls all components except router and publisher
func UpgradePrep(b backend.Backend) error {
var wg sync.WaitGroup
b.Stop([]string{"database", "registry@*", "controller", "builder", "logger", "logspout"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"database", "registry@*", "controller", "builder", "logger", "logspout"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-volume", "store-gateway@*"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-volume", "store-gateway@*"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-metadata"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-metadata"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-daemon"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-daemon"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-monitor"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-monitor"}, &wg, Stdout, Stderr)
wg.Wait()
fmt.Fprintln(Stdout, "The platform has been stopped, but applications are still serving traffic as normal.")
fmt.Fprintln(Stdout, "Your cluster is now ready for upgrade. Install a new deisctl version and run `deisctl upgrade-takeover`.")
fmt.Fprintln(Stdout, "For more details, see: http://docs.deis.io/en/latest/managing_deis/upgrading-deis/#graceful-upgrade")
return nil
}
func listPublishedServices(cb config.Backend) ([]*model.ConfigNode, error) {
nodes, err := cb.GetRecursive("deis/services")
if err != nil {
return nil, err
}
return nodes, nil
}
func republishServices(ttl uint64, nodes []*model.ConfigNode, cb config.Backend) error {
for _, node := range nodes {
_, err := cb.SetWithTTL(node.Key, node.Value, ttl)
if err != nil {
return err
}
}
return nil
}
// UpgradeTakeover gracefully starts a platform stopped with UpgradePrep
func UpgradeTakeover(b backend.Backend, cb config.Backend) error {
if err := doUpgradeTakeOver(b, cb); err != nil {
return err
}
return nil
}
func doUpgradeTakeOver(b backend.Backend, cb config.Backend) error {
var wg sync.WaitGroup
nodes, err := listPublishedServices(cb)
if err != nil {
return err
}
b.Stop([]string{"publisher"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"publisher"}, &wg, Stdout, Stderr)
wg.Wait()
if err := republishServices(1800, nodes, cb); err != nil {
return err
}
b.RollingRestart("router", &wg, Stdout, Stderr)
wg.Wait()
b.Create([]string{"publisher"}, &wg, Stdout, Stderr)
wg.Wait()
b.Start([]string{"publisher"}, &wg, Stdout, Stderr)
wg.Wait()
installDefaultServices(b, false, &wg, Stdout, Stderr) // @fixme: hax?
wg.Wait()
startDefaultServices(b, false, &wg, Stdout, Stderr) // @fixme: hax?
wg.Wait()
return nil
}