Skip to content

Conversation

@tsujie
Copy link
Contributor

@tsujie tsujie commented Oct 4, 2024

pkg/app/master/command/build/image.go

Fixes-###

What

When I run slim build with --use-local-mounts=true and provide local state-path. Then the slim build will fail with error

cmd=build info=build.error status='optimized.image.build.error' error='no layers' 

Why

The reason is for local mounts, there is no files.tar file exits. Only the files folder exists. But the check is

dataDir := filepath.Join(imageInspector.ArtifactLocation, "files")
if fsutil.Exists(dataTar) && fsutil.IsDir(dataDir) {
  layerInfo := imagebuilder.LayerDataInfo{
	  Type:   imagebuilder.DirSource,
	  Source: dataDir,
	  Params: &imagebuilder.DataParams{
		  TargetPath: "/",
	  },
  }
  
  opts.Layers = append(opts.Layers, layerInfo)
  hasData = true
} else {
  logger.Info("WARNING - no data artifacts")
}

which will check if dataTar exists. In this case, it is false, so it will trigger the failure

How Tested

set --use-local-mounts=true and provide your local --state-path

…file

Signed-off-by: Jie Xu <jie.xu@image-metrics.com>
@tsujie tsujie force-pushed the feature/FixLocalArtifactLocation branch from 466223a to 9902c36 Compare October 4, 2024 22:36
@kcq
Copy link
Contributor

kcq commented Oct 4, 2024

thank you for the PR @tsujie

@kcq kcq merged commit c7c32c0 into mintoolkit:master Oct 4, 2024
@tsujie
Copy link
Contributor Author

tsujie commented Oct 5, 2024

@kcq I'm trying to integrate slim into bitbucket pipeline. But get errors

time="2024-10-04T02:37:13Z" level=error msg="dockerutil.CopyToVolume: dclient.CreateContainer() error = API error (403): authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectories"
time="2024-10-04T02:37:13Z" level=fatal msg="slim: failure" error="API error (403): authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectories"

So I try to build using local mount. But the sensor volume seems still needed.
Do you know how can I resolve that?
Thanks!

@kcq
Copy link
Contributor

kcq commented Oct 5, 2024

@tsujie would be good to double check the logic there to see if the volume creation logic can be conditional. another option to consider is to have a configurable local path when the volume is created, so the path from $BITBUCKET_CLONE_DIR is used. Probably the easiest thing to do is to move the main app and sensor executables to the $BITBUCKET_CLONE_DIR directory. You can also try experimenting with the global --state-path flag.

@tsujie
Copy link
Contributor Author

tsujie commented Oct 13, 2024

@kcq btw, we have figured out how to integrate slim into bitbucket pipeline. We can simply use bitbucket docker service
image: dind. Then we can just use mint (slim) the same as locally. Just need a self hosted build agent though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants