Skip to content
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

[CLOYSTER-165] Generate answer file based on TUI data #91

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

arthurmco
Copy link
Collaborator

@arthurmco arthurmco commented Jan 13, 2025

Dump the data from the cluster, filled by the TUI, into an answer file.

Useful for debugging

@arthurmco arthurmco self-assigned this Jan 13, 2025
@dhilst dhilst removed the request for review from lbgracioso January 13, 2025 16:33
src/cluster.cpp Outdated Show resolved Hide resolved

void AnswerFile::dumpNodes(inifile& ini)
{
size_t counter = 1;
Copy link
Owner

Choose a reason for hiding this comment

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

What if the cluster does not have any nodes? It's a workstation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Then, how the answer file would be?

Copy link
Owner

Choose a reason for hiding this comment

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

The node group is optional, or it should be, so you'll automatically figure out if it has nodes or not.

void AnswerFile::loadNetwork(const std::string& networkSection,
NetworkType& network, bool optionalNameservers)
AFNetwork& network, bool optionalNameservers)
Copy link
Owner

Choose a reason for hiding this comment

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

I really dislike this AFNetwork type. What this means?

I'm aware that isn't this PR fault, but this type does not makes sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The question is: why was this function generic?

the AFNetwork type, from what I saw, stores network parameters

Copy link
Owner

Choose a reason for hiding this comment

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

Probably bad implementation. It should fill the Cluster object without temporary storages.

* Do the inverse of `loadOptions`, i.e, move the stored settings
* into the answerfile.
*/
void dumpOptions(inifile& ini);
Copy link
Owner

Choose a reason for hiding this comment

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

const inifile&?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. I vacillated here

