Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-36344: Add CIP relevant mirrors to sigstore attachement cfg #4449

Conversation

QiWang19
Copy link
Member

@QiWang19 QiWang19 commented Jul 2, 2024

Close: #4446
- What I did

- How to verify it

Cluster 4.17.0-0.ci.test-2024-07-08-173847 has default ICSP:

$ oc describe imagecontentsourcepolicy/image-policy
Name:         image-policy
Namespace:    
Labels:       <none>
Annotations:  <none>
API Version:  operator.openshift.io/v1alpha1
Kind:         ImageContentSourcePolicy
Metadata:
  Creation Timestamp:  2024-07-08T17:51:37Z
  Generation:          1
  Resource Version:    706
  UID:                 036f79f1-826c-459c-8adc-8b3cc0499801
Spec:
  Repository Digest Mirrors:
    Mirrors:
      quayio-pull-through-cache-us-east-2-ci.apps.ci.l2s4.p1.openshiftapps.com
    Source:  quay.io
Events:      <none>

Apply CIP:

apiVersion: config.openshift.io/v1alpha1
kind: ClusterImagePolicy
metadata:
  name: openshift
  annotations:
    kubernetes.io/description: Require Red Hat signatures for quay.io/openshift-release-dev/ocp-release container images.
    exclude.release.openshift.io/internal-openshift-hosted: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    release.openshift.io/feature-set: TechPreviewNoUpgrade
spec:
  scopes:
  - quay.io/openshift-release-dev/ocp-release
  policy:
    rootOfTrust:
      policyType: PublicKey
      publicKey:
        keyData: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUEzQzJlVGdJQUo3aGxveDdDSCtIcE1qdDEvbW5lYXcyejlHdE9NUmlSaEgya09ZalRadGVLSEtnWUJHcGViajRBcUpWYnVRaWJYZTZKYVFHQUFER0VOZXozTldsVXpCby9FUUEwaXJDRnN6dlhVbTE2cWFZMG8zOUZpbWpsVVovaG1VNVljSHhxMzR2OTh4bGtRbUVxekowR0VJMzNtWTFMbWFEM3ZhYmd3WWcwb3lzSTk1Z1V1Tk81TmdZUHA4WDREaFNoSmtyVEl5dDJLTEhYWW5BMExzOEJlbG9PWVJlTnJhZmxKRHNzaE5VRFh4MDJhQVZSd2RjMXhJUDArRTlZaTY1ZE4zKzlReVhEOUZ6K3MrTDNjZzh3bDdZd3ZZb1Z2NDhndklmTHlJbjJUaHY2Uzk2R0V6bXBoazRjWDBIeitnUkdocWpyajU4U2hSZzlteitrcnVhR0VuVGcyS3BWR0gzd3I4Z09UdUFZMmtqMnY1YWhnZWt4V1pFN05vazNiNTBKNEpnYXlpSnVSL2R0cmFQMWVMMjlFMG52akdsMXptUXlGNlZnNGdIVXYwaktrcnJ2QUQ4c1dNY2NBS00zbXNXU01uRVpOTnljTTRITlNobGNReG5xU1lFSXR6MGZjajdYamtKbnAxME51Z2lVWlNLeVNXOHc0R3hTaFNraGRGbzByRDlkVElRZkJoeS91ZHRQWUkrK2VoK243QTV2UVV4Wk5BTmZqOUhRbC81Z3lFbFV6TTJOekJ2RHpHellSNVdVZEVEaDlJQ1I4ZlFpMVIxNUtZU0h2Tlc3RW5ucDdZT2d5dmtoSkdwRU5PQkF3c1pLMUhhMkJZYXZMMk05NDJzSkhxOUQ1eEsrZyszQU81eXp6V2NqaUFDMWU4RURPcUVpY01Ud05LOENBd0VBQVE9PQotLS0tLUVORCBQVUJMSUMgS0VZLS0tLS0K

Pull from mirror, check the log: Looking for sigstore attachments

