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

Bug 1741391: support ImageContentSourcePolicy by ImageStreamImport #23

Merged
merged 2 commits into from
Nov 5, 2019

Conversation

dmage
Copy link
Contributor

@dmage dmage commented Sep 17, 2019

No description provided.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 17, 2019
@openshift-ci-robot
Copy link

@dmage: This pull request references Bugzilla bug 1741391, which is invalid:

  • expected the bug to target the "4.2.0" release, but it targets "4.3.0" instead

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

In response to this:

[WIP] Bug 1741391: support ImageContentSourcePolicy by ImageStreamImport

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/test-infra repository.

@openshift-ci-robot openshift-ci-robot added bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 17, 2019
@dmage
Copy link
Contributor Author

dmage commented Sep 20, 2019

@sttts this PR is expected eventually to be backported to 4.2.z. Is it ok to change vendor for such PRs?

@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 24, 2019
@dmage
Copy link
Contributor Author

dmage commented Sep 24, 2019

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Sep 24, 2019
@openshift-ci-robot
Copy link

@dmage: This pull request references Bugzilla bug 1741391, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

/bugzilla 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 kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot removed the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Sep 24, 2019
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, sure, this is consistent with how the ImageContentSourcePolicy object only configures accesses by digest.

(I don’t quite understand what the UX is going to look like — will the users be forced to manually update ImageStream* objects with new values all the time? Where will they get the values to use? … This is all very much outside my area of expertise, I just hope that someone is thinking about that.)

