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

IR-21: Leveraging image config for "insecure" registries during ImageStreamImport #111

Merged
merged 7 commits into from
Jul 22, 2020

Conversation

ricardomaraschini
Copy link
Contributor

@ricardomaraschini ricardomaraschini commented Jun 2, 2020

By leveraging images.config.openshift.io/cluster "insecure" registry configuration we now can flag a registry as insecure for all image stream imports. Without this patch users had to set the registry as "insecure" on the ImageStreamImport request, regardless of what was defined on images.config.openshift.io/cluster.

I have chosen to include here some other housekeeping changes:

  1. Standardized the receiver name for "ImageStreamImporter" struct (linter warning)
  2. Migrating from golang.org/x/net/context to context
  3. Removed unnecessary function parameters (using struct "properties" instead)
  4. Vendoring sysregistriesv2 so we can remove a own copy of this package we had laying on our repository

All four changes above were constricted into their own commits (plus commits where we vendor stuff) in an attempt to make the review easier.

Tests for this feature were implemented through openshift/origin#25058

@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 Jun 2, 2020
@ricardomaraschini ricardomaraschini changed the title WIP - IR21: Leveraging image config for "insecure" registries during ImageStreamImport WIP - IR-21: Leveraging image config for "insecure" registries during ImageStreamImport Jun 2, 2020
@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws

1 similar comment
@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws

@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws-upgrade

@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws

@ricardomaraschini
Copy link
Contributor Author

/retest

@ricardomaraschini ricardomaraschini changed the title WIP - IR-21: Leveraging image config for "insecure" registries during ImageStreamImport IR-21: Leveraging image config for "insecure" registries during ImageStreamImport Jun 4, 2020
@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 Jun 4, 2020
@ricardomaraschini
Copy link
Contributor Author

/assign @dmage @mfojtik

@@ -116,6 +116,39 @@ func (config *V2RegistriesConf) Nonempty() bool {
len(config.UnqualifiedSearchRegistries) != 0)
}

// Insecure returns if access to registry at location is flagged as insecure, i.e. invalid
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation doesn't match the registries.conf documentation.

Please keep it in sync with https://github.com/containers/image/blob/master/pkg/sysregistriesv2/system_registries_v2.go

You may want to import this package directly, AFAIK they fixed their "types" package and it shouldn't have 100500 dependencies anymore.

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 did not know this package was copied from somewhere else. I have updated this PR to vendor the package and remove the copy&pasta we had.

@ricardomaraschini
Copy link
Contributor Author

/assign @dmage

@ricardomaraschini
Copy link
Contributor Author

/assign @mfojtik

@dmage
Copy link
Contributor

dmage commented Jun 15, 2020

/lgtm
/unassign
/assign @mfojtik

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 15, 2020
@dmage
Copy link
Contributor

dmage commented Jun 30, 2020

/assign @sttts

@@ -81,38 +89,68 @@ func NewImageStreamImporter(retriever RepositoryRetriever, regConf *sysregistrie
limiter: limiter,
regConf: regConf,

digestToRepositoryCache: make(map[gocontext.Context]map[manifestKey]*imageapi.Image),
digestToRepositoryCache: make(map[context.Context]map[manifestKey]*imageapi.Image),
Copy link
Contributor

Choose a reason for hiding this comment

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

that's interesting type. Which context ends up here? The one of the request?

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 had the same impression when I came across this construction for the first time, seems rather interesting. I did some digging and I discovered that this is entangled with the client request's context. The next obvious question I had was: "what?!". I could not find where this was freed so I thought this would grow indefinitely, a real memory hoarder eating everything on its way. Well, this is not the case because the object holding it is created in a per request basis, so the next obvious question was "why?", if it is based on a per request basis why to index per context? My guess is that this object was planned to handle multiple requests at the same time but never got finished.

@dmage Am I missing something here? I think we could have a task to check(fix?) this as tech-debt, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

while we touch this, can you add a comment? This has big code smell.

Copy link
Contributor

Choose a reason for hiding this comment

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

I created a tech-debt card: https://issues.redhat.com/browse/IR-116

@@ -11,7 +12,7 @@ import (
"testing"
"time"

"golang.org/x/net/context"
"github.com/containers/image/pkg/sysregistriesv2"

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -223,7 +237,7 @@ func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation
r.transport, r.insecureTransport, secretsList.Items,
)
imports := r.importFn(importCtx, v2regConf)
if err := imports.Import(ctx.(gocontext.Context), isi, stream); err != nil {
if err := imports.Import(ctx.(context.Context), isi, stream); err != nil {
Copy link
Contributor

@sttts sttts Jun 30, 2020

Choose a reason for hiding this comment

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

why this cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, removed it.

@@ -246,7 +260,7 @@ func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation
r.transport, r.insecureTransport, nil,
)
imports := r.importFn(importCtx, v2regConf)
if err := imports.Import(ctx.(gocontext.Context), isi, stream); err != nil {
if err := imports.Import(ctx.(context.Context), isi, stream); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

why this cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, removed it.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 1, 2020
@ricardomaraschini
Copy link
Contributor Author

/retest

1 similar comment
@ricardomaraschini
Copy link
Contributor Author

/retest

@openshift-ci-robot
Copy link

@dmage: dmage unauthorized: /override is restricted to Repo administrators, approvers in top level OWNERS file.

In response to this:

/override ci/prow/e2e-cmd
this test is broken for now

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.

@dmage
Copy link
Contributor

dmage commented Jul 21, 2020

@sttts can you override e2e-cmd? @soltysh is working on it, but it's broken for now.

@openshift-bot
Copy link
Contributor

/retest

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

@sttts
Copy link
Contributor

sttts commented Jul 21, 2020

/override e2e-cmd

@openshift-ci-robot
Copy link

@sttts: /override requires a failed status context to operate on.
The following unknown contexts were given:

  • e2e-cmd

Only the following contexts were expected:

  • ci/prow/e2e-aws
  • ci/prow/e2e-aws-serial
  • ci/prow/e2e-aws-upgrade
  • ci/prow/e2e-cmd
  • ci/prow/images
  • ci/prow/unit
  • ci/prow/verify
  • tide

In response to this:

/override e2e-cmd

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.

@sttts
Copy link
Contributor

sttts commented Jul 21, 2020

/override ci/prow/e2e-cmd

@openshift-ci-robot
Copy link

@sttts: Overrode contexts on behalf of sttts: ci/prow/e2e-cmd

In response to this:

/override ci/prow/e2e-cmd

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-bot
Copy link
Contributor

/retest

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

13 similar comments
@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@petr-muller
Copy link
Member

/hold

If the test is broken then there's no point in retesting. Either button merge it or /override after a failure is reported and then unhold (but Tide may decide to re-run the tests before merge so button merge is probably better).

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 22, 2020
@openshift openshift deleted a comment from openshift-ci-robot Jul 22, 2020
@sttts
Copy link
Contributor

sttts commented Jul 22, 2020

/override ci/prow/e2e-cmd

@sttts
Copy link
Contributor

sttts commented Jul 22, 2020

/hold cancel

@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 Jul 22, 2020
@openshift-ci-robot
Copy link

@sttts: Overrode contexts on behalf of sttts: ci/prow/e2e-cmd

In response to this:

/override ci/prow/e2e-cmd

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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants