-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sealer run-app supports concurrent run #1850
Conversation
8d9c883
to
7dc802d
Compare
Codecov ReportBase: 21.65% // Head: 21.12% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1850 +/- ##
==========================================
- Coverage 21.65% 21.12% -0.53%
==========================================
Files 72 74 +2
Lines 6586 6760 +174
==========================================
+ Hits 1426 1428 +2
- Misses 4974 5146 +172
Partials 186 186
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
7dc802d
to
9bbd571
Compare
clusterRootfs = i.infraDriver.GetClusterRootfsPath() | ||
ex = shell.NewLex('\\') | ||
cmds []string | ||
appPath = i.infraDriver.GetClusterRootfsPath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we can keep use clusterRootfs
.
And In my understanding, we may need a new appRootPath
variable, and it's going to be filepath.Join(clusterRootfs,"applications")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we should launch app in their own workspace, thats why i rename this value from "clusterRootfs" to "appRootPath". later we only need to update this func to support it directly.
imagecommon "github.com/sealerio/sealer/pkg/define/options" | ||
"github.com/sealerio/sealer/pkg/imageengine" | ||
v1 "github.com/sealerio/sealer/types/api/v1" | ||
osi "github.com/sealerio/sealer/utils/os" | ||
"github.com/sealerio/sealer/utils/os/fs" | ||
) | ||
|
||
const ( | ||
mountBaseDir = "/var/lib/sealer/data/mount" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it to. common/common.go file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mountBaseDir is internal used , so i dont move it to pubic common.
pkg/imagedistributor/mount.go
Outdated
if _, err := b.imageEngine.CreateWorkingContainer(&imagecommon.BuildRootfsOptions{ | ||
// make sure base mount Dir is existed. | ||
err := fs.FS.MkdirAll(filepath.Dir(mountDir)) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider the following syntax to avoid widening the scope of error
if err := fs.FS.MkdirAll(filepath.Dir(mountDir));err!=nil{}
pkg/imagedistributor/mount.go
Outdated
for _, info := range imageMountInfo { | ||
err := c.Mounter.Umount(info.MountDir) | ||
if err != nil { | ||
return fmt.Errorf("failed to umount %s:%v", info.MountDir, err) | ||
} | ||
} | ||
// delete all mounted images | ||
if err := fs.FS.RemoveAll(filepath.Join(mountBaseDir, formatImageName(imageName))); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about extracting a public method to return the mount root directory for the specified image name?
pkg/imagedistributor/mount.go
Outdated
@@ -125,3 +139,7 @@ func NewImageMounter(imageEngine imageengine.Interface, hostsPlatform map[v1.Pla | |||
c.Mounter = NewBuildAhMounter(imageEngine) | |||
return c, nil | |||
} | |||
|
|||
func formatImageName(name string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some unit tests and try to consider more scenarios
} | ||
|
||
func (d *SSHInfraDriver) GetClusterBasePath() string { | ||
return common.DefaultClusterBaseDir(d.clusterName) | ||
return filepath.Join(common.DefaultSealerDataDir, d.clusterName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -337,11 +338,11 @@ func (d *SSHInfraDriver) GetHostsPlatform(hosts []net.IP) (map[v1.Platform][]net | |||
} | |||
|
|||
func (d *SSHInfraDriver) GetClusterRootfsPath() string { | |||
return common.DefaultTheClusterRootfsDir(d.clusterName) | |||
return filepath.Join(common.DefaultSealerDataDir, d.clusterName, "rootfs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not keep it?
And I don't see a logical change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here i thought, the only way we get the cluster value such as "GetClusterRootfsPath" and the same kind parameters. not from common pkg directly .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then, should we delete the function common.DefaultTheClusterRootfsDir
?
pkg/cluster-runtime/apps.go
Outdated
applicationFile := common.GetDefaultApplicationFile() | ||
func (i AppInstaller) save(applicationFile string) error { | ||
f, err := os.OpenFile(applicationFile, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0600) | ||
defer func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use defer f.Close()
is OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golang lint will check the func return error ,to make sure each error was handled . so i use defer func()
} | ||
|
||
extensionList = append(extensionList, i.extension) | ||
content, err := json.Marshal(extensionList) | ||
content, err := json.Marshal(i.extension) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user defer func to unlock file locker here
pkg/cluster-runtime/apps.go
Outdated
if err != nil { | ||
return fmt.Errorf("failed to marshal image extension: %v", err) | ||
} | ||
|
||
return osutils.NewCommonWriter(applicationFile).WriteFile(content) | ||
_, err = f.Write(content) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unify use
if err:=func();err!=nil{}
please check the whole picture for yourself
pkg/cluster-runtime/apps.go
Outdated
if err != nil { | ||
return fmt.Errorf("failed to marshal image extension: %v", err) | ||
} | ||
|
||
return osutils.NewCommonWriter(applicationFile).WriteFile(content) | ||
_, err = f.Write(content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find these codes changed the existing logic and the old logic will append the extensions from the old applicationFile.
Cloud you please make a simple explanation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently ,it's also record app installations with append option, just separated from each installation record.
3cc21a1
to
996f159
Compare
add image name to mount dir path add flock to application.json
996f159
to
14d591a
Compare
add image name to mount dir path add flock to application.json
Describe what this PR does / why we need it
At present, our cluster image data is mixed with application image data and base image data, If we run multiple images at the same time, there will be conflicts.
all imagedata mount directory will under below directory:
/var/lib/sealer/data/mount/${imageName}/${platform}
all application imagedata rootfs directory will under below directory:
var/lib/sealer/data/${imageName}/rootfs/application/apps
all basefs imagedata directory will under below directory:
var/lib/sealer/data/${imageName}/rootfs
Does this pull request fix one issue?
Describe how you did it
Describe how to verify it
Special notes for reviews