Skip to content

Commit ff5903b

Browse files
committed
mantle/kola: simplify updates logic in kola upgrade test
Since we are dropping a config fragment down that has higher priority than all the others that try to disable updates from various sources (i.e. dev build, non-production build, etc) then we don't need to worry about deleting them. Let's just let the higher priority config win. This also means we don't have to start and stop and start and stop zincati so many times. Let's just start the machine with it disabled and then start it when we've got the infra in place for it to recognize and apply an update. This may help avoid some race conditions now or in the future.
1 parent d2b9090 commit ff5903b

File tree

1 file changed

+11
-53
lines changed

1 file changed

+11
-53
lines changed

mantle/kola/tests/upgrade/basic.go

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"time"
2626

2727
"github.com/coreos/pkg/capnslog"
28-
rpmostreeclient "github.com/coreos/rpmostree-client-go/pkg/client"
2928

3029
"github.com/coreos/coreos-assembler/mantle/kola"
3130
"github.com/coreos/coreos-assembler/mantle/kola/cluster"
@@ -57,10 +56,15 @@ func init() {
5756
// 2. auto-runs httpd once kolet is scp'ed
5857
// 3. changes the Zincati config to point to localhost:8080 so we'll be
5958
// able to feed the update graph we want
60-
// 4. always start with Zincati updates disabled so we can finish
61-
// setting it up here before enabling it again without risking race
62-
// conditions
63-
// 5. change the OSTree remote to localhost:8080
59+
// 4. changes the Zincati config to have a 99-updates-enabled.toml config
60+
// that overrides any previous config that would have disabled them like
61+
// the following that are dropped in various scenarios:
62+
// - 90-disable-auto-updates.toml
63+
// - 90-disable-on-non-production-stream.toml
64+
// - 95-disable-on-dev.toml
65+
// 5. disables zincati.service in Ignition so we can finish setting it up here
66+
// before starting it again without risking race conditions
67+
// 6. change the OSTree remote to localhost:8080
6468
// We could use file:/// to simplify things though using a URL at least
6569
// exercises the ostree/libcurl stack.
6670
// We use strings.Replace here because fmt.Sprintf would try to
@@ -72,6 +76,7 @@ func init() {
7276
"units": [
7377
{
7478
"name": "zincati.service",
79+
"enabled": false,
7580
"dropins": [{
7681
"name": "verbose.conf",
7782
"contents": "[Service]\nEnvironment=ZINCATI_VERBOSITY=\"-vvvv\""
@@ -96,7 +101,7 @@ func init() {
96101
"mode": 420
97102
},
98103
{
99-
"path": "/etc/zincati/config.d/99-updates.toml",
104+
"path": "/etc/zincati/config.d/99-updates-enabled.toml",
100105
"contents": { "source": "data:,updates.enabled%20%3D%20true%0A" },
101106
"mode": 420
102107
},
@@ -179,13 +184,6 @@ func fcosUpgradeBasic(c cluster.TestCluster) {
179184
// https://github.com/coreos/coreos-assembler/issues/1301
180185
c.RunCmdSync(m, "time sudo sync")
181186

182-
// disable zincati; from now on, we'll start it manually whenenever we
183-
// want to upgrade via Zincati
184-
c.RunCmdSync(m, "sudo systemctl disable --now --quiet zincati.service")
185-
c.RunCmdSync(m, "sudo rm /etc/zincati/config.d/99-updates.toml")
186-
// delete what mantle adds (XXX: should just opt out of this upfront)
187-
c.RunCmdSync(m, "sudo rm /etc/zincati/config.d/90-disable-auto-updates.toml")
188-
189187
})
190188

191189
c.Run("upgrade-from-previous", func(c cluster.TestCluster) {
@@ -288,42 +286,6 @@ func (g *Graph) addUpdate(c cluster.TestCluster, m platform.Machine, version, pa
288286
g.sync(c, m)
289287
}
290288

291-
// XXX: consider making this distinction part of FCOS itself?
292-
func onProdStream(c cluster.TestCluster, d *rpmostreeclient.Deployment) bool {
293-
stream, err := util.GetDeploymentStream(d)
294-
if err != nil {
295-
panic(err)
296-
}
297-
switch stream {
298-
case "stable", "testing", "next":
299-
return true
300-
default:
301-
return false
302-
}
303-
}
304-
305-
func isDevBuild(c cluster.TestCluster, d *rpmostreeclient.Deployment) bool {
306-
return strings.Contains(d.Version, "dev")
307-
}
308-
309-
// On production streams, the default should already be to have updates turned
310-
// on, so we shouldn't have to delete anything. On developer and/or
311-
// non-production streams, we have to delete other knobs.
312-
func undoZincatiDisablement(c cluster.TestCluster, m platform.Machine) {
313-
d, err := util.GetBootedDeployment(c, m)
314-
if err != nil {
315-
c.Fatal(err)
316-
}
317-
318-
if !onProdStream(c, d) {
319-
c.RunCmdSync(m, "sudo rm -f /etc/zincati/config.d/90-disable-on-non-production-stream.toml")
320-
}
321-
322-
if isDevBuild(c, d) {
323-
c.RunCmdSync(m, "sudo rm -f /etc/zincati/config.d/95-disable-on-dev.toml")
324-
}
325-
}
326-
327289
func (g *Graph) sync(c cluster.TestCluster, m platform.Machine) {
328290
b, err := json.Marshal(g)
329291
if err != nil {
@@ -358,10 +320,6 @@ func runFnAndWaitForRebootIntoVersion(c cluster.TestCluster, m platform.Machine,
358320
}
359321

360322
func waitForUpgradeToVersion(c cluster.TestCluster, m platform.Machine, version string) {
361-
// we have to do this every time in case e.g. we've just rebased from an
362-
// official pipeline build to a developer build
363-
undoZincatiDisablement(c, m)
364-
365323
runFnAndWaitForRebootIntoVersion(c, m, version, func() {
366324
// XXX: update to use https://github.com/coreos/zincati/issues/203
367325
c.RunCmdSync(m, "sudo systemctl start zincati.service")

0 commit comments

Comments
 (0)