Without this, you get an error about the lack of package comments.
"package-comments: should have a package comment (revive)"
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
Without this, we are loosing features based on previous logrus
implementation. Now, we will log the stdout and stderr for
each call.
Next to this, we ensure the call of the log. methods will be
ready for the switch to get rid of logrus in the future.
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
Without this patch, we use WriterLevel, which spawns
go routines. As we do it at every call of the util commands,
we spawn goroutines at every check.
This is a problem as it leads to memory management issues.
This fixes it by using a buffer for stdout and stderr, then
logging the results after the command was executed.
To make sure the logging happened at the same place, I inlined
the code from utils. This results in duplicated the code.
However, this is not a big problem as:
- It makes the code more readable
- The implementation between checkers and rebooters _ARE_
different -- One definitely NEEDS privileges, while the other
does not... Which could lead to later improvements.
Removing a "utils" package is not really a big deal (it
is kinda a win in itself, as it is an anti-pattern), as the
test coverage was kept.
Partial-Fix: #1004Fixes: #1013
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
The main is doing flag validation through pflags, then
did further validation by involving the constructors.
With the recent refactor on the commit "Refactor constructors"
in this branch, we moved away from that pattern.
However, it means we reintroduced a log dependency into our
external API, and the external API now had extra validations
regardless of the type.
This is unnecessary, so I moved away from that pattern, and
moved back all the validation into a central place, internal,
which is only doing what kured would desire, without exposing
it to users. The users could still theoretically use the proper
constructors for each type, as they would validate just fine.
The only thing they would lose is the kured internal decision
of validation/precedence.
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
Without this, a bit of the validation is done in main, while
the rest is done in each constructor.
This fixes it by create a new global constructor in checkers/reboot to
solve all the cases and bubble up the errors.
I prefered keeping the old constructors, and calling them, this
way someone wanting to have a fork of the code could still create
directly the good checker/rebooter, without the arbitrary decisions
taken by the generic constructor.
However, kured is not a library, and was never intended to be
usable in forks, so we might want to reconsider is part 2 of the
refactor.
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
Without this, we have no validation of the data in command/signal
reboot.
This was not a problem in the first refactor, as the constructor
was a dummy one, without validation.
However, as we refactoed, we now have code in the root method
that is validation for the reboot command. This can now be
encompassed in the constructor.
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
Without this patch, the rebooter interface has data which is
not related to the rebooter interface. This should get removed
to make it easier to maintain.
The loss comes from the logging, which mentioned the node.
In order to not have a regression compared to [1], this ensures
that at least the node to be rebooted appears in the main.
[1]: https://github.com/kubereboot/kured/pull/134
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
Without this, the interface and the code to reboot is
a bit more complex than it should be.
We do not need setters and getters, as we are just
instanciating a single instance of a rebooter interface.
We create it based on user input, then pass the object
around. This should cleanup the code.
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
* feat: sentinel-command without nsenter by default
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* fix: no readonly mount
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* fix: mount at different folder
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* feat: add signal-reboot
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* feat: make signal configurable and add tests
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* build: rename job
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* cleanup: linter
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* build: also adjust signal manifest
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* test: add e2e-tests
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* fix: small code restructure
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
* fix: adjust version-range
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
---------
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>