// - Implement ImageContentSourcePolicy rules in icspRules.
// “Whole registries” above means that the configuration applies to everything on that registry, including any possible separately-configured
// namespaces/repositories within that registry.
func EditRegistriesConfig(config *sysregistriesv2.V2RegistriesConf, insecureRegistries, blockedRegistries []string, icspRules []*apioperatorsv1alpha1.ImageContentSourcePolicy) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider vendoring the original (https://github.com/openshift/machine-config-operator/tree/master/pkg/controller/container-runtime-config/registries , or the new repo that is being prepared) so that it is only maintained in one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to vendor any operator into the API server. The repo is not ready yet. But even if this code live in a new repo, I still don't want to vendor it because of its dependency on the all-in-one package sysregistriesv2. It will add dependency on toml, for example, that is not needed for the API server.

/cc @adambkaplan

Copy link
Contributor

Choose a reason for hiding this comment

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

@mtrmac I'm getting this repo set up. We'll address the refactor in a later PR.

klog.Warningf("failed to merge ImageContentSourcePolicy resources, mirrored images will not be found: %v", err)
}
for i, reg := range v2regConf.Registries {
v2regConf.Registries[i].Prefix = reg.Location
Copy link
Contributor

Choose a reason for hiding this comment

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

(Strictly speaking, this should happen only if .Prefix == "". It doesn’t make a difference with the data built by EditRegistriesConfig.)

@@ -0,0 +1,260 @@
package sysregistriesv2
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not vendor the original from c/image, and make the relationship and maintenance expectations explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the original package also has V1 types that I don't need. And these types need additional dependencies that may create unnecessary complications for backporting this PR (types.SystemContext, for example).

@adambkaplan It'd be good to make packages more granular in the new repo, so we don't need to import dozen packages only because we need to merge two maps.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, containers/image#692 really is a pain.

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, after containers/image#716 , c/image v4.0.0 no longer imports the compression implementations. Sure, there is still the TOML decoder, and of course containers/image/types, but I can’t see how merely including that code hurts all that much.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mtrmac we also need to backport this change to 4.2.z

Copy link
Contributor

Choose a reason for hiding this comment

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

containers/image does not currently maintain per-OpenShift branches; you can vendor commit df216d7cdc943e3e2ddef7be67a6abdcaf583e61 directly.

(Or use use the later released v4.0.1, but that forces use of Go modules.)

reg := isi.regConf.Registries[i]

if bestMatch == nil || len(reg.Prefix) > len(bestMatch.Prefix) {
if scopeMatchesRegistry(repoName, reg.Prefix) {
Copy link
Contributor

@mtrmac mtrmac Sep 24, 2019

Choose a reason for hiding this comment

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

scopeMatchesRegistry is only correct when the second parameter is a registry, while reg.Prefix can be a namespace or a repository name. In particular this will break in the most common case, with ref a repo:tag or repo@digest, and ref.Prefix being repo.

See how c/image/pkg/sysregistriesv2.FindRegistry works (or, ideally, just call it — right now that would require writing isi.regConf.Registries to a temporary file, I suppose that could change).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

repoName doesn't contain : nor @ here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, true. The code is still misusing scopeMatchesRegistry, though.

pkg/image/apiserver/importer/importer.go Show resolved Hide resolved
pkg/image/apiserver/importer/importer.go Outdated Show resolved Hide resolved
if err != nil {
klog.V(5).Infof("unable to access repository %#v: %#v", repository, err)
switch {
case err == reference.ErrReferenceInvalidFormat:
Copy link
Contributor

Choose a reason for hiding this comment

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

This detailed error handling seems to have been lost in the move to getManifestByDigest.

s, err := repo.Manifests(ctx)
if err != nil {
klog.V(5).Infof("unable to access manifests for repository %#v: %#v", repository, err)
switch {
Copy link
Contributor

Choose a reason for hiding this comment

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

This detailed error handling seems to have been lost in the move to getManifestByDigest.

@dmage dmage force-pushed the import-from-mirrors branch 2 times, most recently from d7eb564 to 4ec0340 Compare October 3, 2019 16:52
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 3, 2019
@dmage dmage changed the title [WIP] Bug 1741391: support ImageContentSourcePolicy by ImageStreamImport Bug 1741391: support ImageContentSourcePolicy by ImageStreamImport Oct 3, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 3, 2019
@dmage
Copy link
Contributor Author

dmage commented Oct 4, 2019

/assign @adambkaplan @sttts

@dmage
Copy link
Contributor Author

dmage commented Oct 8, 2019

@adambkaplan @sttts please take a look

@mfojtik
Copy link
Contributor

mfojtik commented Oct 9, 2019

/hold

This is pending architectural discussion.

I think wiring operator clients and reading CR's inside openshift-apiserver is not the correct way to deal with changing the configuration for the operand. We already have mechanism to do this via operand config (in this case openshift apiserver config) and the operator should have observer loop and sets the configuration using this mechanism.

This is inventing a new "dynamic" config that depends on CRD provided by cluster-config-operator.

Also this config is not changed often, I would say in 99% cases this is "one time setting".

/cc @derekwaynecarr
/cc @smarterclayton
/cc @deads2k

@dmage
Copy link
Contributor Author

dmage commented Oct 23, 2019

/retest

@dmage
Copy link
Contributor Author

dmage commented Oct 24, 2019

@adambkaplan

  1. a bad ICSP shouldn't cause the apiserver to crashloop
  2. I added some debug messages that can help us understand where the image is going to be pulled from

@dmage
Copy link
Contributor Author

dmage commented Oct 24, 2019

Copy link
Contributor

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

/lgm

ping @mfojtik regarding the hold

@adambkaplan
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 24, 2019
@dmage
Copy link
Contributor Author

dmage commented Oct 25, 2019

/retest

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 31, 2019
Copy link
Contributor

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 31, 2019
@dmage
Copy link
Contributor Author

dmage commented Nov 4, 2019

@sttts @mfojtik can we merge it or is there something left to fix?

@mfojtik
Copy link
Contributor

mfojtik commented Nov 4, 2019

/hold cancel

@mfojtik
Copy link
Contributor

mfojtik commented Nov 4, 2019

@dmage please rename the last commit to bump(*): vendor

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 4, 2019
@mfojtik
Copy link
Contributor

mfojtik commented Nov 4, 2019

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2019
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 4, 2019
@adambkaplan
Copy link
Contributor

/lgtm

Last commit renamed per @mfojtik

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 5, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adambkaplan, dmage, mfojtik

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-merge-robot openshift-merge-robot merged commit 36e1300 into openshift:master Nov 5, 2019
@openshift-ci-robot
Copy link

@dmage: All pull requests linked via external trackers have merged. Bugzilla bug 1741391 has been moved to the MODIFIED state.

In response to this:

Bug 1741391: support ImageContentSourcePolicy by ImageStreamImport

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/test-infra repository.

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. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants