Skip to content

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

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

Open
wants to merge 1 commit into
base: rhcos-4.17
Choose a base branch
from

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 failing test for FIPS and LUKS, which is a valuable addition to verify failure modes. The overall logic is sound. My review includes a fix for a potential resource leak, and suggestions to improve error handling and code maintainability for better long-term quality.

}

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

Choose a reason for hiding this comment

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

high

The file handle returned by c.H.TempFile is not being closed, which can lead to a resource leak. You should defer its closure immediately after creation.

	consoleFile := c.H.TempFile("console-")
	defer consoleFile.Close()

Comment on lines +98 to +100
if err := ignitionFailure(c); err != nil {
c.Fatal(err.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

Using err.Error() with c.Fatal can cause loss of valuable stack trace information when using libraries like github.com/pkg/errors. Passing the error object directly to c.Fatal will preserve the stack trace and improve debuggability.

Suggested change
if err := ignitionFailure(c); err != nil {
c.Fatal(err.Error())
}
if err := ignitionFailure(c); err != nil {
c.Fatal(err)
}

Comment on lines +103 to +119
// Read file and verify if it contains a pattern
// 1. Read file, make sure it exists
// 2. regex for pattern
func fileContainsPattern(path string, searchPattern string) (bool, error) {
file, err := os.ReadFile(path)
if err != nil {
return false, err
}
// File has content, but the pattern is not present
match := regexp.MustCompile(searchPattern).Match(file)
if match {
// Pattern found
return true, nil
}
// Pattern not found
return false, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This function is more verbose than necessary and contains redundant comments. It can be simplified for better readability and maintainability.

// fileContainsPattern reads a file and reports whether it contains a match for a regex pattern.
func fileContainsPattern(path string, searchPattern string) (bool, error) {
	file, err := os.ReadFile(path)
	if err != nil {
		return false, err
	}
	// The pattern is a static string, so MustCompile is safe.
	return regexp.MustCompile(searchPattern).Match(file), nil
}

defer builder.Close()

// Prepare Ingnition config
failConfig, err := failConfig.Render(conf.FailWarnings)
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 returned by failConfig.Render shadows the package-level variable of the same name. This can be confusing and hurt maintainability. It's better to use a different name for the rendered config, like renderedConfig, to avoid ambiguity. You will also need to update its usage on line 184.

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

@aaradhak
Copy link
Member

/retest

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:52
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