Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added mint
Binary file not shown.
4 changes: 3 additions & 1 deletion pkg/app/master/command/build/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ var BuildFlags = (append([]cli.Flag{
//Container Build Options
cflag(FlagImageBuildEngine),
cflag(FlagImageBuildArch),
command.Cflag(command.FlagPlatform),
cflag(FlagBuildFromDockerfile),
cflag(FlagDockerfileContext),
cflag(FlagTagFat),
Expand Down Expand Up @@ -866,7 +867,8 @@ var CLI = &cli.Command{
kubeOpts,
GetAppNodejsInspectOptions(ctx),
imageBuildEngine,
imageBuildArch)
imageBuildArch,
ctx.String(command.FlagPlatform))

return nil
},
Expand Down
5 changes: 4 additions & 1 deletion pkg/app/master/command/build/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func OnCommand(
appNodejsInspectOpts config.AppNodejsInspectOptions,
imageBuildEngine string,
imageBuildArch string,
platform string,
) {
printState := true
logger := log.WithFields(log.Fields{"app": appName, "cmd": Name})
Expand Down Expand Up @@ -284,6 +285,7 @@ func OnCommand(
execCmd: execCmd,
imageBuildEngine: imageBuildEngine,
imageBuildArch: imageBuildArch,
platform: platform,
})

vinfo := <-viChan
Expand Down Expand Up @@ -634,7 +636,8 @@ func OnCommand(
gparams.StatePath,
client,
logger,
cmdReport)
cmdReport,
platform)

