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 1816534: DEVEXP-424: Leveraging node credentials during image stream import #83

Merged
merged 2 commits into from
Apr 9, 2020
Merged

Conversation

ricardomaraschini
Copy link
Contributor

@ricardomaraschini ricardomaraschini commented Mar 13, 2020

With this PR we start to use node's pull secrets during image stream import process as described on the enhancement proposal. We prioritize namespace secrets over node pull secrets.

Note: Please review openshift/cluster-openshift-apiserver-operator#284 as well.

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 13, 2020
@ricardomaraschini
Copy link
Contributor Author

/retest

@ricardomaraschini
Copy link
Contributor Author

/test verify

@ricardomaraschini
Copy link
Contributor Author

/test unit

@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws

@ricardomaraschini
Copy link
Contributor Author

/retest

@ricardomaraschini
Copy link
Contributor Author

/test images

@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws-serial

@ricardomaraschini ricardomaraschini changed the title WIP: Levaraging node credentials WIP: Leveraging node credentials Mar 13, 2020
@ricardomaraschini
Copy link
Contributor Author

/retest

1 similar comment
@ricardomaraschini
Copy link
Contributor Author

/retest

@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws

@ricardomaraschini
Copy link
Contributor Author

/retest

@ricardomaraschini ricardomaraschini changed the title WIP: Leveraging node credentials DEVEXP-424: Leveraging node credentials Mar 15, 2020
@ricardomaraschini ricardomaraschini changed the title DEVEXP-424: Leveraging node credentials DEVEXP-424: Leveraging node credentials during image stream import. Mar 15, 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 Mar 15, 2020
@ricardomaraschini
Copy link
Contributor Author

/retest

@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws

1 similar comment
@ricardomaraschini
Copy link
Contributor Author

/test e2e-aws

@ricardomaraschini
Copy link
Contributor Author

/assign @dmage @adambkaplan @mfojtik

@ricardomaraschini
Copy link
Contributor Author

/assign @sttts

@@ -258,24 +257,6 @@ func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation
}
}

// if we encountered an error loading credentials and any images could not be retrieved with an access
Copy link
Contributor

Choose a reason for hiding this comment

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

this code was there to get proper error messages from the API. How is this done now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is part of a behavioral change. Now if we can't load the secrets we return an API error to the user and don't create any image streams. With that out of the way(error retrieving secrets) future StatusReasonUnauthorized and StatusReasonForbidden would be correct so no need to overwrite them by Unable to load secrets for this image error.

Let me know what you reckon and I will adjust appropriately.

This commit vendors github.com/docker/docker/registry as we are going to
start to leverage type registry.StaticCredentialStore when creating a
registryclient.Context.
imageapi "github.com/openshift/openshift-apiserver/pkg/image/apis/image"
dockerregistry "github.com/openshift/openshift-apiserver/pkg/image/apiserver/importer/dockerv1client"
"github.com/openshift/openshift-apiserver/pkg/image/apiserver/sysregistriesv2"
)

func init() {
runtime.Must(userapi.Install(legacyscheme.Scheme))
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the legacy scheme used? Installing anything into that is suspicious. Just create a new scheme object and install into it what you need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Functions[1] such as schema1ToImage or schema2ToImage on this package rely on the legacyscheme, not sure what the options were when they got developed. I don't mind at all fixing this to use a new scheme but it goes over the scope of this feature and I would address it as technical debt. If you are OK with leaving this as is for now I will create a new front to address this issue. You may even see TODO comments[2] talking about the legacyscheme.

[1] https://github.com/openshift/openshift-apiserver/blob/master/pkg/image/apiserver/importer/image.go#L88
[2] https://github.com/openshift/openshift-apiserver/blob/master/pkg/image/apiserver/importer/dockerv1client/client.go#L34

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, fine for me as a follow-up.

})
}

