Skip to content

Conversation

aaradhak
Copy link
Member

Backporting #4181

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

The pull request adds a new failing test for FIPS and LUKS, which is a backport. The new test code is well-structured. I've provided a few suggestions to improve code clarity, debuggability, and maintainability. These include using a more descriptive variable name to avoid shadowing, simplifying error handling logic, and improving how errors are reported.

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

Passing err directly to c.Fatal() can provide more detailed error information, especially for wrapped errors which may include stack traces. This improves 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 +161 to +165
case err := <-errchan:
if err != nil {
return err
}
return 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

The logic for handling the error from the channel can be simplified. Returning err directly achieves the same result, as it will be nil on success and contain the error on failure.

	case err := <-errchan:
		return err

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 is being shadowed here. It is initially a *conf.UserData at the package level, and then it is redeclared as a *conf.Conf within this function. This can be confusing. It's better to use a different name for the rendered configuration to improve clarity.

	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 aaradhak closed this Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant