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 custom etcd prefix compatibility for etcd3 #42506

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Mar 3, 2017

Fixes #42505

restored normalization of custom `--etcd-prefix` when `--storage-backend` is set to etcd3

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 3, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 3, 2017
@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note-label-needed labels Mar 3, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@timothysc
Copy link
Member

iirc @hongchaodeng made that change.

@timothysc timothysc added kind/bug Categorizes issue or PR as related to a bug. release-blocker labels Mar 3, 2017
@timothysc timothysc added this to the v1.6 milestone Mar 3, 2017
@hongchaodeng
Copy link
Contributor

@timothysc Feel free to assign to you

@hongchaodeng
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2017
@k8s-github-robot k8s-github-robot added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Mar 3, 2017
@enj
Copy link
Member

enj commented Mar 4, 2017

Also need upgrade tests with custom prefixes that normalize differently (foo, /foo, /foo//bar, etc).

@hongchaodeng
Copy link
Contributor

/foo//bar

This is already invalid path. Starting apiserver like this should reject it directly.

@enj
Copy link
Member

enj commented Mar 4, 2017

I do not know if we do any validation to the --etcd-prefix parameter but path.Join will normalize /foo//bar to /foo/bar.

@timothysc
Copy link
Member

/cc @mml @wojtek-t there is a gap in your upgrade test coverage.

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 7, 2017
@liggitt
Copy link
Member Author

liggitt commented Mar 7, 2017

rebased and added unit tests

@liggitt liggitt added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. release-note-label-needed labels Mar 7, 2017
@liggitt
Copy link
Member Author

liggitt commented Mar 7, 2017

#39975 flake
@k8s-bot bazel test this

@smarterclayton
Copy link
Contributor

/approve

This is a very serious issue that could cause data loss for an upgrading cluster if the administrator had custom prefixes and wasn't paying attention.

/lgtm

@k8s-ci-robot
Copy link
Contributor

@smarterclayton: you can't LGTM a PR unless you are an assignee.

In response to this comment:

/approve

This is a very serious issue that could cause data loss for an upgrading cluster if the administrator had custom prefixes and wasn't paying attention.

/lgtm

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. I understand the commands that are listed here.

@smarterclayton smarterclayton added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Mar 7, 2017
@smarterclayton
Copy link
Contributor

Actually, quick question. What if an admin had previously configured a prefix of /foo//bar? We use path.join elsewhere when building keys? Could an admin have // in practice (I believe etcd normalizes this via the golang server library, just want to be sure)?

@hongchaodeng
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 7, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

The following people have approved this PR: hongchaodeng, liggitt, smarterclayton

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

We suggest the following people:
cc
You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@liggitt
Copy link
Member Author

liggitt commented Mar 7, 2017

etcd2 used path.join on the prefix and would have normalized it away (// and trailing slashes are normalized away), so they couldn't have a prefix containing // or ending in / on etcd2.

we don't use path join in the keyfuncs.

@smarterclayton
Copy link
Contributor

Ok, thanks lgtm as well.

@liggitt
Copy link
Member Author

liggitt commented Mar 7, 2017

opened cherry-pick for 1.5.x

@liggitt liggitt added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Mar 7, 2017
@k8s-ci-robot
Copy link
Contributor

@liggitt: The following test(s) failed:

Test name Commit Details Rerun command
Jenkins GCE e2e 6853e4d link @k8s-bot cvm gce e2e test this

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 42506, 42585, 42596, 42584)

@k8s-github-robot k8s-github-robot merged commit 8b10527 into kubernetes:master Mar 7, 2017
@liggitt liggitt deleted the etcd-prefix branch March 7, 2017 17:14
@enj
Copy link
Member

enj commented Mar 8, 2017

we don't use path join in the keyfuncs.

Both of them use path.Join to merge the root prefix with the keyFunc's output. So now the etcd key is guaranteed to start with a / and be a fully normalized path.

etcd2:

func (h *etcdHelper) prefixEtcdKey(key string) string {
	if strings.HasPrefix(key, h.pathPrefix) {
		return key
	}
	return path.Join(h.pathPrefix, key)
}

etcd3:

func keyWithPrefix(prefix, key string) string {
	if strings.HasPrefix(key, prefix) {
		return key
	}
	return path.Join(prefix, key)
}

@liggitt
Copy link
Member Author

liggitt commented Mar 8, 2017

those don't exist any more (b6e3296), but yes, the etcd prefix and the key are joined that way. I was referring to the actual key functions in the registries

k8s-github-robot pushed a commit that referenced this pull request Mar 13, 2017
…6-upstream-release-1.5

Automatic merge from submit-queue

Automated cherry pick of #42506

Cherry pick of #42506 on release-1.5.

#42506: Preserve custom etcd prefix compatibility for etcd3

```release-note
restored normalization of custom `--etcd-prefix` when `--storage-backend` is set to etcd3
```
mintzhao pushed a commit to mintzhao/kubernetes that referenced this pull request Jun 1, 2017
…k-of-#42506-upstream-release-1.5

Automatic merge from submit-queue

Automated cherry pick of kubernetes#42506

Cherry pick of kubernetes#42506 on release-1.5.

kubernetes#42506: Preserve custom etcd prefix compatibility for etcd3

```release-note
restored normalization of custom `--etcd-prefix` when `--storage-backend` is set to etcd3
```
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-blocker release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API server cannot find data when switching from etcd2 to etcd3 with custom etcd prefix
8 participants