Skip to content

Commit

Permalink
New API for parallel export
Browse files Browse the repository at this point in the history
Signed-off-by: Woa <[email protected]>
  • Loading branch information
ESWZY committed Sep 21, 2023
1 parent 78fb788 commit 0c8f4dc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/lifecycle/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func FlagPlanPath(planPath *string) {
flagSet.StringVar(planPath, "plan", *planPath, "path to plan.toml")
}

func FlagParallelExport(ParallelExport *bool) {

Check failure on line 111 in cmd/lifecycle/cli/flags.go

View workflow job for this annotation

GitHub Actions / test-linux-arm64

captLocal: `ParallelExport' should not be capitalized (gocritic)

Check failure on line 111 in cmd/lifecycle/cli/flags.go

View workflow job for this annotation

GitHub Actions / test-linux-amd64

captLocal: `ParallelExport' should not be capitalized (gocritic)

Check failure on line 111 in cmd/lifecycle/cli/flags.go

View workflow job for this annotation

GitHub Actions / test-windows

captLocal: `ParallelExport' should not be capitalized (gocritic)
flagSet.BoolVar(ParallelExport, "parallel", *ParallelExport, "export app image and cache image in parallel")
}

func FlagPlatformDir(platformDir *string) {
flagSet.StringVar(platformDir, "platform", *platformDir, "path to platform directory")
}
Expand Down
1 change: 1 addition & 0 deletions cmd/lifecycle/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (c *createCmd) DefineFlags() {
cli.FlagLauncherPath(&c.LauncherPath)
cli.FlagLayersDir(&c.LayersDir)
cli.FlagOrderPath(&c.OrderPath)
cli.FlagParallelExport(&c.ParallelExport)
cli.FlagPlatformDir(&c.PlatformDir)
cli.FlagPreviousImage(&c.PreviousImageRef)
cli.FlagProcessType(&c.DefaultProcessType)
Expand Down
6 changes: 6 additions & 0 deletions cmd/lifecycle/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (e *exportCmd) DefineFlags() {
cli.FlagLaunchCacheDir(&e.LaunchCacheDir)
cli.FlagLauncherPath(&e.LauncherPath)
cli.FlagLayersDir(&e.LayersDir)
cli.FlagParallelExport(&e.ParallelExport)
cli.FlagProcessType(&e.DefaultProcessType)
cli.FlagProjectMetadataPath(&e.ProjectMetadataPath)
cli.FlagReportPath(&e.ReportPath)
Expand Down Expand Up @@ -229,6 +230,11 @@ func (e *exportCmd) export(group buildpack.Group, cacheStore lifecycle.Cache, an
})
}()

// waiting here if parallel export is not enabled
if !e.ParallelExport {
exportWaitGroup.Wait()
}

exportWaitGroup.Add(1)
go func() {
defer exportWaitGroup.Done()
Expand Down
3 changes: 3 additions & 0 deletions platform/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ const (

// EnvKanikoCacheTTL is the amount of time to persist layers cached by kaniko during the `extend` phase.
EnvKanikoCacheTTL = "CNB_KANIKO_CACHE_TTL"

// EnvParallelExport is a flag used to instruct the lifecycle to export of application image and cache image in parallel, if true.
EnvParallelExport = "CNB_PARALLEL_EXPORT"
)

// DefaultKanikoCacheTTL is the default kaniko cache TTL (2 weeks).
Expand Down
3 changes: 3 additions & 0 deletions platform/lifecycle_inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type LifecycleInputs struct {
UID int
GID int
ForceRebase bool
ParallelExport bool
SkipLayers bool
UseDaemon bool
UseLayout bool
Expand Down Expand Up @@ -129,6 +130,7 @@ func NewLifecycleInputs(platformAPI *api.Version) *LifecycleInputs {
KanikoDir: "/kaniko",
LaunchCacheDir: os.Getenv(EnvLaunchCacheDir),
SkipLayers: skipLayers,
ParallelExport: boolEnv(EnvParallelExport),

// Images used by the lifecycle during the build

Expand All @@ -147,6 +149,7 @@ func NewLifecycleInputs(platformAPI *api.Version) *LifecycleInputs {
ProjectMetadataPath: envOrDefault(EnvProjectMetadataPath, filepath.Join(PlaceholderLayers, DefaultProjectMetadataFile)),

// Configuration options for rebasing

ForceRebase: boolEnv(EnvForceRebase),
}

Expand Down

0 comments on commit 0c8f4dc

Please sign in to comment.