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

Preserve namespace on imagestreams server-side export #18487

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Feb 6, 2018

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 6, 2018
@openshift-merge-robot openshift-merge-robot added the vendor-update Touching vendor dir or related files label Feb 6, 2018
@@ -1199,9 +1199,6 @@ func (e *Store) calculateTTL(obj runtime.Object, defaultTTL int64, update bool)
// present when the object is exported.
func exportObjectMeta(accessor metav1.Object, exact bool) {
accessor.SetUID("")
if !exact {
accessor.SetNamespace("")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k from what I can tell, it wasn't the export strategy that was defaulting an empty namespace to "default".
In the case of the imagestream I tested with, its ExportStrategy was nil. Instead, the CreateStrategy was called here. I suspect it is somewhere there that the namespace is defaulted

Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect the client to set the namespace wrong on export. The "default" namespace is not special and I guess whoever reported that BZ was just using "default" as the current namespace.

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 looks correct. Check the return value from teh apiserver. Was it actually "default" or was that set client-side?

Copy link
Contributor Author

@juanvallejo juanvallejo Feb 7, 2018

Choose a reason for hiding this comment

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

Taking a second look, this problem does not exist when testing against a cluster created with openshift start (compiled from latest master).

Can only replicate if using a cluster created via oc cluster up. Still looking

Copy link
Contributor Author

@juanvallejo juanvallejo Feb 7, 2018

Choose a reason for hiding this comment

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

@deads2k

Was it actually "default" or was that set client-side?

It does not look like the client is setting it to "default", from what I can tell. Namespace seems to be set already when the client receives a response from the server.
--loglevel=8 of oc get is/jenkins -o yaml --export: http://pastebin.test.redhat.com/553666

Copy link
Contributor Author

@juanvallejo juanvallejo Feb 7, 2018

Choose a reason for hiding this comment

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

@mfojtik @deads2k for comparison, here is --loglevel 8 output for the same command, but executed against a cluster created via openshift start instead (same result with an openshift binary compiled from both latest master, and tag v3.9.0-alpha.4, which is the image version I am using for oc cluster up): http://pastebin.test.redhat.com/553669

Copy link
Contributor Author

@juanvallejo juanvallejo Feb 7, 2018

Choose a reason for hiding this comment

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

cc @bparees I'm not sure if oc cluster up uses a different export strategy / why it appears to behave differently than an $ openshift start cluster.

We handle server-side export here: https://github.com/openshift/origin/blob/master/vendor/k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go#L1215 clearing the namespace field for an object here https://github.com/openshift/origin/blob/master/vendor/k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go#L1203

Not sure how / where an empty namespace field could be defaulting to default as its value. The client does not appear to be altering this, as loglevel output linked to above shows that the cluster is already returning the object with the namespace field value defaulted.

This does not happen with openshift start clusters. I have tested with 3.8 and 3.9 releases of the openshift binary.

I have also tested with oc cluster up --latest and oc cluster up --version v3.8.0-alpha.0. Was hoping you had maybe seen something like this before?

Copy link
Contributor

Choose a reason for hiding this comment

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

Was hoping you had maybe seen something like this before?

i haven't, and no, oc cluster up certainly doesn't configure export strategies, so i can't imagine why there would be a difference in behavior.

also "oc export" seems to do the right thing (leaves off the namespace).

Anyway I'm seeing the "wrong" behavior using openshift start clusters, as well as oc cluster up clusters:

exporting from current project==openshift:

$ oc get --export is jenkins -o yaml
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
  annotations:
    openshift.io/display-name: Jenkins
    openshift.io/image.dockerRepositoryCheck: 2018-02-07T19:19:34Z
  creationTimestamp: null
  generation: 1
  name: jenkins
  namespace: default

@mfojtik
Copy link
Contributor

mfojtik commented Feb 7, 2018

/retest
/lgtm

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 7, 2018
@mfojtik
Copy link
Contributor

mfojtik commented Feb 7, 2018

/hold

Please have upstream PR approved first and use the upstream PR number in commit message.

@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 Feb 7, 2018
@deads2k
Copy link
Contributor

deads2k commented Feb 7, 2018

/hold

fix doesn't look correct.

@deads2k
Copy link
Contributor

deads2k commented Feb 7, 2018

/lgtm cancel

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 7, 2018
@mffiedler
Copy link
Contributor

My current namespace was "logging" not "default" in latest repro in https://bugzilla.redhat.com/show_bug.cgi?id=1542238

@juanvallejo juanvallejo force-pushed the jvallejo/dont-remove-namespace-on-export branch from 4482be4 to ec47625 Compare February 12, 2018 21:18
@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 12, 2018
@juanvallejo juanvallejo changed the title UPSTREAM: 0000: preserve namespace on server-side export Preserve namespace on imagestreams server-side export Feb 12, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/dont-remove-namespace-on-export branch from ec47625 to f38e47e Compare February 12, 2018 21:20
@openshift-merge-robot openshift-merge-robot removed the vendor-update Touching vendor dir or related files label Feb 12, 2018
@juanvallejo
Copy link
Contributor Author

@mfojtik @soltysh @deads2k Updated this PR to just add an export strategy for imagestreams. Before, they did not have one, so doing a server-side export was defaulting to a call to the imagestream create-strategy. This strategy was defaulting the namespace to the "Default" value when it saw that the namespace field had been cleared. ptal

@bparees
Copy link
Contributor

bparees commented Feb 12, 2018

lgtm for whatever that's worth.

@soltysh
Copy link
Member

soltysh commented Feb 13, 2018

I've talked with @juanvallejo on IRC he'll try to fix setting the namespace in dockerImageRepository so that it is not set when being called from PrepareForCreate.

@soltysh
Copy link
Member

soltysh commented Feb 13, 2018

/assign

@juanvallejo
Copy link
Contributor Author

@soltysh thanks for the feedback. Added an extra arg to dockerImageRepository to allow/prevent namespace defaulting. PTAL

@soltysh
Copy link
Member

soltysh commented Feb 15, 2018

@juanvallejo update tests:

# github.com/openshift/origin/pkg/image/registry/imagestream
[WARNING] pkg/image/registry/imagestream/strategy_test.go:184:42: not enough arguments in call to strategy.dockerImageRepository
[WARNING] 	have (*image.ImageStream)
[WARNING] 	want (*image.ImageStream, bool) 

and you're good to go.

@soltysh
Copy link
Member

soltysh commented Feb 15, 2018

/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 Feb 15, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/dont-remove-namespace-on-export branch from c7e6544 to 2074572 Compare February 15, 2018 15:57
@juanvallejo juanvallejo force-pushed the jvallejo/dont-remove-namespace-on-export branch from 2074572 to f07954b Compare February 15, 2018 16:01
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 15, 2018
Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: juanvallejo, mfojtik, soltysh

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@juanvallejo
Copy link
Contributor Author

/test gcp

@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 18487, 18537, 18630).

@openshift-merge-robot openshift-merge-robot merged commit 0c282b0 into openshift:master Feb 15, 2018
@juanvallejo juanvallejo deleted the jvallejo/dont-remove-namespace-on-export branch February 15, 2018 22:37
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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants