Skip to content

Conversation

openshift-cherrypick-robot

This is an automated cherry-pick of #4181

/assign aaradhak

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.
Copy link

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.

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
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 lukscreate fails when FIPS is enabled with an incompatible crypto algorithm. The implementation looks good, but I have identified a couple of areas for improvement: a potential goroutine leak due to an unbuffered channel, and a variable shadowing issue that could affect code readability and maintainability. Please see my detailed comments.


defer cancel()

errchan := make(chan error)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The errchan is unbuffered. If the context times out (<-ctx.Done() case is selected), the goroutine launched on line 133 will block forever when it tries to send on errchan, as there will be no receiver. This will cause a goroutine leak. Using a buffered channel of size 1 will prevent this.

Suggested change
errchan := make(chan error)
errchan := make(chan error, 1)

Comment on lines +174 to +184
failConfig, err := failConfig.Render(conf.FailWarnings)
if err != nil {
return errors.Wrapf(err, "creating invalid FIPS config")
}

// Create a temporary log file
consoleFile := c.H.TempFile("console-")

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

Choose a reason for hiding this comment

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

medium

The variable failConfig declared on line 174 shadows the global variable of the same name. This can be confusing. It's better to use a different name for the rendered config, for example renderedConfig.

Suggested change
failConfig, err := failConfig.Render(conf.FailWarnings)
if err != nil {
return errors.Wrapf(err, "creating invalid FIPS config")
}
// Create a temporary log file
consoleFile := c.H.TempFile("console-")
// Instruct builder to use it
builder.ConsoleFile = consoleFile.Name()
builder.SetConfig(failConfig)
renderedConfig, err := failConfig.Render(conf.FailWarnings)
if err != nil {
return errors.Wrapf(err, "creating invalid FIPS config")
}
// Create a temporary log file
consoleFile := c.H.TempFile("console-")
// Instruct builder to use it
builder.ConsoleFile = consoleFile.Name()
builder.SetConfig(renderedConfig)

@aaradhak
Copy link
Member

/ok-to-test

Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

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

/lgtm

@jlebon jlebon enabled auto-merge (rebase) August 20, 2025 01:53
@jlebon jlebon merged commit acb829c into coreos:rhcos-4.16 Aug 27, 2025
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.

5 participants