Commit Graph

1173 Commits

Author SHA1 Message Date
Jean-Philippe Evrard
a5b3faaa05 Merge pull request #1019 from evrardjp/release_1.16.2
chore: update release
1.16.2
2024-11-07 22:03:43 +01:00
Jean-Philippe Evrard
3da7d5b8f4 chore: update release
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-11-07 19:06:12 +01:00
Jean-Philippe Evrard
ec0ba4f1bd Merge pull request #1018 from kubereboot/dependabot/github_actions/lycheeverse/lychee-action-2.1.0
build(deps): bump lycheeverse/lychee-action from 2.0.2 to 2.1.0
2024-11-07 18:51:15 +01:00
Jean-Philippe Evrard
3adeb5a384 Merge pull request #1016 from evrardjp/fix_small_memleak 2024-11-07 18:40:40 +01:00
dependabot[bot]
9b13117fd4 build(deps): bump lycheeverse/lychee-action from 2.0.2 to 2.1.0
Bumps [lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action) from 2.0.2 to 2.1.0.
- [Release notes](https://github.com/lycheeverse/lychee-action/releases)
- [Commits](7cd0af4c74...f81112d0d2)

---
updated-dependencies:
- dependency-name: lycheeverse/lychee-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-07 17:20:13 +00:00
Jean-Philippe Evrard
e370b0bd4a Remove reassignment in rebootasrequired loop
There is no need to continuously reallocate the check blockers.
They only need to be defined once.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-11-06 18:57:09 +01:00
Jean-Philippe Evrard
659e9fd5bf Merge pull request #1015 from evrardjp/fix_goroutine_leak
Fix goroutine leak
2024-11-06 18:54:15 +01:00
Jean-Philippe Evrard
94e73465ad Add stdout and stderr to log info
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>
2024-11-06 08:41:19 +01:00
Jean-Philippe Evrard
f81a302fa5 Merge pull request #1014 from evrardjp/improve_makefile
bootstrap-tools are required for kured bin
2024-11-05 23:18:59 +01:00
Jean-Philippe Evrard
f20a1ddd05 Fix goroutine leak
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: #1004
Fixes: #1013
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-11-05 22:11:13 +01:00
Jean-Philippe Evrard
7c3184239a bootstrap-tools are required for kured bin
kured linking needs the goreleaser command line, yet it does
not ensure it is present.

This fixes it by ensuring the bootstrap-tools are always
fetched first and used for all the make targets requiring them.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-11-05 17:24:42 +01:00
dependabot[bot]
9fbd0a2cc8 build(deps): bump actions/upload-artifact from 3.2.1.pre.node20 to 4.4.3 (#1012)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.2.1.pre.node20 to 4.4.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](c24449f33c...b4b15b8c7c)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-01 10:55:20 -07:00
dependabot[bot]
738564296a build(deps): bump ossf/scorecard-action from 2.3.1 to 2.4.0 (#1011)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.3.1 to 2.4.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](0864cf1902...62b2cac7ed)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-31 11:28:40 -07:00
dependabot[bot]
b47d43f268 build(deps): bump actions/upload-artifact (#1010)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 97a0fba1372883ab732affbe8f94b823f91727db to c24449f33cd45d4826c6702db7e49f7cdb9b551d.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](97a0fba137...c24449f33c)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-31 11:28:07 -07:00
Jean-Philippe Evrard
9ac37661d2 Merge pull request #1007 from kubereboot/Add-OpenSSF-Scorecard
Create scorecard.yml
2024-10-30 23:03:58 +01:00
Jean-Philippe Evrard
fc8d979da4 Merge pull request #1006 from evrardjp/update_go_mod
Be explicit about toolchain version
2024-10-30 23:03:31 +01:00
Jean-Philippe Evrard
030ff4525e Merge pull request #1005 from evrardjp/remove_security_exception
Remove security exception
2024-10-30 23:03:03 +01:00
Jean-Philippe Evrard
c62e67b27a Merge pull request #1009 from kubereboot/update-email
Update email address for Hidde Beydals
2024-10-28 21:23:33 +01:00
Hidde Beydals
2a2ee20b32 Update email address for Hidde Beydals
Signed-off-by: Hidde Beydals <hiddeco@users.noreply.github.com>
2024-10-28 21:22:30 +01:00
Jean-Philippe Evrard
e6c06078ff Create scorecard.yml
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-27 22:30:34 +01:00
Jean-Philippe Evrard
e110d575f0 Be explicit about toolchain version
As of Go 1.21, toolchain versions must use the 1.N.P syntax.
We were not explicit in our go.mod.

Without this, the openssf audit will fail to work.

This fixes it by doing a go get go@1.22.8 toolchain@1.22.8

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-27 22:26:19 +01:00
Jean-Philippe Evrard
f680091f02 Remove security exception
Now that we are building with latest 1.22, the exception should
not be used anymore.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-27 21:57:31 +01:00
Jean-Philippe Evrard
edb7460928 Merge pull request #997 from evrardjp/tidy_gomod
Cleanup gomod
2024-10-27 21:46:31 +01:00
Jean-Philippe Evrard
62f22e7060 Merge pull request #990 from evrardjp/first_refactors
Cleanup Part 1 - First refactors
2024-10-27 21:45:00 +01:00
dependabot[bot]
eba33a7149 build(deps): bump github.com/prometheus/common from 0.60.0 to 0.60.1 (#1003)
Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.60.0 to 0.60.1.
- [Release notes](https://github.com/prometheus/common/releases)
- [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md)
- [Commits](https://github.com/prometheus/common/compare/v0.60.0...v0.60.1)

---
updated-dependencies:
- dependency-name: github.com/prometheus/common
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-25 15:04:48 -07:00
Jean-Philippe Evrard
d29cc2ae68 Cleanup dockerfile (#996)
Without this, docker buildx will complain about the
following issues:
- "RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in
   FROM is redundant as this is the default behavior"
- "FromAsCasing: 'as' and 'FROM' keywords' casing do not match"

This fixes it.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-25 15:04:16 -07:00
Jean-Philippe Evrard
11acd1a86d Clarify features for e2e test (#995)
Without this, ppl might be wondering how to use e2e test,
especially on slower machines.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-25 15:03:13 -07:00
Jean-Philippe Evrard
3a116be09d Merge pull request #1002 from evrardjp/improve-release-doc 2024-10-23 13:11:50 +02:00
Jean-Philippe Evrard
e750f07de8 Improve release documentation
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-22 21:57:10 +02:00
Jean-Philippe Evrard
c77090d5fd chore: update release
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
1.16.1
2024-10-22 21:13:28 +02:00
Jean-Philippe Evrard
f559a95304 Make the internal blockers implementation internal
This at the same time, removes the alert public package.
Alert was only used inside prometheus blocker, so it allows
to simplify the code.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
73f00ce445 Make all the internal validations ... internal
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>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
626db87158 Add error to reboot interface
Without this, impossible to bubble up errors to main

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
67df0e935a Remove deprecated PollWithContext
Replaced with PollUntilContextTimeout.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
231888e58a Use RegexpValue in plags
This will remove double pointers, and be explicit about the
type we are using.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
d8b9e31ac9 Refactor constructors
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>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
104a745305 Make locks more generic
Implementation details of lock should not leak into the calling
methods.

Without this path, calls are a bit more complex
and error handling is harder to find.

This is a problem for long term maintenance, as it
is tougher to refactor the locks without impacting the main.

Decoupling the two (main usage of the lock, and the lock
themselves) will allow us to introduce other kinds of locks
easily.

I solve this by inlining into the daemonsetlock package:
- including all the methods for managing locks from the main.go
  functions. Those were mostly doing error handling
  where code became no-op by introducing multiple
  daemonsetlock types
- adding the lock release delay part of lock info

I also did not like the pattern include in Test method,
which added a reference to nodeMeta: It was not very clear
that Test was storing the current metadata of the node,
or was returning the current state. (Metadata here only means unschedulable).

The problem I saw was that the metadata was silently
mutated from a lock Test method, which was very not obvious.

Instead, I picked to explicitly return the lock data instead.

I also made it explicit that the Acquire lock method
is passing the node metadata as structured information,
rather than an interface{}. This is a bit more fragile
at runtime, but I prefer having very explicit errors if
the locks are incorrect, rather than having to deal with
unvalidated data.

For the lock release delay, it was part of the rebootasrequired
loop, where I believe it makes more sense to be part of the
Release method itself, for readability. Yet, it hides the
delay into the implementation detail, but it keeps the
reboot as required goroutine more readable.

Instead of passing the argument rebootDelay as parameter of the
rebootasrequired method, this refactor took creation of the lock
object in the main loop, close to all the variables, and then
pass the lock object to the rebootasrequired. This makes the
call for rebootasrequired more clear, and lock is now
encompassing everything needed to acquire, release, or get
info about the lock.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
aae5bb6ebb Raise the error levels for wrong flag
If the notification url configuration is known to be not working,
this should be raised as an error, not a warning.

Without this, it would be easy to miss a misconfiguration.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
a8132a2286 Remove viper/cobra deps
Without this, the main loop is in need of 3 functions to simply
parse flags and env variables (excluding input validation).

This is a bit more complex than it should, especially since
we only need to parse command line flags and env vars.

This fixes it by simply using pflags (which we were already
using) instead of pflags + viper + cobra (for which we
do not have any benefit), and removing all the methods
outside the mapping of env var with cli flag.

The main code is now far simpler: It handles the reading,
parsing, and returning in case of error.

As we do not bubble up errors from rebootasRequired yet,
this is good enough at this moment.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
42c4b8bc53 Revert to use a constructor again
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>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
3895a2f6d3 Remove nodeID from rebooter interface
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>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
f43ed1484e Cleanup checkers
Without this, the checkers are only shell calls: test -f
sentinelFile, or sentinelCommand.

This changes the behaviour of existing code to test file for
sentinelFile checker, and to keep the sentinel command as
a command.

However, to avoid having validation in the root loop, it moves
to use a constructor to cleanup the code.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00
Jean-Philippe Evrard
969926dfc3 Remove all mentions of .tmp (#999)
We moved to hack/bin in commit
608abc6e89.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-18 11:49:19 -07:00
Jean-Philippe Evrard
36e6c8b4d8 Rename variable
Without this, the variable name is hard to follow.

This fixes it by cleaning up the var name.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-18 00:53:38 +02:00
Jean-Philippe Evrard
00d8a524ab Move command line validations in pre function
Without this, validations are all over the place.
This moves some validations directly into the function, to
make the code simpler to read.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-18 00:53:38 +02:00
Jean-Philippe Evrard
eeedf203c3 Extract blockers
This will make it easier to manipulate main in the future.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-18 00:53:38 +02:00
Jean-Philippe Evrard
574065ff8a Add checker interface
This will be useful to refactor the checkers loop.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-18 00:53:38 +02:00
Jean-Philippe Evrard
3bfdd76f29 Extract privileged command wrapper into util
Without this, it makes the code a bit harder to read.

This fixes it by extracting the method.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-18 00:53:38 +02:00
Jean-Philippe Evrard
f34864758e Cleanup rebooter interface
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>
2024-10-18 00:53:38 +02:00
Jean-Philippe Evrard
7239c5460c Cleanup gomod
Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-18 00:40:34 +02:00