Skip to content

[rhcos-4.14] kola/tests: Add failing test for FIPS & LUKS#4262

Merged
HuijingHei merged 3 commits intocoreos:rhcos-4.14from
openshift-cherrypick-robot:cherry-pick-4181-to-rhcos-4.14
Mar 12, 2026
Merged

[rhcos-4.14] kola/tests: Add failing test for FIPS & LUKS#4262
HuijingHei merged 3 commits intocoreos:rhcos-4.14from
openshift-cherrypick-robot:cherry-pick-4181-to-rhcos-4.14

Conversation

@openshift-cherrypick-robot
Copy link
Copy Markdown

This is an automated cherry-pick of #4181

/assign aaradhak

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Aug 14, 2025

Hi @openshift-cherrypick-robot. Thanks for your PR.

I'm waiting for a coreos member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new test case to verify that cryptsetup fails with non-FIPS-compliant algorithms when FIPS mode is enabled. The overall test logic is sound and covers the intended scenario. I have provided a few suggestions to improve code clarity and maintainability by addressing variable shadowing and simplifying error handling logic.

Comment on lines +134 to +152
resultingError := inst.WaitAll(ctx)
if resultingError == nil {
resultingError = fmt.Errorf("ignition unexpectedly succeeded")
} else if resultingError == platform.ErrInitramfsEmergency {
// Expected initramfs failure, checking the console file to ensure
// that it failed the expected way
found, err := fileContainsPattern(builder.ConsoleFile, searchPattern)
if err != nil {
resultingError = errors.Wrapf(err, "looking for pattern '%s' in file '%s' failed", searchPattern, builder.ConsoleFile)
} else if !found {
resultingError = fmt.Errorf("pattern '%s' in file '%s' not found", searchPattern, builder.ConsoleFile)
} else {
// The expected case
resultingError = nil
}
} else {
resultingError = errors.Wrapf(resultingError, "expected initramfs emergency.target error")
}
errchan <- resultingError
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error handling logic in this goroutine is a bit complex due to multiple reassignments of resultingError. Using a switch statement on the error from inst.WaitAll(ctx) would make the logic clearer and easier to maintain.

Suggested change
resultingError := inst.WaitAll(ctx)
if resultingError == nil {
resultingError = fmt.Errorf("ignition unexpectedly succeeded")
} else if resultingError == platform.ErrInitramfsEmergency {
// Expected initramfs failure, checking the console file to ensure
// that it failed the expected way
found, err := fileContainsPattern(builder.ConsoleFile, searchPattern)
if err != nil {
resultingError = errors.Wrapf(err, "looking for pattern '%s' in file '%s' failed", searchPattern, builder.ConsoleFile)
} else if !found {
resultingError = fmt.Errorf("pattern '%s' in file '%s' not found", searchPattern, builder.ConsoleFile)
} else {
// The expected case
resultingError = nil
}
} else {
resultingError = errors.Wrapf(resultingError, "expected initramfs emergency.target error")
}
errchan <- resultingError
err := inst.WaitAll(ctx)
switch err {
case nil:
errchan <- fmt.Errorf("ignition unexpectedly succeeded")
case platform.ErrInitramfsEmergency:
// Expected initramfs failure, checking the console file to ensure
// that it failed the expected way
found, patternErr := fileContainsPattern(builder.ConsoleFile, searchPattern)
if patternErr != nil {
errchan <- errors.Wrapf(patternErr, "looking for pattern '%s' in file '%s' failed", searchPattern, builder.ConsoleFile)
} else if !found {
errchan <- fmt.Errorf("pattern '%s' in file '%s' not found", searchPattern, builder.ConsoleFile)
} else {
// The expected case
errchan <- nil
}
default:
errchan <- errors.Wrap(err, "expected initramfs emergency.target error")
}

defer builder.Close()

// Prepare Ingnition config
failConfig, err := failConfig.Render(conf.FailWarnings)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The local variable failConfig shadows the global package-level variable of the same name. This can be confusing and lead to bugs. It's better to use a different name for the local variable, for example renderedConfig.

Suggested change
failConfig, err := failConfig.Render(conf.FailWarnings)
renderedConfig, err := failConfig.Render(conf.FailWarnings)


// Instruct builder to use it
builder.ConsoleFile = consoleFile.Name()
builder.SetConfig(failConfig)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To fix the variable shadowing issue from line 174, this should use the newly named renderedConfig variable.

Suggested change
builder.SetConfig(failConfig)
builder.SetConfig(renderedConfig)

@aaradhak
Copy link
Copy Markdown
Member

/retest

@dustymabe
Copy link
Copy Markdown
Member

dustymabe commented Aug 19, 2025

The lint failures here look like they would be legitimate build failures.

Ensure that setting up a LUKS device with FIPS incompatible algorithms
will fail when FIPS mode is enabled.

Only run this on QEMU as it should behave the same way on all platforms.
@HuijingHei HuijingHei force-pushed the cherry-pick-4181-to-rhcos-4.14 branch from 29292fa to 2f029b9 Compare March 12, 2026 07:38
@HuijingHei
Copy link
Copy Markdown
Member

Rebase to rhcos-4.14 branch and wait for the results.

cgwalters and others added 2 commits March 12, 2026 15:53
It's generally a good idea for variable names include their units.

(cherry picked from commit 55658b4)
Now that coreos/fedora-coreos-pipeline#959
is merged, we have these images built by the coreOS CI and
hosted on the quay.io/coreos-assembler org.

Point tests that requires containers to use images from the
coreos-assembler org.

See  coreos#3727
Fixes coreos/fedora-coreos-tracker#1639

(cherry picked from commit 6cbe502)
@HuijingHei
Copy link
Copy Markdown
Member

Glad to see the test is passed.
--- PASS: fips.failure (50.35s)

@HuijingHei
Copy link
Copy Markdown
Member

/retest-required

@HuijingHei
Copy link
Copy Markdown
Member

/test rhcos

1 similar comment
@HuijingHei
Copy link
Copy Markdown
Member

/test rhcos

@HuijingHei HuijingHei merged commit 607c444 into coreos:rhcos-4.14 Mar 12, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants