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

kola: Disable the public update server by default #460

Merged
merged 1 commit into from
Oct 9, 2023
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
1 change: 1 addition & 0 deletions kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig
NoSSHKeyInUserData: t.HasFlag(register.NoSSHKeyInUserData),
NoSSHKeyInMetadata: t.HasFlag(register.NoSSHKeyInMetadata),
NoEnableSelinux: t.HasFlag(register.NoEnableSelinux),
NoDisableUpdates: t.HasFlag(register.NoDisableUpdates),
SSHRetries: Options.SSHRetries,
SSHTimeout: Options.SSHTimeout,
DefaultUser: t.DefaultUser,
Expand Down
1 change: 1 addition & 0 deletions kola/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
NoEnableSelinux // don't enable selinux when starting or rebooting a machine
NoKernelPanicCheck // don't check console output for kernel panic
NoVerityCorruptionCheck // don't check console output for verity corruption
NoDisableUpdates // don't disable usage of the public update server
)

// Test provides the main test abstraction for kola. The run function is
Expand Down
9 changes: 7 additions & 2 deletions kola/tests/ignition/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ func init() {
ClusterSize: 1,
ExcludePlatforms: []string{"qemu", "esx"},
Distros: []string{"cl"},
UserData: conf.Empty(),
// The userdata injection of disabling the update server won't work
// for an empty config, we still take care of doing later it via SSH
Flags: []register.Flag{register.NoDisableUpdates, register.NoSSHKeyInUserData},
UserData: conf.Empty(),
// Should run on all cloud environments
})
// Tests for https://github.com/coreos/bugs/issues/1981
Expand All @@ -59,5 +62,7 @@ func init() {
})
}

