Skip to content

Commit 3adcf53

Browse files
tonistiigicrazy-max
authored andcommitted
enable CDI by default for buildkitd
Access should be managed by entitlements checks Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 0f24e35 commit 3adcf53

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

cmd/buildkitd/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type OTELConfig struct {
7777
}
7878

7979
type CDIConfig struct {
80-
Enabled *bool `toml:"enabled"`
80+
Disabled *bool `toml:"disabled"`
8181
SpecDirs []string `toml:"specDirs"`
8282
}
8383

cmd/buildkitd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ func applyMainFlags(c *cli.Context, cfg *config.Config) error {
633633

634634
if c.IsSet("cdi-enabled") {
635635
cdiEnabled := c.Bool("cdi-enabled")
636-
cfg.CDI.Enabled = &cdiEnabled
636+
cfg.CDI.Disabled = &cdiEnabled
637637
}
638638
if c.IsSet("cdi-spec-dir") {
639639
cfg.CDI.SpecDirs = c.StringSlice("cdi-spec-dir")

cmd/buildkitd/main_oci_worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func ociWorkerInitializer(c *cli.Context, common workerInitializerOpt) ([]worker
324324
opt.BuildkitVersion = getBuildkitVersion()
325325
opt.RegistryHosts = hosts
326326

327-
if common.config.CDI.Enabled != nil && *common.config.CDI.Enabled {
327+
if common.config.CDI.Disabled == nil || !*common.config.CDI.Disabled {
328328
if len(common.config.CDI.SpecDirs) == 0 {
329329
return nil, errors.New("No CDI specification directories specified")
330330
}

control/control.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,9 @@ func toPBBuildkitVersion(in client.BuildkitVersion) *apitypes.BuildkitVersion {
687687
}
688688

689689
func toPBCDIDevices(manager *cdi.Cache) []*apitypes.CDIDevice {
690+
if manager == nil {
691+
return nil
692+
}
690693
devs := manager.ListDevices()
691694
out := make([]*apitypes.CDIDevice, 0, len(devs))
692695
for _, dev := range devs {

executor/oci/spec_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ func generateCDIOpts(ctx context.Context, devices []*pb.CDIDevice) ([]oci.SpecOp
178178
withStaticCDIRegistry := func() oci.SpecOpts {
179179
return func(ctx context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {
180180
_ = cdi.Configure(cdi.WithAutoRefresh(false))
181+
// TODO: this should use worker CDIManager
181182
if err := cdi.Refresh(); err != nil {
182183
// We don't consider registry refresh failure a fatal error.
183184
// For instance, a dynamically generated invalid CDI Spec file

0 commit comments

Comments
 (0)