-
Notifications
You must be signed in to change notification settings - Fork 184
[rhcos-4.18] - Backport failing test for FIPS & LUKS #4258
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
Conversation
There was a problem hiding this 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.
if err := ignitionFailure(c); err != nil { | ||
c.Fatal(err.Error()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing err
directly to c.Fatal()
can provide more detailed error information, especially for wrapped errors which may include stack traces. This improves debuggability.
if err := ignitionFailure(c); err != nil { | |
c.Fatal(err.Error()) | |
} | |
if err := ignitionFailure(c); err != nil { | |
c.Fatal(err) | |
} |
case err := <-errchan: | ||
if err != nil { | ||
return err | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
Backporting #4181