Skip to content

Commit

Permalink
fix: add disk swap disable stage (#78)
Browse files Browse the repository at this point in the history
* fix: add log rotation and version in logging

Signed-off-by: Nianyu Shen <[email protected]>

* fix: add disk swap disable stage

Signed-off-by: Nianyu Shen <[email protected]>

---------

Signed-off-by: Nianyu Shen <[email protected]>
  • Loading branch information
nianyush authored Jan 29, 2025
1 parent cec1363 commit 3be437b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
12 changes: 12 additions & 0 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
},
}
}

0 comments on commit 3be437b

Please sign in to comment.