sh-5.1# crictl pull quay.io/openshift-release-dev/ocp-release@sha256:c17d4489c1b283ee71c76dda559e66a546e16b208a57eb156ef38fb30098903a
E0708 19:53:07.692735    7828 remote_image.go:180] "PullImage from image service failed" err="rpc error: code = Unknown desc = SignatureValidationFailed: Source image rejected: Signature for identity quay.io/openshift-release-dev/ocp-release is not accepted" image="quay.io/openshift-release-dev/ocp-release@sha256:c17d4489c1b283ee71c76dda559e66a546e16b208a57eb156ef38fb30098903a"
FATA[0000] pulling image: SignatureValidationFailed: Source image rejected: Signature for identity quay.io/openshift-release-dev/ocp-release is not accepted 
sh-5.1# journalctl -u crio --since "1 minute ago"
Jul 08 19:53:07 ip-10-0-90-119 crio[2147]: time="2024-07-08 19:53:07.124789735Z" level=debug msg="Looking for sigstore attachments in quayio-pull-through-cache-us-east-2-ci.apps.ci.l2s4.p1.openshiftapps.com/openshift-release-dev/ocp-release:sha256-c17d...

- Description for the changelog

Add icsp/idms/itms mirrors of CIP scope to /etc/containers/registries.d, so sigstore attachment will be used during the image pull and verification.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 2, 2024
Copy link
Contributor

openshift-ci bot commented Jul 2, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@QiWang19 QiWang19 force-pushed the add-mirrors-to-sigstore-regisconf branch 2 times, most recently from f771a5e to 7a610ae Compare July 3, 2024 15:54
@QiWang19 QiWang19 changed the title WIP: add CIP relevant mirrors to sigstore attachement cfg WIP: OCPBUGS-36344: Add CIP relevant mirrors to sigstore attachement cfg Jul 3, 2024
@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 3, 2024
@openshift-ci-robot
Copy link
Contributor

@QiWang19: This pull request references Jira Issue OCPBUGS-36344, which is invalid:

  • expected the bug to target the "4.17.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

- What I did

- How to verify it

- Description for the changelog

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@QiWang19
Copy link
Member Author

QiWang19 commented Jul 3, 2024

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 3, 2024
@openshift-ci-robot
Copy link
Contributor