loadExtraIncludePaths := func() {
if (includeLastImageLayers > 0) ||
Expand Down
3 changes: 2 additions & 1 deletion pkg/app/master/command/build/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func inspectFatImage(
client *dockerapi.Client,
logger *log.Entry,
cmdReport *report.SlimCommand,
platform string,
) (*image.Inspector, string, string, string) {
crtClient := dockercrtclient.New(client)
imageInspector, err := image.NewInspector(crtClient, targetRef)
Expand All @@ -58,7 +59,7 @@ func inspectFatImage(
"message": "trying to pull target image",
})

err := imageInspector.Pull(doShowPullLogs, dockerConfigPath, registryAccount, registrySecret)
err := imageInspector.Pull(doShowPullLogs, dockerConfigPath, registryAccount, registrySecret, platform)
if err != nil {
if strings.Contains(err.Error(), "not found") ||
strings.Contains(err.Error(), "API error (404)") {
Expand Down
4 changes: 3 additions & 1 deletion pkg/app/master/command/build/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type kubeHandleOptions struct {
execCmd string
imageBuildEngine string
imageBuildArch string
platform string
}

func (h *kubeHandler) Handle(
Expand Down Expand Up @@ -135,7 +136,8 @@ func (h *kubeHandler) Handle(
opts.StatePath,
h.dockerClient,
h.logger,
h.report)
h.report,
opts.platform)
workload.TargetContainer().Image = imageInspector.ImageRef

// 3. Patch and run the workload
Expand Down
8 changes: 8 additions & 0 deletions pkg/app/master/command/cliflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const (
FlagRegistryAccount = "registry-account"
FlagRegistrySecret = "registry-secret"
FlagShowPullLogs = "show-plogs"
FlagPlatform = "platform"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR also adds a root-level mint file marked as a binary in the diff; can you confirm this isn’t an accidentally-committed build artifact (it can bloat the repo and makes review/auditing harder)?

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.


//Compose-related flags
FlagComposeFile = "compose-file"
Expand Down Expand Up @@ -207,6 +208,7 @@ const (
FlagRegistryAccountUsage = "Target registry account used when pulling images from private registries"
FlagRegistrySecretUsage = "Target registry secret used when pulling images from private registries"
FlagShowPullLogsUsage = "Show image pull logs"
FlagPlatformUsage = "Target platform for the container image if it's a multi-architecture image (e.g., linux/arm64)"

//Compose-related flags
FlagComposeFileUsage = "Load container info from selected compose file(s)"
Expand Down Expand Up @@ -493,6 +495,12 @@ var CommonFlags = map[string]cli.Flag{
Usage: FlagShowPullLogsUsage,
EnvVars: []string{"DSLIM_PLOG"},
},
FlagPlatform: &cli.StringFlag{
Name: FlagPlatform,
Value: "",
Usage: FlagPlatformUsage,
EnvVars: []string{"DSLIM_PLATFORM"},
},
//
FlagComposeFile: &cli.StringSliceFlag{
Name: FlagComposeFile,
Expand Down
3 changes: 3 additions & 0 deletions pkg/app/master/command/debug/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type CommandParams struct {
UID int64
/// GID to use for the debugging sidecar container
GID int64
Platform string
/// run the debug sidecar as a privileged container
DoRunPrivileged bool
/// use the security context params from the target container with the debug sidecar container
Expand Down Expand Up @@ -170,6 +171,7 @@ var CLI = &cli.Command{
cflag(FlagRunPrivileged),
cflag(FlagSecurityContextFromTarget),
cflag(FlagFallbackToTargetUser),
command.Cflag(command.FlagPlatform),
command.Cflag(command.FlagTUI),
},
Action: func(ctx *cli.Context) error {
Expand Down Expand Up @@ -220,6 +222,7 @@ var CLI = &cli.Command{
ActionConnectSession: ctx.Bool(FlagConnectSession),
UID: ctx.Int64(FlagUID),
GID: ctx.Int64(FlagGID),
Platform: ctx.String(command.FlagPlatform),
DoRunPrivileged: ctx.Bool(FlagRunPrivileged),
UseSecurityContextFromTarget: ctx.Bool(FlagSecurityContextFromTarget),
DoFallbackToTargetUser: ctx.Bool(FlagFallbackToTargetUser),
Expand Down
6 changes: 5 additions & 1 deletion pkg/app/master/command/debug/handle_containerd_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ func HandleContainerdRuntime(
if err != nil {
logger.WithError(err).Trace("api.ImageService.Get")
logger.Debugf("api.Pull(%s)", commandParams.DebugContainerImage)
debugImage, err = api.Pull(ctx, commandParams.DebugContainerImage, containerd.WithPullUnpack)
pullOpts := []containerd.RemoteOpt{containerd.WithPullUnpack}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When --platform is set but the debug image already exists locally, this code skips api.Pull(...), so the local image may still reflect a different platform variant/unpack than requested.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

if commandParams.Platform != "" {
pullOpts = append(pullOpts, containerd.WithPlatform(commandParams.Platform))
}
debugImage, err = api.Pull(ctx, commandParams.DebugContainerImage, pullOpts...)
if err != nil {
logger.WithError(err).Error("api.Pull")
xc.FailOn(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/master/command/debug/handle_docker_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func HandleDockerRuntime(
noImage, err := imageInspector.NoImage()
errutil.FailOn(err)
if noImage {
err := imageInspector.Pull(true, "", "", "")
err := imageInspector.Pull(true, "", "", "", commandParams.Platform)
xc.FailOn(err)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/app/master/command/debug/handle_kubernetes_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func HandleKubernetesRuntime(
if err == nil {
var foundImage bool
if noImage {
if err := imageInspector.Pull(true, "", "", ""); err != nil {
if err := imageInspector.Pull(true, "", "", "", commandParams.Platform); err != nil {
logger.WithError(err).Trace("imageInspector.Pull")
}

Expand Down
1 change: 1 addition & 0 deletions pkg/app/master/command/debug/handle_podman_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ func podmanEnsureImage(logger *log.Entry, connCtx context.Context, image string)
if !exists {
logger.Tracef("Pulling image '%s'...", image)

//TODO: support Platform in podman pull
_, err = images.Pull(connCtx, image, nil)
if err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions pkg/app/master/command/profile/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var CLI = &cli.Command{
command.Cflag(command.FlagRegistryAccount),
command.Cflag(command.FlagRegistrySecret),
command.Cflag(command.FlagShowPullLogs),
command.Cflag(command.FlagPlatform),
//Compose support
command.Cflag(command.FlagComposeFile), //not used yet
command.Cflag(command.FlagTargetComposeSvc), //not used yet
Expand Down Expand Up @@ -119,6 +120,7 @@ var CLI = &cli.Command{
registryAccount := ctx.String(command.FlagRegistryAccount)
registrySecret := ctx.String(command.FlagRegistrySecret)
doShowPullLogs := ctx.Bool(command.FlagShowPullLogs)
platform := ctx.String(command.FlagPlatform)

doRmFileArtifacts := ctx.Bool(command.FlagRemoveFileArtifacts)
doCopyMetaArtifacts := ctx.String(command.FlagCopyMetaArtifacts)
Expand Down Expand Up @@ -293,6 +295,7 @@ var CLI = &cli.Command{
registryAccount,
registrySecret,
doShowPullLogs,
platform,
crOpts,
httpProbeOpts,
portBindings,
Expand Down
3 changes: 2 additions & 1 deletion pkg/app/master/command/profile/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func OnCommand(
registryAccount string,
registrySecret string,
doShowPullLogs bool,
platform string,
crOpts *config.ContainerRunOptions,
httpProbeOpts config.HTTPProbeOptions,
portBindings map[docker.Port][]docker.PortBinding,
Expand Down Expand Up @@ -174,7 +175,7 @@ func OnCommand(
"message": "trying to pull target image",
})

err := imageInspector.Pull(doShowPullLogs, dockerConfigPath, registryAccount, registrySecret)
err := imageInspector.Pull(doShowPullLogs, dockerConfigPath, registryAccount, registrySecret, platform)
errutil.FailOn(err)
} else {
xc.Out.Info("target.image.error",
Expand Down
3 changes: 3 additions & 0 deletions pkg/app/master/command/run/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type CommandParams struct {
RegistryAccount string
RegistrySecret string
DoShowPullLogs bool
Platform string
Entrypoint []string
Cmd []string
DoLiveLogs bool
Expand All @@ -41,6 +42,7 @@ func CommandFlagValues(ctx *cli.Context) (*CommandParams, error) {
RegistryAccount: ctx.String(command.FlagRegistryAccount),
RegistrySecret: ctx.String(command.FlagRegistrySecret),
DoShowPullLogs: ctx.Bool(command.FlagShowPullLogs),
Platform: ctx.String(command.FlagPlatform),
DoLiveLogs: ctx.Bool(FlagLiveLogs),
DoTerminal: ctx.Bool(FlagTerminal),
EnvVars: ctx.StringSlice(command.FlagEnv),
Expand Down Expand Up @@ -88,6 +90,7 @@ var CLI = &cli.Command{
command.Cflag(command.FlagRegistryAccount),
command.Cflag(command.FlagRegistrySecret),
command.Cflag(command.FlagShowPullLogs),
command.Cflag(command.FlagPlatform),
command.Cflag(command.FlagEntrypoint),
command.Cflag(command.FlagCmd),
cflag(FlagLiveLogs),
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/master/command/run/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func OnCommand(
"message": "trying to pull target image",
})

err := imageInspector.Pull(cparams.DoShowPullLogs, cparams.DockerConfigPath, cparams.RegistryAccount, cparams.RegistrySecret)
err := imageInspector.Pull(cparams.DoShowPullLogs, cparams.DockerConfigPath, cparams.RegistryAccount, cparams.RegistrySecret, cparams.Platform)
errutil.FailOn(err)
} else {
xc.Out.Info("target.image.error",
Expand Down
3 changes: 3 additions & 0 deletions pkg/app/master/command/xray/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var XRayFlags = []cli.Flag{
command.Cflag(command.FlagRegistryAccount),
command.Cflag(command.FlagRegistrySecret),
command.Cflag(command.FlagShowPullLogs),
command.Cflag(command.FlagPlatform),
cflag(FlagChanges),
cflag(FlagChangesOutput),
cflag(FlagLayer),
Expand Down Expand Up @@ -204,6 +205,7 @@ var CLI = &cli.Command{
registryAccount := ctx.String(command.FlagRegistryAccount)
registrySecret := ctx.String(command.FlagRegistrySecret)
doShowPullLogs := ctx.Bool(command.FlagShowPullLogs)
platform := ctx.String(command.FlagPlatform)

changes, err := parseChangeTypes(ctx.StringSlice(FlagChanges))
if err != nil {
Expand Down Expand Up @@ -350,6 +352,7 @@ var CLI = &cli.Command{
registryAccount,
registrySecret,
doShowPullLogs,
platform,
changes,
changesOutputs,
layers,
Expand Down
3 changes: 2 additions & 1 deletion pkg/app/master/command/xray/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func OnCommand(
registryAccount string,
registrySecret string,
doShowPullLogs bool,
platform string,
changes map[string]struct{},
changesOutputs map[string]struct{},
layers map[string]struct{},
Expand Down Expand Up @@ -257,7 +258,7 @@ func OnCommand(
"message": "trying to pull target image",
})

err := imageInspector.Pull(doShowPullLogs, dockerConfigPath, registryAccount, registrySecret)
err := imageInspector.Pull(doShowPullLogs, dockerConfigPath, registryAccount, registrySecret, platform)
if err != nil {
if strings.Contains(err.Error(), "not found") ||
strings.Contains(err.Error(), "API error (404)") {
Expand Down
3 changes: 2 additions & 1 deletion pkg/app/master/inspectors/image/image_inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (i *Inspector) NoImage() (bool, error) {
}

// Pull tries to download the target image
func (i *Inspector) Pull(showPullLog bool, dockerConfigPath, registryAccount, registrySecret string) error {
func (i *Inspector) Pull(showPullLog bool, dockerConfigPath, registryAccount, registrySecret, platform string) error {
var pullLog bytes.Buffer
var repo string
var tag string
Expand All @@ -108,6 +108,7 @@ func (i *Inspector) Pull(showPullLog bool, dockerConfigPath, registryAccount, re
input := crt.PullImageOptions{
Repository: repo,
Tag: tag,
Platform: platform,
}

if showPullLog {
Expand Down
1 change: 1 addition & 0 deletions pkg/crt/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type ImageHistory struct {
type PullImageOptions struct {
Repository string
Tag string
Platform string
OutputStream io.Writer
}

Expand Down
1 change: 1 addition & 0 deletions pkg/crt/docker/dockercrtclient/dockercrtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ func (ref *Instance) PullImage(opts crt.PullImageOptions, authConfig crt.AuthCon
input := docker.PullImageOptions{
Repository: opts.Repository,
Tag: opts.Tag,
Platform: opts.Platform,
}

if opts.OutputStream != nil {
Expand Down
Loading