kola: add bootc-base tag for kola tests#4469
Conversation
|
Skipping CI for Draft Pull Request. |
There was a problem hiding this comment.
Code Review
This pull request introduces a --no-ignition flag to kola to allow running tests on pre-baked QCOW2 images, optimizing certain testing scenarios. However, the implementation of the --ssh-user flag introduces a potential SSH configuration injection vulnerability in mantle/platform/cluster.go as the user-supplied SSHUser string is written directly into the ssh-config file without sanitization. It is recommended to sanitize this input to prevent arbitrary SSH option injection. Additionally, consider improving the readability of the machine creation logic in the QEMU platform code.
| if bc.rconf.SSHUser != "" { | ||
| if _, err := fmt.Fprintf(sshBuf, " User %s\n", bc.rconf.SSHUser); err != nil { | ||
| return err | ||
| } | ||
| } |
There was a problem hiding this comment.
The SSHUser command-line flag is written directly into the ssh-config file without sanitization. An attacker who can control the command-line arguments to kola can inject arbitrary SSH configuration options by including newlines in the SSHUser string. This can lead to arbitrary command execution if the ssh-config file is used by the user or another tool (e.g., via ProxyCommand).
| qc.mu.Lock() | ||
|
|
||
| conf, err := qc.RenderUserData(userdata, map[string]string{}) | ||
| if err != nil { | ||
| noIgnition := qc.RuntimeConf().NoIgnition | ||
| var conf *conf.Conf | ||
| var confPath string | ||
| var err error | ||
| if noIgnition { | ||
|
|
||
| qc.mu.Unlock() | ||
| return nil, err | ||
| } else { | ||
| conf, err = qc.RenderUserData(userdata, map[string]string{}) | ||
| if err != nil { | ||
| qc.mu.Unlock() | ||
| return nil, err | ||
| } | ||
| qc.mu.Unlock() | ||
|
|
||
| if conf.IsIgnition() { | ||
| confPath = filepath.Join(dir, "ignition.json") | ||
| if err := conf.WriteFile(confPath); err != nil { | ||
| return nil, err | ||
| } | ||
| } else if !conf.IsEmpty() { | ||
| return nil, fmt.Errorf("qemu only supports Ignition or empty configs") | ||
| } | ||
| } |
There was a problem hiding this comment.
This block for handling Ignition is a bit complex and hard to follow due to the locking and branching. It can be simplified by restructuring the if condition and moving the lock to be more tightly scoped around the operation it protects. This will improve readability and maintainability.
noIgnition := qc.RuntimeConf().NoIgnition
var conf *conf.Conf
var confPath string
var err error
if !noIgnition {
qc.mu.Lock()
conf, err = qc.RenderUserData(userdata, map[string]string{})
qc.mu.Unlock()
if err != nil {
return nil, err
}
if conf.IsIgnition() {
confPath = filepath.Join(dir, "ignition.json")
if err := conf.WriteFile(confPath); err != nil {
return nil, err
}
} else if !conf.IsEmpty() {
return nil, fmt.Errorf("qemu only supports Ignition or empty configs")
}
}
Do you have any context for all of this? Running nested container images inside kubernetes/openshift (where we run our pipeline today) isn't trivial so I'm not sure if it will save us much. Also, the description here is contradictory. It says we should be able to run tests against a container, but then you mention a QCOW with an ssh key inject, which is a VM. What's the real goal here? |
Hey Dusty, I’ll send over the task and the context I have. To be honest, I’m still figuring it out myself. Since this is a spike, the goal is to investigate and see what’s actually feasible. The DoD in the jira ticket is to create a POC and document the different approaches. |
7640c85 to
c6612bc
Compare
joelcapitao
left a comment
There was a problem hiding this comment.
It looks good overall, though I think we can already add systemd/SMBIOS support in this PR to implement SSH key provisioning.
So, instead of injecting SSH keys via Ignition, QEMU would be started with:
-smbios type=11,value=io.systemd.credential.binary:tmpfiles.extra=<base64-encoded-tmpfiles-config>
That way, we'd be able to run the kola bootc-base tagged tests against bootc image.
6b43480 to
5917f5d
Compare
|
@joelcapitao I added the support for SMBIOS and I guess it's good since I tested manually and worked fine. I need to test with bootc too. |
jlebon
left a comment
There was a problem hiding this comment.
Awesome, thanks for working on this!
I think it's OK to try things out by having some of the built-in tests be base bootc-compatible to start. But the real value is in external tests. Once we add enablement for bootc-base for external tests, I would probably even drop all of the internal tags we added to tests here. I don't think it's a good idea to have kola built-in tests be a chokepoint/maintenance burden as we look to scale out kola usage across !CoreOS.
| // Use default builder if none provided | ||
| builder = qc.ensureBuilderDefaults(builder) | ||
|
|
||
| qm, config, err := qc.createMachine(userdata) |
There was a problem hiding this comment.
createMachine seems to already handle the case where userdata could be nil. Would it be cleaner to instead keep using createMachine, and conditionalize whatever else is needed there on nil userdata?
There was a problem hiding this comment.
Not sure I got the point here, but I kept createMachine and moved the Ignition vs SMBIOS split there. For bootc runs we key off --no-ignition rather than userdata == nil, since many normal tests pass nil userdata and still expect default Ignition. When the flag isn’t set, nil userdata still goes through RenderUserDataIfNeeded as before. Is that making sense to you? What would be another approach for this?
| if qc.flight.opts.Arch != "" { | ||
| if err := builder.SetArchitecture(qc.flight.opts.Arch); err != nil { | ||
| return nil, err | ||
| } | ||
| } |
There was a problem hiding this comment.
This feels like something that should just already be taken care of when builder was constructed.
There was a problem hiding this comment.
I did this based in what I saw in qemuiso/cluster.go (line 91 - 101). As far I understood NewQemuBuilder only knows host defaults. Is that right? What would be the best approach in this case?
| if qc.flight.opts.Firmware != "" { | ||
| builder.Firmware = qc.flight.opts.Firmware | ||
| } |
5523475 to
c6d020a
Compare
c6d020a to
6735d65
Compare
… set UserData.docs. Tag the agreed core, ostree, and rpm-ostree upgrade-rollback tests so we can select them without custom Ignition
Provision SSH keys via systemd tmpfiles.extra credentials passed through QEMU SMBIOS so bootc-base tests can run without Ignition.
6735d65 to
20a2c9d
Compare
20a2c9d to
90e9fcd
Compare
90e9fcd to
6dcbff7
Compare
Adds a bootc-base tag for Kola tests that do not set register.Test.UserData (no test-specific Ignition/Butane).