fix: add disk swap disable stage (#78)

* fix: add log rotation and version in logging

Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com>

* fix: add disk swap disable stage

Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com>

---------

Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com>
This commit is contained in:
Nianyu Shen 2025-01-29 12:17:49 -08:00 committed by GitHub
parent cec13638ac
commit 3be437bafe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View File

@ -22,18 +22,18 @@ func InitLogger(path string) {
}
logrus.SetOutput(logfile)
logrus.SetFormatter(KubeadmLogger{
logrus.SetFormatter(RKE2Logger{
Version: version.Version,
Formatter: logrus.StandardLogger().Formatter,
})
}
type KubeadmLogger struct {
type RKE2Logger struct {
Version string
Formatter logrus.Formatter
}
func (l KubeadmLogger) Format(entry *logrus.Entry) ([]byte, error) {
func (l RKE2Logger) Format(entry *logrus.Entry) ([]byte, error) {
entry.Data["version"] = l.Version
return l.Formatter.Format(entry)
}

View File

@ -22,6 +22,8 @@ func ClusterProvider(cluster clusterplugin.Cluster) yip.YipConfig {
var stages []yip.Stage
clusterRootPath := getClusterRootPath(cluster)
stages = append(stages, getSwapDisableStage())
rke2Config := types.RKE2Config{
Token: cluster.ClusterToken,
// RKE2 server listens on 9345 for node registration https://docs.rke2.io/install/quickstart/#3-configure-the-rke2-agent-service
@ -204,3 +206,13 @@ func getNodeCIDR() string {
func getClusterRootPath(cluster clusterplugin.Cluster) string {
return cluster.ProviderOptions[constants.ClusterRootPath]
}
func getSwapDisableStage() yip.Stage {
return yip.Stage{
Name: "disable disk swap",
Commands: []string{
"sed -i '/ swap / s/^\\(.*\\)$/#\\1/g' /etc/fstab",
"swapoff -a",
},
}
}