@@ -188,13 +194,17 @@ class AnswerFile {
*/
void loadExternalNetwork();

void dumpExternalNetwork(inifile& ini);
Copy link
Owner

Choose a reason for hiding this comment

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

inifile is passed too many times. It should be a member.


void AnswerFile::dumpPostfix(inifile& ini)
{
if (!postfix.enabled) {
Copy link
Owner

Choose a reason for hiding this comment

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

The source of this seems strange. Is it a bool on mail class? If yes that's a bug. The class should be std::optional.

case Postfix::Profile::Relay:
ini.setValue("postfix.relay", "server", postfix.smtp->server);
ini.setValue(
"postfix.relay", "port", std::to_string(postfix.smtp->port));
Copy link
Owner

Choose a reason for hiding this comment

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

int

Copy link
Collaborator

Choose a reason for hiding this comment

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

unsigned

Copy link
Owner

Choose a reason for hiding this comment

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

std::uint16_t

Comment on lines 211 to 217
dumpExternalNetwork(ini);
dumpManagementNetwork(ini);
dumpApplicationNetwork(ini);
dumpInformation(ini);
dumpTimeSettings(ini);
dumpHostnameSettings(ini);
dumpSystemSettings(ini);
Copy link
Owner

Choose a reason for hiding this comment

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

You see, it should be a member.

Base automatically changed from fix-bugs to master January 13, 2025 21:04
@dhilst
Copy link
Collaborator

dhilst commented Jan 14, 2025

_ No description provided. _

Arthur, plz give an precise description of the feature in the PR description (:

@viniciusferrao
Copy link
Owner

I don't understand why Github shows changes from PR's that were already merged. I could not read the code anymore because everything is mixed. Is that how this works?

@arthurmco arthurmco force-pushed the cloyster-answerfile-dump branch from 6e3138f to 89de020 Compare January 16, 2025 17:24
@dhilst dhilst marked this pull request as ready for review January 16, 2025 17:31
conanfile.txt Outdated
Comment on lines 1 to 13
[requires]
cli11/[>=2.4.0 <2.5.0]
spdlog/[>=1.14.0 <1.15.0]
fmt/[>=10.0.0 <12.0.0]
boost/[>=1.83.0 <1.84.0]
magic_enum/[>=0.9.0 <0.10.0]
gsl-lite/[>=0.41.0 <0.42.0]
doctest/[>=2.4.0 <2.5.0]
cryptopp/[>=8.9.0 <8.10.0]
sdbus-cpp/[>=2.0.0 <2.1.0]

[layout]
cmake_layout
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this file need to be deleted in favor of connanfile.py, right?
@viniciusferrao

Comment on lines +25 to +40
struct AFNode {
std::optional<std::string> prefix;
std::optional<std::string> padding;
std::optional<address> start_ip = address();
std::optional<std::string> hostname;
std::optional<std::string> root_password;
std::optional<std::string> mac_address;
std::optional<std::string> sockets;
std::optional<std::string> cores_per_socket;
std::optional<std::string> threads_per_core;
std::optional<std::string> bmc_address;
std::optional<std::string> bmc_username;
std::optional<std::string> bmc_password;
std::optional<std::string> bmc_serialport;
std::optional<std::string> bmc_serialspeed;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is prefix and padding sensical for a single node? Remove it if it doesn't please.

Also, I guess it is ip instead of start_ip?

And some fields like sockets and core_pre_socket should be positive integers, instead of strings, @viniciusferrao uint16_t again?

Copy link
Owner

Choose a reason for hiding this comment

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

Prefix is the node prefix, like: n or node. The padding is the number of digits a sequence should have, example, a padding of 1 will produce n01, 2 will be node001. None will be just n1, or node1.

Finally the start_ip is considering a formation of nodes, that will be filled in sequence.

So yes, it seems misplaced, because it looks like it should be calculated and not hardcoded.

Regarding the other fields, yes, they must have strong typing. However I'm not sure how SimpleIni handles this. I very much dislike everything being std::string.

@dhilst
Copy link
Collaborator

dhilst commented Jan 16, 2025

Dump the data from the cluster, filled by the TUI, into an answer file.

Useful for debugging

How can I run the TUI and get the anwerfile without running the remaining of the installation?

Copy link
Owner

@viniciusferrao viniciusferrao left a comment

Choose a reason for hiding this comment

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

Can it also possible to write answerfile in extension instead of AF? Maybe answer_file?

Let's try to merge this as soon as possible so we can move on to glibmm.

@dhilst
Copy link
Collaborator

dhilst commented Jan 17, 2025

Can it also possible to write answerfile in extension instead of AF? Maybe answer_file?

Let's try to merge this as soon as possible so we can move on to glibmm.

The only thing missing is to generate the answerfile and stop (do not continue the installation), the remaining of the code LGTM

@viniciusferrao
Copy link
Owner

viniciusferrao commented Jan 17, 2025

Can it also possible to write answerfile in extension instead of AF? Maybe answer_file?
Let's try to merge this as soon as possible so we can move on to glibmm.

The only thing missing is to generate the answerfile and stop (do not continue the installation), the remaining of the code LGTM

That can be (not should) on main(). Just before the start of the executionEngine it should dump and return.

@arthurmco arthurmco force-pushed the cloyster-answerfile-dump branch 2 times, most recently from a47101a to 0be1187 Compare January 20, 2025 09:44
viniciusferrao and others added 7 commits January 20, 2025 06:45
Signed-off-by: Vinícius Ferrão <[email protected]>

Fixed more outrageous bugs.

The program is now able to at least boot a compute node again

Signed-off-by: Vinícius Ferrão <[email protected]>

Disable cosmetic warnings

Pin spdlog version

Run clang-format

Handle copy to temporary file error

Fix message in CMakeLists.txt

Handle error in answerfile minor version

Fix routing error disabling the VM network

Enable Managed network again

Fix answerfile version handling

Fix copyFile implementation

Fix typos, change variables names and fix throw.

* Fix typos in the documentation.
* Fix typos on LOG messages.
* Change variable names to be more accurate with the context.
* Rethrow should also follow the golden rule of: throw by value and catch by reference.

Signed-off-by: Vinícius Ferrão <[email protected]>

Clearning more warnings

Fix the last warnings

Remove std::exit call, and raise an exception instead

Run clang-format

Added version ranges to conanfile.txt

This change will keep the project more reliable while
still getting updates from upstream on minor versions.

Signed-off-by: Vinícius Ferrão <[email protected]>

Last try to fix clang-format

Signed-off-by: Vinícius Ferrão <[email protected]>
This parameter was unneeded, we can use the member m_ini parameter
@arthurmco arthurmco force-pushed the cloyster-answerfile-dump branch from 0be1187 to 58ba2db Compare January 20, 2025 09:46
@arthurmco arthurmco requested review from dhilst and removed request for viniciusferrao January 20, 2025 09:46
@dhilst
Copy link
Collaborator

dhilst commented Jan 20, 2025

image

Fix the warning

src/main.cpp Outdated
LOG_TRACE("Starting execution engine");
model->dumpData("answerfile.result.ini");

return EXIT_SUCCESS;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will stop the execution unconditionally, remove it. To generate the file without executing it we can already use dry run

Copy link
Collaborator

@dhilst dhilst Jan 20, 2025

Choose a reason for hiding this comment

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

Also, it leads to another warning, please fix it
image

Copy link
Collaborator

@dhilst dhilst Jan 20, 2025

Choose a reason for hiding this comment

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

I'm getting a permission error when executing it, we should add a command line option to where the answerfile should be generated, --dump-answerfile=<PATH> and use answerfile-<DATE>.conf as default, where <DATE> is the current date. This will prevent anwerfiles to be rewritten.

image

I'm having weird messages at the background of the TUI, I guess this is a bug?
image, maybe this is because of the -l6?

Confirming, yes it is because of the -l6, it's okay I guess. @viniciusferrao What do you think? Is -l6 supposed to be used by the end user?

Copy link
Owner

Choose a reason for hiding this comment

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

I'm getting a permission error when executing it, we should add a command line option to where the answerfile should be generated, --dump-answerfile=<PATH> and use answerfile-<DATE>.conf as default, where <DATE> is the current date. This will prevent anwerfiles to be rewritten.

image

I'm having weird messages at the background of the TUI, I guess this is a bug? image, maybe this is because of the -l6?

Confirming, yes it is because of the -l6, it's okay I guess. @viniciusferrao What do you think? Is -l6 supposed to be used by the end user?

This is and isn't a bug at the same time. If you see other applications, when there's warnings or errors it overwrites the newt library, which is expected.

But what is happening here is that the log should be preferrabily written to a file instead of stdout. If you call the TUI it's obvious that the output should be on a file.

If running in unattended mode it should be on stdout. That's the problem here.

The view isn't implemented correctly. However even after fixing this will still occour, however much less, and many times it will not even happen. Errors should be thrown using the TUI composing.

For now I would leave it as is.

src/presenter/PresenterNodesOperationalSystem.cpp Outdated Show resolved Hide resolved
src/presenter/PresenterNetwork.cpp Outdated Show resolved Hide resolved
@@ -42,6 +42,8 @@ class NetworkCreator {
bool checkIfInterfaceRegistered(std::string_view interface);

void saveNetworksToModel(Cluster& model);

size_t getSelectedInterfaces();
Copy link
Owner

Choose a reason for hiding this comment

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

std::size_t.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's the same thing, no?

@dhilst
Copy link
Collaborator

dhilst commented Jan 20, 2025

@viniciusferrao If we run with -a what should be the behavior? It should generate another answerfile? This would be useful for testing because the input and output must match.

I think we should add an --dump-answerfile=<PATH> option that dumps the answerfile even if -a is passed in the command line

Here is a behavioral specification suggestion:

  • --dump-anwerfile=output-answerfile.conf and no -a: Invokes the TUI, ask the question to the user and generate output-answerfile.conf at the end of the questions
  • -a input-answerfile.conf --dump-anwerfile=output-answerfile.conf: generates output-answerfile.conf and diff input-answerfile.conf output-answerfile.conf must output no lines (both files are equal (as long as input-answerfile.conf was generated by a previous successful run with --dump-answerfile=input-answerfile.conf))
  • -a input-answerfile.conf (and no --dump-anwerfile): No answerfile is generated
  • No -a and no --dump-answerfile: Generates answerfile-<DATE>.conf where <DATE> is a date in the format YYYY-mm-dd-HHMM

@dhilst
Copy link
Collaborator

dhilst commented Jan 20, 2025

I got a segfault after entering the node information, not sure yet where (installing clion to find out) meanwhile, here is the gdb stacktrace (for future reference)
image

@arthurmco
Copy link
Collaborator Author

@dhilst OK, we will solve this in a future PR

@arthurmco arthurmco requested a review from dhilst January 21, 2025 13:53
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.

3 participants