From 6617549d294174971f0327da95f5ef5007dff57f Mon Sep 17 00:00:00 2001 From: cuisongliu Date: Fri, 29 Jul 2022 17:49:12 +0800 Subject: [PATCH] docs(main): fix miss mount in add nodes (#1429) Signed-off-by: cuisongliu --- pkg/apply/processor/scale.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/apply/processor/scale.go b/pkg/apply/processor/scale.go index 2dfe216be..5de377ae7 100644 --- a/pkg/apply/processor/scale.go +++ b/pkg/apply/processor/scale.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/labring/sealos/pkg/constants" + fileutil "github.com/labring/sealos/pkg/utils/file" "github.com/labring/sealos/pkg/utils/logger" "github.com/labring/sealos/pkg/utils/yaml" @@ -67,6 +68,7 @@ func (c *ScaleProcessor) GetPipeLine() ([]func(cluster *v2.Cluster) error, error todoList = append(todoList, c.JoinCheck, c.PreProcess, + c.PreProcessImage, c.RunConfig, c.MountRootfs, //s.GetPhasePluginFunc(plugin.PhasePreJoin), @@ -171,6 +173,28 @@ func (c *ScaleProcessor) PreProcess(cluster *v2.Cluster) error { return err } +func (c *ScaleProcessor) PreProcessImage(cluster *v2.Cluster) error { + logger.Info("Executing pipeline PreProcessImage in ScaleProcessor.") + + for i, mount := range cluster.Status.Mounts { + if mount.Type == v2.AppImage { + continue + } + dirs, _ := fileutil.GetAllSubDirs(mount.MountPoint) + if len(dirs) == 0 { + clusterManifest, err := c.ClusterManager.Create(mount.Name, mount.ImageName) + if err != nil { + return err + } + mount.Name = clusterManifest.Container + mount.MountPoint = clusterManifest.MountPoint + cluster.Status.Mounts[i] = mount + } + } + + return nil +} + func (c *ScaleProcessor) RunConfig(cluster *v2.Cluster) error { logger.Info("Executing pipeline RunConfig in ScaleProcessor.") eg, _ := errgroup.WithContext(context.Background())