importCtx := registryclient.NewContext(
Copy link
Contributor

Choose a reason for hiding this comment

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

By recreating Context all the time, you are losing all caching features. Essentially you'll make a lot of ping requests to the /v2/ endpoint for every tag in ImageStreamImport.

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 can lay down a cache layer here and reuse them, what do you think? Ideally I would add this logic on library-go but unfortunately i can't as it includes k8s keyrings and I am not supposed to add these dependencies there.

Copy link
Contributor Author

@ricardomaraschini ricardomaraschini Mar 20, 2020

Choose a reason for hiding this comment

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

Could you PTAL ? I have added a code to reuse contexts.

Copy link
Contributor

Choose a reason for hiding this comment

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

getting credentials using ref and then caching them by regurl definitely needs to be covered by tests. It can cause authentication problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/hold

I am investigating what is the best way of achieving this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dmage I have updated the indexing to use the repository name instead of the URL. Could you PTAL?

@ricardomaraschini ricardomaraschini changed the title DEVEXP-424: Leveraging node credentials during image stream import. DEVEXP-424: Leveraging node credentials during image stream import Mar 19, 2020
@ricardomaraschini
Copy link
Contributor Author

/retest

@@ -273,7 +273,7 @@ func (i *ImageStreamImporter) importFromRepository(ctx gocontext.Context, retrie

key := repositoryKey{url: *registryURL, name: repoName}
repo := &importRepository{
Ref: ref,
Ref: defaultRef,
Copy link
Contributor

Choose a reason for hiding this comment

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

what is implication of this 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.

As far as I checked the only side effect is some error strings, see here for an example.

What changes is that:

  1. If no registry is present, docker.io is used.
  2. If no Namespace is set on the registry being imported and the repository is docker hub, library is used on the repository URL.
  3. If no tag is set, latest is used.

Do you see any problem with this approach? Let me know if you have an use case where this can cause issues and I will make sure it works.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's for error strings, then it should contain the name as it was entered by the user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right. I have reverted this change and now the error string is the same as it used to be. Please let me know if it is OK for you.

})
}

importCtx := registryclient.NewContext(
Copy link
Contributor

Choose a reason for hiding this comment

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

getting credentials using ref and then caching them by regurl definitely needs to be covered by tests. It can cause authentication problems.

@dmage
Copy link
Contributor

dmage commented Mar 23, 2020

Looks good, we'll need to create BZs to track follow-up tech debt addressing.

/lgtm

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

Looks good, we'll need to create BZs to track follow-up tech debt addressing.

/lgtm

I have already opened a JIRA card for the tech debt, thanks for the heads-up.

@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 Mar 23, 2020
Starting to merge node pull secrets with kubernetes docker secrets
during image stream import.

Implementation details may be found at:

openshift/enhancements/node-pull-credentials/pull-credentials.md
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 24, 2020
@ricardomaraschini
Copy link
Contributor Author

/retest

@dmage
Copy link
Contributor

dmage commented Mar 25, 2020

/retitle Bug 1816534: DEVEXP-424: Leveraging node credentials during image stream import

@openshift-ci-robot openshift-ci-robot changed the title DEVEXP-424: Leveraging node credentials during image stream import Bug 1816534: DEVEXP-424: Leveraging node credentials during image stream import Mar 25, 2020
@openshift-ci-robot
Copy link

@ricardomaraschini: This pull request references Bugzilla bug 1816534, 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.

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

In response to this:

Bug 1816534: DEVEXP-424: Leveraging node credentials during image stream import

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 the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Mar 25, 2020
@dmage
Copy link
Contributor

dmage commented Mar 25, 2020

/lgtm

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

/unhold

@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 Mar 29, 2020
@dmage
Copy link
Contributor

dmage commented Apr 7, 2020

@mfojtik @sttts please take a look

@sttts
Copy link
Contributor

sttts commented Apr 9, 2020

/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dmage, ricardomaraschini, sttts

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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 9, 2020
@openshift-merge-robot openshift-merge-robot merged commit c41ece2 into openshift:master Apr 9, 2020
@openshift-ci-robot
Copy link

@ricardomaraschini: All pull requests linked via external trackers have merged: openshift/openshift-apiserver#83. Bugzilla bug 1816534 has been moved to the MODIFIED state.

In response to this:

Bug 1816534: DEVEXP-424: Leveraging node credentials during image stream import

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.

7 participants