@QiWang19: This pull request references Jira Issue OCPBUGS-36344, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.17.0) matches configured target version for branch (4.17.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (schoudha@redhat.com), skipping review request.

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@QiWang19
Copy link
Member Author

QiWang19 commented Jul 3, 2024

/test all

@QiWang19 QiWang19 changed the title WIP: OCPBUGS-36344: Add CIP relevant mirrors to sigstore attachement cfg OCPBUGS-36344: Add CIP relevant mirrors to sigstore attachement cfg Jul 3, 2024
@QiWang19 QiWang19 marked this pull request as ready for review July 3, 2024 16:03
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 3, 2024
@openshift-ci-robot
Copy link
Contributor

@QiWang19: This pull request references Jira Issue OCPBUGS-36344, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.17.0) matches configured target version for branch (4.17.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (schoudha@redhat.com), skipping review request.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Close: #4446
- What I did

- How to verify it

- Description for the changelog

Add icsp/idms/itms mirrors of CIP scope to /etc/containers/registries.d, so sigstore attachment will be used during the image pull and verification.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@QiWang19
Copy link
Member Author

QiWang19 commented Jul 3, 2024

@mtrmac could you review?

@QiWang19 QiWang19 force-pushed the add-mirrors-to-sigstore-regisconf branch from 7a610ae to 60fd9c8 Compare July 3, 2024 17:02
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Overall it seems to me that doing this with the ICSP/ITMS/IDMS data is harder than it needs to be; instead, the code could consume the already-generated registries.conf, or maybe this could be built along with registries.conf in runtime-utils/pkg/registries.

Something vaguely like:

registries.EditRegistriesConf(config, …)
tmpFile := marshalAndWriteTempFile(config)
systemContext := types.SystemContext{SystemRegistriesConfPath: tmpFile, SystemRegistriesConfDirPath: "/dev/null"}
attachmentScopes := Set[string].New()
for policyScope in allPolicyScopesFromClusterImagePolicy{
    parent := sysregistriesv2.FindRegistry(systemContext, policyScope)
    addPhysicalLocations(attachmentScopes, parent, policyScope)
    for reg in config.Registries {
        scope = reg.Prefix ?? reg.Location
        if registries.ScopeIsNestedInsideScope(scope, policyScope) && scope != policyScope {
            nested := sysregistriesv2.FindRegistry(systemContext, scope) // Finds (a preprocessed version of) reg
            addPhysicalLocations(attachmentScopes, nested, scope)
    }
}
createRegistriesD(attachmentScopes)

// ---
func addPhysicalLocations(dest *Set[string], reg Registry, scope string) {
    // Ugly… we need to look up endpoints for a taged and a digested reference, to account for ITMS/IDMS
    endpoints := reg.PullSourcesFromReference(scope + ":tag")
    endpoints += reg.PullSourcesFromReference(scope + "@sha256:aaaa…")
    dest.Add(endpoints)
}

There are various ugly parts in there, admittedly, maybe c/image should gain a few more APIs (“load data from in-memory config”, “return all endpoints ignoring tag/digest restrictions”, …)

pkg/controller/container-runtime-config/helpers.go Outdated Show resolved Hide resolved
pkg/controller/container-runtime-config/helpers.go Outdated Show resolved Hide resolved
pkg/controller/container-runtime-config/helpers.go Outdated Show resolved Hide resolved
@mtrmac
Copy link
Contributor

mtrmac commented Jul 3, 2024

Arguably, it might not be strictly necessary to be precise in the use-sigstore-attachments configuration, the performance impact of enabling that unnecessarily is a few HTTP round-trips per image. OTOH it does add some interoperability risk — if we don’t correctly recognize the registry’s response as “sigstore image not found”, that can cause the whole pull to fail.

So, I think, at the very least, it should not be hard-coded enabled via default-docker, at least for now; using somewhat wider scopes within a registry which is used to fetch sigstore-signed images is not ideal but might be acceptable if we were under time pressure.

@QiWang19 QiWang19 force-pushed the add-mirrors-to-sigstore-regisconf branch 2 times, most recently from 4f979d0 to 60d9968 Compare July 8, 2024 19:25
@QiWang19
Copy link
Member Author

QiWang19 commented Jul 8, 2024

@mtrmac Could you review?
I think we can move the code to runtime-utils/pkg/registries in the follow-up PRs since we are under time pressure. What do you think?

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

A fairly brief skim so that I’m not blocking progress; I didn’t read the tests, I’ll try to do that tomorrow.

if registriesTOML == nil {
continue
}
parentReg, err := sysregistriesv2.FindRegistry(&types.SystemContext{SystemRegistriesConfPath: tmpFile.Name()}, policyScope)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should set SystemRegistriesConfDirPath to something non-existent or not-a-directory, so that the controller doesn’t read current configuration of the node/container where it is currently running.

(In both places, ideally by sharing the SystemContext)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the explanation.

registriesDockerConfig[scope] = sigstoreAttachment

for policyScope := range clusterScopePolicies {
registriesDockerConfig[policyScope] = sigstoreAttachment
Copy link
Contributor

Choose a reason for hiding this comment

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

(Non-blocking: The entry for the primary repo is not necessary if NeverContactSource … but it also doesn’t really hurt; and otherwise we would need to special-case the “no configuration for registry” code path, i.e. this is a bit simpler than being 100% precise.)

scope = strings.Replace(scope, "*", dummyPrefix, 1)
}

scopeRef, err := reference.Parse(scope)
Copy link
Contributor

@mtrmac mtrmac Jul 8, 2024

Choose a reason for hiding this comment

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

[As a general rule, prefer ParseNormalizedNamed. It shouldn’t make a difference for valid scopes, … but do we actually validate that? IsValidRegistriesConfScope seems rather loose, and I’m not sure that there is any other location validating scopes more strictly.

I’m … worried what happens in the “scope == host name” case — AFAICS reference.Parse turns that into "[nothing]/$input". But it might work well enough.

OTOH with ParseNormalizedNamed, the dummyPath part would really have to happen before this parsing. See elsewhere.]

Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought, ParseNormalizedNamed("docker.io/library") would produce an unwanted result (or we would have to work around that even more); reference.Parse() is really better here.

Comment on lines 1029 to 1043
if digestRef, digested := scopeRef.(reference.Digested); digested {
namedRef, err := reference.ParseNamed(digestRef.String())
if err != nil {
return fmt.Errorf("error parsing scope digested reference %s: %w", digestRef.String(), err)
}
scope = reference.TrimNamed(namedRef).String()

}
if tagRef, tagged := scopeRef.(reference.Tagged); tagged {
namedRef, err := reference.ParseNamed(tagRef.String())
if err != nil {
return fmt.Errorf("error parsing scope tagged reference %s: %w", tagRef.String(), err)
}
scope = reference.TrimNamed(namedRef).String()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be just scope = scopeRef.Name(), or scopeRef = reference.TrimNamed(scopeRef), without specifically checking for tagged/digested.

scope = reference.TrimNamed(namedRef).String()
}
if !strings.Contains(scope, "/") {
scope += dummyPath
Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh… I didn’t realize there’s this corner case.

It’s safe to do because we have already looked up reg, but, AFAICS, if we add dummyPath here, we must also strip it from the returned endpoints.

Copy link
Contributor

Choose a reason for hiding this comment

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

… or, alternatively, unconditionally add dummyPath, and unconditionally remove it. Either way, ugly…

Comment on lines 1048 to 1053
digestRef, err := reference.ParseNamed(scope + dummyDigest)
if err != nil {
return fmt.Errorf("error parsing digest name for scope %s: %w", scope, err)
}
tagRef, err := reference.ParseNamed(scope + dummyTag)
if err != nil {
return fmt.Errorf("error parsing tag name for scope %s: %w", scope, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

(Non-blocking? This does work, but it does a bit more parsing than necessary. I think:

// dummyPrefix
if !strings.Contains(scope, "/") { // implies no tag and no digest, so this should be safe
   scope += dummyPath
   addedDummy = true
}
repo := reference.ParseNormalizedNamed(scope).TrimNamed()
digestRef = reference.WithDigest(repo, digest.Parse(dummyDigest))
tagRef = reference.WithTag(repo, dummyTag)

should work.

Comment on lines 1065 to 1074
endpoint := s.Endpoint.Location
if endpoint == "" {
endpoint = reg.Prefix
}
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICS this should be strings.TrimSuffix(s.Reference.Name(), dummyPathIfUsed); s.Endpoint is the “root” of the mirror, not the final remapped repo (consider an original scope of example.com/foo/bar, and a mirror defined for example.com/foo)

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

A more complete review: the two stand-outs are not setting SystemRegistriesConfDirPath and the Endpoint vs. Reference difference; the rest is mostly cosmetic.

If we absolutely had to, I’d be fine with merging as is and fixing that shortly after, e.g. in the immediately following sprint.

`docker:
'*.example.com':
use-sigstore-attachments: true
a-a1.mirror/a1:
Copy link
Contributor

Choose a reason for hiding this comment

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

a.com/a1/a2 is mirrored to a-a1.mirror/a2/a2, so that should be the scope. (See Reference vs. Endpoint in the previous review brach.)

`docker:
'*.example.com':
use-sigstore-attachments: true
'*.scope':
Copy link
Contributor

Choose a reason for hiding this comment

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

I don’t think this should be added (probably Endpoint vs. Reference?)

use-sigstore-attachments: true
'*.scope':
use-sigstore-attachments: true
'*.x.example.com':
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn’t hurt but also doesn’t need to be added — *.x.example.com is a subset of *.example.com

use-sigstore-attachments: true
a.com/a1/a2@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
use-sigstore-attachments: true
a.example.com:
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn’t hurt but doesn’t need to be added.

pkg/controller/container-runtime-config/helpers_test.go Outdated Show resolved Hide resolved
pkg/controller/container-runtime-config/helpers_test.go Outdated Show resolved Hide resolved
@QiWang19 QiWang19 force-pushed the add-mirrors-to-sigstore-regisconf branch 2 times, most recently from 855ca0d to 78f043b Compare July 9, 2024 20:37
Comment on lines 1063 to 1074
if hasWildcard {
if endpoint == strings.Replace(originalScope, "*", dummyPrefix, 1) {
continue
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@mtrmac Could you review this? We also need to add a check for dummyPrefix.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I’m afraid that my suggestion to use the c/image matching code has not been simpler — certainly not much simpler.)


To be explicit, the situation is a config entry with

  • prefix: *.example.com
  • location not set — OCP never does that for wild-carded scopes
  • and perhaps some mirrors, perhaps not, e.g. this entry might exist because there was an “insecure” bool set

And in that case the source reference is returned as is.

Here, unlike the added dummyPath, I’m worried about collisions with user-defined names (e.g. a mirroring setup from *.example.com to matched.example.com). I don’t think just a string comparison can resolve that.

It seems to me that this needs a condition && s.Endpoint.Location == "" to rule out this case: mirror endpoints must, by definition, have a mirror location. So if we have Location set, the host name was user-supplied; if Location is unset, the host name comes from dummyPrefix.

(Alternatively, I think the Location == "" check could be the only condition here, but then all primary endpoints would be ruled out and would have to be added at the top level. That would actually match the addScopeMirrorsSigstoreRegistriesdConfig function name a bit better — it would be adding only mirrors, and that would be good enough for currently OCP-generated configs, OTOH it would be less correct for processing registries.conf in general, because top-level redirection (`prefix: "logical"; location: "actualServer") would not be handled. I think we can handle top-level redirection here “for free”, so it’s better to do so than to risk future surprises.)

Please make sure there’s a unit test for this situation, and document what the situation and what the condition is checking for. (Something vaguely like “if we had to add a dummyPrefix to process a wildcard Registry entry, we only want to configure the mirror endpoints, if any; not to add a new entry for exactly dummyPrefix+originalScope”).

Also, this code would now depend on the caller unconditionally configuring attachments for registriesDockerConfig[policyScope] — that also seems worth having a comment.

scope = reg.Prefix
}
if runtimeutils.ScopeIsNestedInsideScope(scope, policyScope) && scope != policyScope {
nestedReg, err := sysregistriesv2.FindRegistry(&types.SystemContext{SystemRegistriesConfPath: tmpFile.Name()}, scope)
Copy link
Contributor

Choose a reason for hiding this comment

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

This place also needs updating with SystemRegistriesConfDirPath.

(Please create a single SystemContext variable to share that.)

return fmt.Errorf("error parsing scope %s: %w", scope, err)
}

repo := reference.TrimNamed(scopeRef.(reference.Named))
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking: This cast probably can’t fail, but double-checking might be easier than worrying about crashes.

Comment on lines 1401 to 1402
require.Len(t, gotRegistriesCfg.Docker, len(tc.expectedSigstoreRegistriesConfigScopes))
for _, scope := range tc.expectedSigstoreRegistriesConfigScopes {
Copy link
Contributor

Choose a reason for hiding this comment

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

assert.ElementsMatch(…, expected, maps.Keys(gotRegistriesCfg.Docker)) would check not just a subset relationship, but equality.

@QiWang19 QiWang19 force-pushed the add-mirrors-to-sigstore-regisconf branch 2 times, most recently from 21e2187 to f1c20bd Compare July 10, 2024 20:17
Spec: apicfgv1.ImageDigestMirrorSetSpec{
ImageDigestMirrors: []apicfgv1.ImageDigestMirrors{
{Source: "a.example.com", Mirrors: []apicfgv1.ImageMirror{"a-example.mirror"}},
{Source: "*.x.example.com", Mirrors: []apicfgv1.ImageMirror{"matched.example.mirror", "star-x.example.mirror"}},
Copy link
Member Author

Choose a reason for hiding this comment

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

@mtrmac PTAL. Test cases for #4449 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks.

Also a test for policy scope foo.example.com/ns/repo vs *.example.com -> our.mirror/example (expected scopes foo.example.com/ns/repo. our.mirror/example/ns/repo) might be a interesting because it might be closer to real-world configurations (with fairly coarse mirror maps but fairly small policy scopes); I don’t expect it would change code coverage…

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Implementation LGTM

sigstoreAttachment = dockerConfig{
UseSigstoreAttachments: true,
}
sysContext = &types.SystemContext{
Copy link
Contributor

Choose a reason for hiding this comment

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

(This is only used on the registriesTOML != nil path, so it can be initialized there. A context with SystemRegistriesConfPath set but SystemRegistriesConfPath does not make all that much sense. But this works fine as is.)

Add icsp/idms/itms mirrors of CIP scope to /etc/containers/registries.d, so sigstore attachment will be used during the image pull and verification.

Signed-off-by: Qi Wang <qiwan@redhat.com>
@QiWang19 QiWang19 force-pushed the add-mirrors-to-sigstore-regisconf branch from f1c20bd to 861d9af Compare July 10, 2024 21:19
@mtrmac
Copy link
Contributor

mtrmac commented Jul 10, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2024
@mtrmac
Copy link
Contributor

mtrmac commented Jul 10, 2024

The unit test failure seems not to be obviously related, but I didn’t investigate beyond reading the backtrace.

@QiWang19
Copy link
Member Author

/test unit

@QiWang19
Copy link
Member Author

/assign @saschagrunert
Could you approve?

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

/retest
/lgtm

Copy link
Contributor

openshift-ci bot commented Jul 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mtrmac, QiWang19, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 11, 2024
Copy link
Contributor

openshift-ci bot commented Jul 11, 2024

@QiWang19: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-op-techpreview 861d9af link false /test e2e-gcp-op-techpreview

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 35ce1c1 into openshift:master Jul 11, 2024
16 of 17 checks passed
@openshift-ci-robot
Copy link
Contributor

@QiWang19: Jira Issue OCPBUGS-36344: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-36344 has been moved to the MODIFIED state.

In response to this:

Close: #4446
- What I did

- How to verify it

Cluster 4.17.0-0.ci.test-2024-07-08-173847 has default ICSP:

$ oc describe imagecontentsourcepolicy/image-policy
Name:         image-policy
Namespace:    
Labels:       <none>
Annotations:  <none>
API Version:  operator.openshift.io/v1alpha1
Kind:         ImageContentSourcePolicy
Metadata:
 Creation Timestamp:  2024-07-08T17:51:37Z
 Generation:          1
 Resource Version:    706
 UID:                 036f79f1-826c-459c-8adc-8b3cc0499801
Spec:
 Repository Digest Mirrors:
   Mirrors:
     quayio-pull-through-cache-us-east-2-ci.apps.ci.l2s4.p1.openshiftapps.com
   Source:  quay.io
Events:      <none>

Apply CIP:

apiVersion: config.openshift.io/v1alpha1
kind: ClusterImagePolicy
metadata:
 name: openshift
 annotations:
   kubernetes.io/description: Require Red Hat signatures for quay.io/openshift-release-dev/ocp-release container images.
   exclude.release.openshift.io/internal-openshift-hosted: "true"
   include.release.openshift.io/self-managed-high-availability: "true"
   release.openshift.io/feature-set: TechPreviewNoUpgrade
spec:
 scopes:
 - quay.io/openshift-release-dev/ocp-release
 policy:
   rootOfTrust:
     policyType: PublicKey
     publicKey:
       keyData: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUEzQzJlVGdJQUo3aGxveDdDSCtIcE1qdDEvbW5lYXcyejlHdE9NUmlSaEgya09ZalRadGVLSEtnWUJHcGViajRBcUpWYnVRaWJYZTZKYVFHQUFER0VOZXozTldsVXpCby9FUUEwaXJDRnN6dlhVbTE2cWFZMG8zOUZpbWpsVVovaG1VNVljSHhxMzR2OTh4bGtRbUVxekowR0VJMzNtWTFMbWFEM3ZhYmd3WWcwb3lzSTk1Z1V1Tk81TmdZUHA4WDREaFNoSmtyVEl5dDJLTEhYWW5BMExzOEJlbG9PWVJlTnJhZmxKRHNzaE5VRFh4MDJhQVZSd2RjMXhJUDArRTlZaTY1ZE4zKzlReVhEOUZ6K3MrTDNjZzh3bDdZd3ZZb1Z2NDhndklmTHlJbjJUaHY2Uzk2R0V6bXBoazRjWDBIeitnUkdocWpyajU4U2hSZzlteitrcnVhR0VuVGcyS3BWR0gzd3I4Z09UdUFZMmtqMnY1YWhnZWt4V1pFN05vazNiNTBKNEpnYXlpSnVSL2R0cmFQMWVMMjlFMG52akdsMXptUXlGNlZnNGdIVXYwaktrcnJ2QUQ4c1dNY2NBS00zbXNXU01uRVpOTnljTTRITlNobGNReG5xU1lFSXR6MGZjajdYamtKbnAxME51Z2lVWlNLeVNXOHc0R3hTaFNraGRGbzByRDlkVElRZkJoeS91ZHRQWUkrK2VoK243QTV2UVV4Wk5BTmZqOUhRbC81Z3lFbFV6TTJOekJ2RHpHellSNVdVZEVEaDlJQ1I4ZlFpMVIxNUtZU0h2Tlc3RW5ucDdZT2d5dmtoSkdwRU5PQkF3c1pLMUhhMkJZYXZMMk05NDJzSkhxOUQ1eEsrZyszQU81eXp6V2NqaUFDMWU4RURPcUVpY01Ud05LOENBd0VBQVE9PQotLS0tLUVORCBQVUJMSUMgS0VZLS0tLS0K

Pull from mirror, check the log: Looking for sigstore attachments

sh-5.1# crictl pull quay.io/openshift-release-dev/ocp-release@sha256:c17d4489c1b283ee71c76dda559e66a546e16b208a57eb156ef38fb30098903a
E0708 19:53:07.692735    7828 remote_image.go:180] "PullImage from image service failed" err="rpc error: code = Unknown desc = SignatureValidationFailed: Source image rejected: Signature for identity quay.io/openshift-release-dev/ocp-release is not accepted" image="quay.io/openshift-release-dev/ocp-release@sha256:c17d4489c1b283ee71c76dda559e66a546e16b208a57eb156ef38fb30098903a"
FATA[0000] pulling image: SignatureValidationFailed: Source image rejected: Signature for identity quay.io/openshift-release-dev/ocp-release is not accepted 
sh-5.1# journalctl -u crio --since "1 minute ago"
Jul 08 19:53:07 ip-10-0-90-119 crio[2147]: time="2024-07-08 19:53:07.124789735Z" level=debug msg="Looking for sigstore attachments in quayio-pull-through-cache-us-east-2-ci.apps.ci.l2s4.p1.openshiftapps.com/openshift-release-dev/ocp-release:sha256-c17d...

- Description for the changelog

Add icsp/idms/itms mirrors of CIP scope to /etc/containers/registries.d, so sigstore attachment will be used during the image pull and verification.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build ose-machine-config-operator-container-v4.17.0-202407111341.p0.g35ce1c1.assembly.stream.el9 for distgit ose-machine-config-operator.
All builds following this will include this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClusterImagePolicy’s code to set use-sigstore-attachments does not set it for mirrors
5 participants