Conversation
|
|
||
| void ELRepoFile::read() | ||
| { | ||
| printf("reading\n"); |
| m_repositories.push_back(std::move(repo)); | ||
| } | ||
|
|
||
| for (const auto& r : m_repositories) { |
There was a problem hiding this comment.
I would avoid using only r as variable name. Usually we use it for well defined counters, like: i, j and k. Or for iterators, like it.
There was a problem hiding this comment.
This is only code for toying with glibmm
In real life, this would not be like this
(This comment applies to every printf/fmt::format comment above)
| class ELRepoFile : public RepoFile<ELRepo> { | ||
| private: | ||
| Glib::RefPtr<Glib::KeyFile> loadFile(); | ||
|
|
||
| public: | ||
| ELRepoFile(const std::filesystem::path& path) | ||
| : RepoFile(path) | ||
| { | ||
| } | ||
|
|
||
| void read() override; | ||
| void write() override; | ||
| }; |
There was a problem hiding this comment.
We can have an abstract RepoFile which extends the File, adds the m_repositories generic member, and with parse unparse methods, read is super read followed by parse and write is unparse followed by super write
There was a problem hiding this comment.
std::filesystem::path is convertible to std::string or const char*. We must use it. It's the right API.
However the file class that be dependent on std::filesystem::path and not the derived one.
There was a problem hiding this comment.
Just to be clear
parseloads data from the file into them_repositoriesmemberunparseloads them_repositoriesmember into the file
Also, @arthurmco, add overloads to parse and unparse which I/O into istringstream ostringstream instead of directly into the file so we can test without touching the disks. I don't know if this is possible because I don't know the interface of glibmm if it can load/unload keyfiles from strings, can it?
There was a problem hiding this comment.
This is possible; glibmm can load keyhole data from a string.
| std::vector<ELRepo> ELRepoFile::parse(const std::stringstream& ss) | ||
| { | ||
| m_file = Glib::KeyFile::create(); | ||
| m_file->load_from_data(ss.str().c_str()); | ||
| return this->parseData(); | ||
| } |
There was a problem hiding this comment.
Cool, now
- Add
m_repositoriesmember as a vector of ELRepo with a getter - The getter should load the data into the member if the member is empty and return at the end
There was a problem hiding this comment.
Inside of ELRepo?
| struct ELRepo { | ||
| std::string group; | ||
| std::string name; | ||
| std::optional<std::string> baseURL; |
| auto get_optional_string | ||
| = [this](auto group, auto key) -> std::optional<Glib::ustring> { | ||
| return m_file->has_key(group, key) | ||
| ? std::make_optional(m_file->get_string(group, key)) | ||
| : std::nullopt; | ||
| }; |
There was a problem hiding this comment.
I don't see why this captures this, anyway, move it to functions.cpp
dhilst
left a comment
There was a problem hiding this comment.
The API looks good, there are a few points
- Make sure to remove the prints
- Rename the ELReo to ELCloneRepo
- Remove the PR from draft
viniciusferrao
left a comment
There was a problem hiding this comment.
Another issue that I've observed. The virtual classes should be on its own files. This needs to be fixed.
|
|
||
| std::vector<ELRepo> ELRepoFile::parse() | ||
| { | ||
| this->read(); |
| void copyFile(std::filesystem::path source, std::filesystem::path destination); | ||
|
|
||
| std::optional<Glib::ustring> readKeyfileString(Glib::RefPtr<Glib::KeyFile> file, | ||
| const std::string_view& group, const std::string_view& key); |
There was a problem hiding this comment.
std:string_view is already a pointer to a string. It should not be passed as const ref.
There was a problem hiding this comment.
I didn't know that. I thought it was pointer+length. It will be fixed
| } | ||
|
|
||
| std::optional<Glib::ustring> readKeyfileString(Glib::RefPtr<Glib::KeyFile> file, | ||
| const std::string_view& group, const std::string_view& key) |
viniciusferrao
left a comment
There was a problem hiding this comment.
I ended up adding a lot of comments.
I think we should think a little bit more on this implementation.
There was a problem hiding this comment.
The class name must match de filename. And also the #ifndef guards.
I would recommend using a namespace to avoid clashing.
| virtual void read() { } | ||
| virtual void write() { } |
There was a problem hiding this comment.
This should be = 0? I can't find the implementation in other files, only the specialization. It should be pure virtual.
| { | ||
| } | ||
|
|
||
| virtual void read() { } |
There was a problem hiding this comment.
I think read will not modify the state of the object right? Should it be const?
| virtual void read() { } | ||
| virtual void write() { } | ||
|
|
||
| virtual ~GenericFile() = default; |
There was a problem hiding this comment.
Since you defaulted a destructor, AFAIK, the move operations are by default deleted. I think we should define the move operations:
GenericFile(GenericFile&&) = default;
GenericFile& operator=(GenericFile&&) = default;
| repo.enabled = enabled; | ||
| repo.gpgcheck = gpgcheck; | ||
| repo.gpgkey = gpgkey; | ||
| repositories.push_back(std::move(repo)); |
| } | ||
|
|
||
| [[nodiscard]] const std::vector<ELCloneRepo>& | ||
| ELRepoFile::getRepositoriesConst() const |
There was a problem hiding this comment.
Having the qualifier in the method name is a very bad approach.
9d0b02b to
ecb7a02
Compare
viniciusferrao
left a comment
There was a problem hiding this comment.
That's a big one. There's some comments that were probably not from this PR originally, we should mark those as a BUG to be fixed later.
For everything else can you evaluate @dhilst? Don't be economic when naming things, you can abuse it. Avoids guessing. The compiler will optimize anyway.
| #ifndef CLOYSTER_CONCEPTS_H | ||
| #define CLOYSTER_CONCEPTS_H |
There was a problem hiding this comment.
| #ifndef CLOYSTER_CONCEPTS_H | |
| #define CLOYSTER_CONCEPTS_H | |
| /* | |
| * Copyright 2025 Vinícius Ferrão <vinicius@ferrao.net.br> | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| #ifndef CLOYSTERHPC_CONCEPTS_H_ | |
| #define CLOYSTERHPC_CONCEPTS_H_ |
| * @brief IsParser<P, T> means: P can parse and unparse Ts from streams. The | ||
| * parsers are allowed to throw exceptions | ||
| */ | ||
| template <typename Parser_, typename I, typename O> |
There was a problem hiding this comment.
I is input and O is output? If yes I think we should use more descriptive names.
| * The parsers are not allowed to throw exceptions, it must return errors of | ||
| * type E | ||
| */ | ||
| template <typename Parser_, typename T, typename E> |
There was a problem hiding this comment.
What is T and E?
Also the naming with _ at the end, is that a convention?
There was a problem hiding this comment.
I removed this concept, anyway T is the parsed type and E the error type
|
|
||
| } | ||
|
|
||
| #endif // CLOYSTER_CONCEPTS_H |
There was a problem hiding this comment.
| #endif // CLOYSTER_CONCEPTS_H | |
| #endif // CLOYSTERHPC_CONCEPTS_H_ |
| { "AlmaLinux-8.8-x86_64-dvd.iso", "OracleLinux-R8-U8-x86_64-dvd.iso", | ||
| "rhel-8.8-x86_64-dvd.iso", "Rocky-8.8-x86_64-dvd1.iso", | ||
| "Rocky-9.5-x86_64-dvd.iso" }) }; |
There was a problem hiding this comment.
I think this should be better organized or generated since it's a pattern and not hardcoded like that. I know it's a problem from legacy code. But maybe this should be removed.
| case OS::Platform::el8: | ||
| case OS::Platform::el9: | ||
| case OS::Platform::el10: | ||
| return "/etc/yum.repos.d/cloyster.repo"; |
There was a problem hiding this comment.
I think this will explicit return as const char*. Should we force it to return an std::string?
| std::vector<std::string> dependencies; | ||
|
|
||
| std::size_t version = osinfo.getMajorVersion(); | ||
| std::string powertools = "powertools"; |
There was a problem hiding this comment.
That logic is not good at all.
| void RepoManager::enable(const std::string& repoid) | ||
| { | ||
| if (cloyster::dryRun) { | ||
| LOG_WARN("Dry Run: Would enable repository {}", repoid); |
There was a problem hiding this comment.
Should all dry run statements be LOG_INFO instead? It's not a warning.
There was a problem hiding this comment.
This is because I standardized all the dry-run logging messages to be warning and have Dry Run: as the prefix, for the sake of consistency
| return std::vector<std::string>( | ||
| { "-beegfs", "-elrepo", "-epel", "-openhpc", | ||
| "-openhpc-updates", "-rpmfusion-free-updates" }) |
There was a problem hiding this comment.
It is not. These are the repositories enabled by default in EL distros, it comes from old/refactored code. Is it wrong?
* Add script to build rpms * Fix debug build * Link against host Glibmm using pkg-config * Extract glibmm from diskImage, move it to files.cpp --------- Co-authored-by: Daniel Hilst <daniel@versatushpc.com.br>
|
|
@viniciusferrao Changing the smart pointers in the postfix (for the client bus) requires refactoring and changing the IService interface. Replacing shared with unique pointers in the presenter requires a major refactoring too because these classes should not have ownership of these objects I will address these problems in another PR |
* Adding OFED option and Cluster singleton with global getter * Add singleton class * Use Singleton<T> class for other singletons * Make all Dry Run message LOG_INFO * Remove print and test option * Implement DOCA kernel driver installation into the netboot image * Fix OFED installation in headnode * Fix review comments * Generalize testing and fix createHTTPRepo function * Remove CATTUS_... environment variables in favor of --force + --skip flags * Rename BaseRunner to IRunner for consistency * Wrap magic_enum lib * Remove package_manager in favor of IOSService interface * Deduplicate code * Run clang-format * Remove hwinfo, cloyster/hardware.h and tests The tests are breaking because of the refactoring, I'll redo the tests after I finish it * Remove inifile in favor of KeyFile * Removing old repository code * Add comments and FIXME * Use boost to parse options * Run clang-format * Decouple message bus from implementors * Fix test command handling * Fix warning in options.h * Restores runtime behavior after refactoring (WIP) * Replace boost::program_options with CLI11 * Implement repository sanity checking logic in repos.cpp * WIP generalizing repository addition * Restore testing code infra * Add test on the CI * Move singletons initalization to its own file * [WIP] Add libbacktrace to the dependencies * Decouple I/O from repository config classes to make them testable * Remove stacktrace attempt There is no libstdc++exp.a in Rocklinux repositories, stacktrace requires it. * Continuing the repositories core logic implementation * Remove old repository installation for xCAT and OFED * Add test files * Add ScriptBuilder service * Update NFS with script builder * Refactor NFS to use ScriptBuilder for installation and image customization. * WIP Fixing repositories bugs after the revamp * Fixing image generation and bugs after revamp * Fix the tests --------- Co-authored-by: Daniel Hilst <daniel@versatushpc.com.br>
|
This and #95 were big refactoring, a new RPM was generated and sent for acceptance testing, there is no point into review currently as it is now



This is a HUGE refactoring adding some structure to the code base (namespace and folders) and removing old RepoManager code
RepoManagerover the repository type and the runner,cloyster::modelsandcloyster::servicesto start splitting the code according to the model-view-presenter architectureKeyFileimplementation hiding glibmm KeyFile (files.h/files.cpp)concepts.hheader for general conceptsCATTUS_SKIP_DISK_CHECKSUMenvironment to skip checksum of the ISO--test-conf-filefor testing KeyFile implementation against arbitrary files (it loads and prints the file)