Introduce a new storage config option for the etcd key
prefix for both OpenShift and Kubernetes
... | ... |
@@ -23,7 +23,7 @@ const ( |
23 | 23 |
// BuildPath is the path to build resources in etcd |
24 | 24 |
BuildPath string = "/builds" |
25 | 25 |
// BuildConfigPath is the path to buildConfig resources in etcd |
26 |
- BuildConfigPath string = "/buildConfigs" |
|
26 |
+ BuildConfigPath string = "/buildconfigs" |
|
27 | 27 |
) |
28 | 28 |
|
29 | 29 |
// Etcd implements build.Registry and buildconfig.Registry backed by etcd. |
... | ... |
@@ -46,12 +46,12 @@ func makeTestDefaultBuildListKey() string { |
46 | 46 |
} |
47 | 47 |
func makeTestBuildConfigListKey(namespace string) string { |
48 | 48 |
if len(namespace) != 0 { |
49 |
- return "/buildConfigs/" + namespace |
|
49 |
+ return "/buildconfigs/" + namespace |
|
50 | 50 |
} |
51 |
- return "/buildConfigs" |
|
51 |
+ return "/buildconfigs" |
|
52 | 52 |
} |
53 | 53 |
func makeTestBuildConfigKey(namespace, id string) string { |
54 |
- return "/buildConfigs/" + namespace + "/" + id |
|
54 |
+ return "/buildconfigs/" + namespace + "/" + id |
|
55 | 55 |
} |
56 | 56 |
func makeTestDefaultBuildConfigKey(id string) string { |
57 | 57 |
return makeTestBuildConfigKey(kapi.NamespaceDefault, id) |
... | ... |
@@ -685,7 +685,7 @@ func TestEtcdListBuildConfigsInDifferentNamespaces(t *testing.T) { |
685 | 685 |
fakeClient := tools.NewFakeEtcdClient(t) |
686 | 686 |
namespaceAlfa := kapi.WithNamespace(kapi.NewContext(), "alfa") |
687 | 687 |
namespaceBravo := kapi.WithNamespace(kapi.NewContext(), "bravo") |
688 |
- fakeClient.Data["/buildConfigs/alfa"] = tools.EtcdResponseWithError{ |
|
688 |
+ fakeClient.Data["/buildconfigs/alfa"] = tools.EtcdResponseWithError{ |
|
689 | 689 |
R: &etcd.Response{ |
690 | 690 |
Node: &etcd.Node{ |
691 | 691 |
Nodes: []*etcd.Node{ |
... | ... |
@@ -697,7 +697,7 @@ func TestEtcdListBuildConfigsInDifferentNamespaces(t *testing.T) { |
697 | 697 |
}, |
698 | 698 |
E: nil, |
699 | 699 |
} |
700 |
- fakeClient.Data["/buildConfigs/bravo"] = tools.EtcdResponseWithError{ |
|
700 |
+ fakeClient.Data["/buildconfigs/bravo"] = tools.EtcdResponseWithError{ |
|
701 | 701 |
R: &etcd.Response{ |
702 | 702 |
Node: &etcd.Node{ |
703 | 703 |
Nodes: []*etcd.Node{ |
... | ... |
@@ -735,8 +735,8 @@ func TestEtcdGetBuildConfigInDifferentNamespaces(t *testing.T) { |
735 | 735 |
fakeClient := tools.NewFakeEtcdClient(t) |
736 | 736 |
namespaceAlfa := kapi.WithNamespace(kapi.NewContext(), "alfa") |
737 | 737 |
namespaceBravo := kapi.WithNamespace(kapi.NewContext(), "bravo") |
738 |
- fakeClient.Set("/buildConfigs/alfa/foo", runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{ObjectMeta: kapi.ObjectMeta{Name: "foo"}}), 0) |
|
739 |
- fakeClient.Set("/buildConfigs/bravo/foo", runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{ObjectMeta: kapi.ObjectMeta{Name: "foo"}}), 0) |
|
738 |
+ fakeClient.Set("/buildconfigs/alfa/foo", runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{ObjectMeta: kapi.ObjectMeta{Name: "foo"}}), 0) |
|
739 |
+ fakeClient.Set("/buildconfigs/bravo/foo", runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{ObjectMeta: kapi.ObjectMeta{Name: "foo"}}), 0) |
|
740 | 740 |
registry := NewTestEtcd(fakeClient) |
741 | 741 |
|
742 | 742 |
alfaFoo, err := registry.GetBuildConfig(namespaceAlfa, "foo") |
... | ... |
@@ -148,10 +148,18 @@ type EtcdStorageConfig struct { |
148 | 148 |
// serialized to. This value should *not* be advanced until all clients in the |
149 | 149 |
// cluster that read from etcd have code that allows them to read the new version. |
150 | 150 |
KubernetesStorageVersion string |
151 |
+ // KubernetesStoragePrefix is the path within etcd that the Kubernetes resources will |
|
152 |
+ // be rooted under. This value, if changed, will mean existing objects in etcd will |
|
153 |
+ // no longer be located. |
|
154 |
+ KubernetesStoragePrefix string |
|
151 | 155 |
// OpenShiftStorageVersion is the API version that OS resources in etcd should be |
152 | 156 |
// serialized to. This value should *not* be advanced until all clients in the |
153 | 157 |
// cluster that read from etcd have code that allows them to read the new version. |
154 | 158 |
OpenShiftStorageVersion string |
159 |
+ // OpenShiftStoragePrefix is the path within etcd that the OpenShift resources will |
|
160 |
+ // be rooted under. This value, if changed, will mean existing objects in etcd will |
|
161 |
+ // no longer be located. |
|
162 |
+ OpenShiftStoragePrefix string |
|
155 | 163 |
} |
156 | 164 |
|
157 | 165 |
type ServingInfo struct { |
... | ... |
@@ -12,9 +12,15 @@ func init() { |
12 | 12 |
if len(obj.KubernetesStorageVersion) == 0 { |
13 | 13 |
obj.KubernetesStorageVersion = "v1beta3" |
14 | 14 |
} |
15 |
+ if len(obj.KubernetesStoragePrefix) == 0 { |
|
16 |
+ obj.KubernetesStoragePrefix = "kubernetes.io" |
|
17 |
+ } |
|
15 | 18 |
if len(obj.OpenShiftStorageVersion) == 0 { |
16 | 19 |
obj.OpenShiftStorageVersion = "v1beta1" |
17 | 20 |
} |
21 |
+ if len(obj.OpenShiftStoragePrefix) == 0 { |
|
22 |
+ obj.OpenShiftStoragePrefix = "openshift.io" |
|
23 |
+ } |
|
18 | 24 |
}, |
19 | 25 |
) |
20 | 26 |
if err != nil { |
... | ... |
@@ -144,10 +144,18 @@ type EtcdStorageConfig struct { |
144 | 144 |
// serialized to. This value should *not* be advanced until all clients in the |
145 | 145 |
// cluster that read from etcd have code that allows them to read the new version. |
146 | 146 |
KubernetesStorageVersion string `json:"kubernetesStorageVersion"` |
147 |
+ // KubernetesStoragePrefix is the path within etcd that the Kubernetes resources will |
|
148 |
+ // be rooted under. This value, if changed, will mean existing objects in etcd will |
|
149 |
+ // no longer be located. The default value is 'kubernetes.io'. |
|
150 |
+ KubernetesStoragePrefix string `json:"kubernetesStoragePrefix"` |
|
147 | 151 |
// OpenShiftStorageVersion is the API version that OS resources in etcd should be |
148 | 152 |
// serialized to. This value should *not* be advanced until all clients in the |
149 | 153 |
// cluster that read from etcd have code that allows them to read the new version. |
150 | 154 |
OpenShiftStorageVersion string `json:"openShiftStorageVersion"` |
155 |
+ // OpenShiftStoragePrefix is the path within etcd that the OpenShift resources will |
|
156 |
+ // be rooted under. This value, if changed, will mean existing objects in etcd will |
|
157 |
+ // no longer be located. The default value is 'openshift.io'. |
|
158 |
+ OpenShiftStoragePrefix string `json:"openShiftStoragePrefix"` |
|
151 | 159 |
} |
152 | 160 |
|
153 | 161 |
type ServingInfo struct { |
... | ... |
@@ -105,6 +105,13 @@ func ValidateEtcdStorageConfig(config api.EtcdStorageConfig) fielderrors.Validat |
105 | 105 |
allErrs = append(allErrs, fielderrors.NewFieldRequired("openShiftStorageVersion")) |
106 | 106 |
} |
107 | 107 |
|
108 |
+ if strings.ContainsRune(config.KubernetesStoragePrefix, '%') { |
|
109 |
+ allErrs = append(allErrs, fielderrors.NewFieldInvalid("kubernetesStoragePrefix", config.KubernetesStoragePrefix, "the '%' character may not be used in etcd path prefixes")) |
|
110 |
+ } |
|
111 |
+ if strings.ContainsRune(config.OpenShiftStoragePrefix, '%') { |
|
112 |
+ allErrs = append(allErrs, fielderrors.NewFieldInvalid("openShiftStoragePrefix", config.OpenShiftStoragePrefix, "the '%' character may not be used in etcd path prefixes")) |
|
113 |
+ } |
|
114 |
+ |
|
108 | 115 |
return allErrs |
109 | 116 |
} |
110 | 117 |
|
... | ... |
@@ -48,7 +48,7 @@ func BuildKubernetesMasterConfig(options configapi.MasterConfig, requestContextM |
48 | 48 |
if err != nil { |
49 | 49 |
return nil, err |
50 | 50 |
} |
51 |
- ketcdHelper, err := master.NewEtcdHelper(etcdClient, options.EtcdStorageConfig.KubernetesStorageVersion, "kubernetes.io") |
|
51 |
+ ketcdHelper, err := master.NewEtcdHelper(etcdClient, options.EtcdStorageConfig.KubernetesStorageVersion, options.EtcdStorageConfig.KubernetesStoragePrefix) |
|
52 | 52 |
if err != nil { |
53 | 53 |
return nil, fmt.Errorf("Error setting up Kubernetes server storage: %v", err) |
54 | 54 |
} |
... | ... |
@@ -38,7 +38,7 @@ func BuildAuthConfig(options configapi.MasterConfig) (*AuthConfig, error) { |
38 | 38 |
if err != nil { |
39 | 39 |
return nil, err |
40 | 40 |
} |
41 |
- etcdHelper, err := NewEtcdHelper(client, options.EtcdStorageConfig.OpenShiftStorageVersion, "openshift") |
|
41 |
+ etcdHelper, err := NewEtcdHelper(client, options.EtcdStorageConfig.OpenShiftStorageVersion, options.EtcdStorageConfig.OpenShiftStoragePrefix) |
|
42 | 42 |
if err != nil { |
43 | 43 |
return nil, fmt.Errorf("Error setting up server storage: %v", err) |
44 | 44 |
} |
... | ... |
@@ -97,7 +97,7 @@ func BuildMasterConfig(options configapi.MasterConfig) (*MasterConfig, error) { |
97 | 97 |
if err != nil { |
98 | 98 |
return nil, err |
99 | 99 |
} |
100 |
- etcdHelper, err := NewEtcdHelper(client, options.EtcdStorageConfig.OpenShiftStorageVersion, "openshift") |
|
100 |
+ etcdHelper, err := NewEtcdHelper(client, options.EtcdStorageConfig.OpenShiftStorageVersion, options.EtcdStorageConfig.OpenShiftStoragePrefix) |
|
101 | 101 |
if err != nil { |
102 | 102 |
return nil, fmt.Errorf("Error setting up server storage: %v", err) |
103 | 103 |
} |
... | ... |
@@ -20,7 +20,7 @@ const ( |
20 | 20 |
// DeploymentPath is the path to deployment resources in etcd |
21 | 21 |
DeploymentPath string = "/deployments" |
22 | 22 |
// DeploymentConfigPath is the path to deploymentConfig resources in etcd |
23 |
- DeploymentConfigPath string = "/deploymentConfigs" |
|
23 |
+ DeploymentConfigPath string = "/deploymentconfigs" |
|
24 | 24 |
) |
25 | 25 |
|
26 | 26 |
// Etcd implements deployment.Registry and deploymentconfig.Registry interfaces. |
... | ... |
@@ -40,12 +40,12 @@ func makeTestDefaultDeploymentListKey() string { |
40 | 40 |
} |
41 | 41 |
func makeTestDeploymentConfigListKey(namespace string) string { |
42 | 42 |
if len(namespace) != 0 { |
43 |
- return "/deploymentConfigs/" + namespace |
|
43 |
+ return "/deploymentconfigs/" + namespace |
|
44 | 44 |
} |
45 |
- return "/deploymentConfigs" |
|
45 |
+ return "/deploymentconfigs" |
|
46 | 46 |
} |
47 | 47 |
func makeTestDeploymentConfigKey(namespace, id string) string { |
48 |
- return "/deploymentConfigs/" + namespace + "/" + id |
|
48 |
+ return "/deploymentconfigs/" + namespace + "/" + id |
|
49 | 49 |
} |
50 | 50 |
func makeTestDefaultDeploymentConfigKey(id string) string { |
51 | 51 |
return makeTestDeploymentConfigKey(kapi.NamespaceDefault, id) |
... | ... |
@@ -642,7 +642,7 @@ func TestEtcdListDeploymentConfigsInDifferentNamespaces(t *testing.T) { |
642 | 642 |
fakeClient := tools.NewFakeEtcdClient(t) |
643 | 643 |
namespaceAlfa := kapi.WithNamespace(kapi.NewContext(), "alfa") |
644 | 644 |
namespaceBravo := kapi.WithNamespace(kapi.NewContext(), "bravo") |
645 |
- fakeClient.Data["/deploymentConfigs/alfa"] = tools.EtcdResponseWithError{ |
|
645 |
+ fakeClient.Data["/deploymentconfigs/alfa"] = tools.EtcdResponseWithError{ |
|
646 | 646 |
R: &etcd.Response{ |
647 | 647 |
Node: &etcd.Node{ |
648 | 648 |
Nodes: []*etcd.Node{ |
... | ... |
@@ -654,7 +654,7 @@ func TestEtcdListDeploymentConfigsInDifferentNamespaces(t *testing.T) { |
654 | 654 |
}, |
655 | 655 |
E: nil, |
656 | 656 |
} |
657 |
- fakeClient.Data["/deploymentConfigs/bravo"] = tools.EtcdResponseWithError{ |
|
657 |
+ fakeClient.Data["/deploymentconfigs/bravo"] = tools.EtcdResponseWithError{ |
|
658 | 658 |
R: &etcd.Response{ |
659 | 659 |
Node: &etcd.Node{ |
660 | 660 |
Nodes: []*etcd.Node{ |
... | ... |
@@ -692,8 +692,8 @@ func TestEtcdGetDeploymentConfigInDifferentNamespaces(t *testing.T) { |
692 | 692 |
fakeClient := tools.NewFakeEtcdClient(t) |
693 | 693 |
namespaceAlfa := kapi.WithNamespace(kapi.NewContext(), "alfa") |
694 | 694 |
namespaceBravo := kapi.WithNamespace(kapi.NewContext(), "bravo") |
695 |
- fakeClient.Set("/deploymentConfigs/alfa/foo", runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{ObjectMeta: kapi.ObjectMeta{Name: "foo"}}), 0) |
|
696 |
- fakeClient.Set("/deploymentConfigs/bravo/foo", runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{ObjectMeta: kapi.ObjectMeta{Name: "foo"}}), 0) |
|
695 |
+ fakeClient.Set("/deploymentconfigs/alfa/foo", runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{ObjectMeta: kapi.ObjectMeta{Name: "foo"}}), 0) |
|
696 |
+ fakeClient.Set("/deploymentconfigs/bravo/foo", runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{ObjectMeta: kapi.ObjectMeta{Name: "foo"}}), 0) |
|
697 | 697 |
registry := NewTestEtcd(fakeClient) |
698 | 698 |
|
699 | 699 |
alfaFoo, err := registry.GetDeploymentConfig(namespaceAlfa, "foo") |
... | ... |
@@ -100,7 +100,7 @@ func TestOverwritePolicyCommand(t *testing.T) { |
100 | 100 |
t.Errorf("unexpected error: %v", err) |
101 | 101 |
} |
102 | 102 |
|
103 |
- etcdHelper, err := origin.NewEtcdHelper(etcdClient, masterConfig.EtcdStorageConfig.OpenShiftStorageVersion, "openshift") |
|
103 |
+ etcdHelper, err := origin.NewEtcdHelper(etcdClient, masterConfig.EtcdStorageConfig.OpenShiftStorageVersion, masterConfig.EtcdStorageConfig.OpenShiftStoragePrefix) |
|
104 | 104 |
if err != nil { |
105 | 105 |
t.Errorf("unexpected error: %v", err) |
106 | 106 |
} |
... | ... |
@@ -84,7 +84,7 @@ func TestUserInitialization(t *testing.T) { |
84 | 84 |
t.Errorf("unexpected error: %v", err) |
85 | 85 |
} |
86 | 86 |
|
87 |
- etcdHelper, err := origin.NewEtcdHelper(etcdClient, masterConfig.EtcdStorageConfig.OpenShiftStorageVersion, "openshift") |
|
87 |
+ etcdHelper, err := origin.NewEtcdHelper(etcdClient, masterConfig.EtcdStorageConfig.OpenShiftStorageVersion, masterConfig.EtcdStorageConfig.OpenShiftStoragePrefix) |
|
88 | 88 |
if err != nil { |
89 | 89 |
t.Errorf("unexpected error: %v", err) |
90 | 90 |
} |