+
Skip to content

Redundant policy logic, incorrect logging #9217

Open
@mtrmac

Description

@mtrmac

cri-o/server/image_pull.go

Lines 138 to 159 in e738af1

sourceCtx, err := s.contextForNamespace(pullArgs.namespace)
if err != nil {
return storage.RegistryImageReference{}, fmt.Errorf("get context for namespace: %w", err)
}
log.Debugf(ctx, "Using pull policy path for image %s: %q", pullArgs.image, sourceCtx.SignaturePolicyPath)
sourceCtx.DockerLogMirrorChoice = true // Add info level log of the pull source
if pullArgs.credentials.Username != "" {
sourceCtx.DockerAuthConfig = &pullArgs.credentials
}
if pullArgs.namespace != "" {
policyPath := filepath.Join(s.config.SignaturePolicyDir, pullArgs.namespace+".json")
if _, err := os.Stat(policyPath); err == nil {
sourceCtx.SignaturePolicyPath = policyPath
} else if !os.IsNotExist(err) {
return storage.RegistryImageReference{}, fmt.Errorf("read policy path %s: %w", policyPath, err)
}
}
log.Debugf(ctx, "Using pull policy path for image %s: %s", pullArgs.image, sourceCtx.SignaturePolicyPath)
(via the called contextForNamespace) contains two duplicate copies of the logic that sets SignaturePolicyPath, and two duplicate debug logs of the chosen value (one of which is irrelevant).

Please clean that up.

Metadata

Metadata

Assignees

Labels

good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载