func empty(_ cluster.TestCluster) {
func empty(c cluster.TestCluster) {
m := c.Machines()[0]
_ = c.MustSSH(m, "echo SERVER=disabled | sudo tee /etc/flatcar/update.conf")
}
14 changes: 11 additions & 3 deletions kola/tests/locksmith/locksmith.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ func init() {
ClusterSize: 3,
// When cl.etcd-member.discovery runs on all clouds to test CLC IP templating, we can skip running this
Platforms: []string{"qemu", "qemu-unpriv"},
// This test already specifies the update.conf file in the userdata.
// Disabling of the public server is done explicitly.
Flags: []register.Flag{register.NoDisableUpdates},
UserData: conf.ContainerLinuxConfig(`locksmith:
reboot_strategy: etcd-lock
update:
server: disabled
etcd:
version: 3.5.0
listen_client_urls: http://0.0.0.0:2379
Expand All @@ -60,8 +65,11 @@ etcd:
Distros: []string{"cl"},
})
register.Register(&register.Test{
Name: "coreos.locksmith.tls",
Run: locksmithTLS,
Name: "coreos.locksmith.tls",
Run: locksmithTLS,
// This test already specifies the update.conf file in the userdata.
// Disabling of the public server is done explicitly.
Flags: []register.Flag{register.NoDisableUpdates},
ClusterSize: 1,
// This test is normally not related to the cloud environment
Platforms: []string{"qemu", "qemu-unpriv"},
Expand Down Expand Up @@ -95,7 +103,7 @@ etcd:
{
"filesystem": "root",
"path": "/etc/coreos/update.conf",
"contents": { "source": "data:,REBOOT_STRATEGY=etcd-lock%0A" },
"contents": { "source": "data:,REBOOT_STRATEGY=etcd-lock%0ASERVER=disabled%0A" },
"mode": 420
},
{
Expand Down
2 changes: 2 additions & 0 deletions kola/tests/misc/omaha.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func init() {
Run: OmahaPing,
ClusterSize: 0,
Name: "cl.omaha.ping",
// This test already sets its own update server in the userdata
Flags: []register.Flag{register.NoDisableUpdates},
// This test is normally not related to the cloud environment
Platforms: []string{"qemu"},
ExcludePlatforms: []string{"qemu-unpriv"},
Expand Down
6 changes: 6 additions & 0 deletions platform/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ func (bc *BaseCluster) RenderUserData(userdata *conf.UserData, ignitionVars map[
conf.CopyKeys(keys)
}

// disable the public update server by default
if !bc.rconf.NoDisableUpdates {
conf.AddFile("/etc/flatcar/update.conf", "root", `SERVER=disabled
pothos marked this conversation as resolved.
Show resolved Hide resolved
`, 0644)
}

// disable Zincati & Pinger by default
if bc.Distribution() == "fcos" {
conf.AddFile("/etc/fedora-coreos-pinger/config.d/90-disable-reporting.toml", "root", `[reporting]
Expand Down
55 changes: 50 additions & 5 deletions platform/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ func (c *Conf) addFileV3(path, filesystem, contents string, mode int) {
Files: []v3types.File{
{
Node: v3types.Node{
Path: path,
Path: path,
Overwrite: &[]bool{true}[0],
},
FileEmbedded1: v3types.FileEmbedded1{
Contents: v3types.FileContents{
Expand All @@ -610,7 +611,8 @@ func (c *Conf) addFileV31(path, filesystem, contents string, mode int) {
Files: []v31types.File{
{
Node: v31types.Node{
Path: path,
Path: path,
Overwrite: &[]bool{true}[0],
},
FileEmbedded1: v31types.FileEmbedded1{
Contents: v31types.Resource{
Expand All @@ -635,7 +637,8 @@ func (c *Conf) addFileV32(path, filesystem, contents string, mode int) {
Files: []v32types.File{
{
Node: v32types.Node{
Path: path,
Path: path,
Overwrite: &[]bool{true}[0],
},
FileEmbedded1: v32types.FileEmbedded1{
Contents: v32types.Resource{
Expand All @@ -660,7 +663,8 @@ func (c *Conf) addFileV33(path, filesystem, contents string, mode int) {
Files: []v33types.File{
{
Node: v33types.Node{
Path: path,
Path: path,
Overwrite: &[]bool{true}[0],
},
FileEmbedded1: v33types.FileEmbedded1{
Contents: v33types.Resource{
Expand Down Expand Up @@ -707,6 +711,41 @@ func (c *Conf) addFileCloudConfig(path, filesystem, contents string, mode int) {
})
}

func (c *Conf) addFileScript(path, filesystem, contents string, mode int) {
c.script += fmt.Sprintf(`
cat <<EOF > %s
%s
EOF
chmod %o %s
`, path, contents, mode, path)
}

func (c *Conf) addFileMultipartMime(path, filesystem, contents string, mode int) {
header := textproto.MIMEHeader{
"Content-Type": []string{"text/cloud-config; charset=\"us-ascii\""},
"MIME-Version": []string{"1.0"},
"Content-Transfer-Encoding": []string{"7bit"},
"Content-Disposition": []string{"attachment; filename=\"testing-keys.yaml\""},
}
cc := cci.CloudConfig{
WriteFiles: []cci.File{
cci.File{
Content: contents,
Owner: "root",
Path: path,
RawFilePermissions: fmt.Sprintf("%#o", mode),
},
},
}
asYaml, err := yaml.Marshal(cc)
if err != nil {
plog.Errorf("failed to marshal yaml: %v", err)
return
}
c.multipartMime.AddPart(header, asYaml)

}

func (c *Conf) AddFile(path, filesystem, contents string, mode int) {
if c.ignitionV33 != nil {
c.addFileV33(path, filesystem, contents, mode)
Expand All @@ -728,8 +767,12 @@ func (c *Conf) AddFile(path, filesystem, contents string, mode int) {
c.addFileV1(path, filesystem, contents, mode)
} else if c.cloudconfig != nil {
c.addFileCloudConfig(path, filesystem, contents, mode)
} else if c.multipartMime != nil {
c.addFileMultipartMime(path, filesystem, contents, mode)
} else if c.script != "" {
c.addFileScript(path, filesystem, contents, mode)
} else {
panic(fmt.Errorf("unimplemented case in AddFile"))
panic(fmt.Errorf("unimplemented case in AddFile (conf.Empty not supported on purpose"))
}
}

Expand Down Expand Up @@ -1346,6 +1389,8 @@ func (c *Conf) CopyKeys(keys []*agent.Key) {
c.copyKeysScript(keys)
} else if c.multipartMime != nil {
c.copyKeysMultipartMime(keys)
} else {
panic(fmt.Errorf("unimplemented case in CopyKeys (conf.Empty not supported on purpose"))
}
}

Expand Down
1 change: 1 addition & 0 deletions platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ type RuntimeConfig struct {
NoSSHKeyInUserData bool // don't inject SSH key into Ignition/cloud-config
NoSSHKeyInMetadata bool // don't add SSH key to platform metadata
NoEnableSelinux bool // don't enable selinux when starting or rebooting a machine
NoDisableUpdates bool // don't disable usage of the public update server
AllowFailedUnits bool // don't fail CheckMachine if a systemd unit has failed
SSHRetries int // see SSHRetries field in Options
SSHTimeout time.Duration // see SSHTimeout field in Options
Expand Down