From ef61b031f596c375e4e2cd84d77781da01f3b042 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Thu, 4 Jun 2015 11:37:44 -0700 Subject: [PATCH 1/2] make v1 enabled by default --- cmd/integration/integration.go | 1 - cmd/kube-apiserver/app/server.go | 8 +++++--- pkg/master/master.go | 6 +++--- test/integration/auth_test.go | 8 -------- test/integration/framework/master_utils.go | 1 - test/integration/scheduler_test.go | 1 - test/integration/secret_test.go | 1 - test/integration/service_account_test.go | 1 - test/integration/utils.go | 1 - 9 files changed, 8 insertions(+), 20 deletions(-) diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 918d924698eb6..093c08f614a43 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -164,7 +164,6 @@ func startComponents(firstManifestURL, secondManifestURL, apiVersion string) (st ReadWritePort: portNumber, PublicAddress: publicAddress, CacheTimeout: 2 * time.Second, - EnableV1: true, }) handler.delegate = m.Handler diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go index fd4f370fc7425..4a6e73228309e 100644 --- a/cmd/kube-apiserver/app/server.go +++ b/cmd/kube-apiserver/app/server.go @@ -282,8 +282,10 @@ func (s *APIServer) Run(_ []string) error { disableV1beta3 := disableAllAPIs disableV1beta3 = !s.getRuntimeConfigValue("api/v1beta3", !disableV1beta3) - // V1 is disabled by default. Users can enable it using "api/v1={true}". - _, enableV1 := s.RuntimeConfig["api/v1"] + // "api/v1={true|false} allows users to enable/disable v1 API. + // This takes preference over api/all and api/legacy, if specified. + disableV1 := disableAllAPIs + disableV1 = !s.getRuntimeConfigValue("api/v1", !disableV1) // TODO: expose same flags as client.BindClientConfigFlags but for a server clientConfig := &client.Config{ @@ -371,7 +373,7 @@ func (s *APIServer) Run(_ []string) error { Authorizer: authorizer, AdmissionControl: admissionController, DisableV1Beta3: disableV1beta3, - EnableV1: enableV1, + DisableV1: disableV1, MasterServiceNamespace: s.MasterServiceNamespace, ClusterName: s.ClusterName, ExternalHost: s.ExternalHost, diff --git a/pkg/master/master.go b/pkg/master/master.go index 9cc85ac15a538..47b1b009e2e5b 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -91,8 +91,8 @@ type Config struct { EnableSwaggerSupport bool // allow v1beta3 to be conditionally disabled DisableV1Beta3 bool - // allow v1 to be conditionally enabled - EnableV1 bool + // allow v1 to be conditionally disabled + DisableV1 bool // allow downstream consumers to disable the index route EnableIndex bool EnableProfiling bool @@ -313,7 +313,7 @@ func New(c *Config) *Master { authorizer: c.Authorizer, admissionControl: c.AdmissionControl, v1beta3: !c.DisableV1Beta3, - v1: c.EnableV1, + v1: !c.DisableV1, requestContextMapper: c.RequestContextMapper, cacheTimeout: c.CacheTimeout, diff --git a/test/integration/auth_test.go b/test/integration/auth_test.go index 490127543b19e..ada2c441df74d 100644 --- a/test/integration/auth_test.go +++ b/test/integration/auth_test.go @@ -397,7 +397,6 @@ func TestAuthModeAlwaysAllow(t *testing.T) { APIPrefix: "/api", Authorizer: apiserver.NewAlwaysAllowAuthorizer(), AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) transport := http.DefaultTransport @@ -538,7 +537,6 @@ func TestAuthModeAlwaysDeny(t *testing.T) { APIPrefix: "/api", Authorizer: apiserver.NewAlwaysDenyAuthorizer(), AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) transport := http.DefaultTransport @@ -607,7 +605,6 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) { Authenticator: getTestTokenAuth(), Authorizer: allowAliceAuthorizer{}, AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) previousResourceVersion := make(map[string]float64) @@ -695,7 +692,6 @@ func TestBobIsForbidden(t *testing.T) { Authenticator: getTestTokenAuth(), Authorizer: allowAliceAuthorizer{}, AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) transport := http.DefaultTransport @@ -757,7 +753,6 @@ func TestUnknownUserIsUnauthorized(t *testing.T) { Authenticator: getTestTokenAuth(), Authorizer: allowAliceAuthorizer{}, AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) transport := http.DefaultTransport @@ -838,7 +833,6 @@ func TestNamespaceAuthorization(t *testing.T) { Authenticator: getTestTokenAuth(), Authorizer: a, AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) previousResourceVersion := make(map[string]float64) @@ -954,7 +948,6 @@ func TestKindAuthorization(t *testing.T) { Authenticator: getTestTokenAuth(), Authorizer: a, AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) previousResourceVersion := make(map[string]float64) @@ -1057,7 +1050,6 @@ func TestReadOnlyAuthorization(t *testing.T) { Authenticator: getTestTokenAuth(), Authorizer: a, AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) transport := http.DefaultTransport diff --git a/test/integration/framework/master_utils.go b/test/integration/framework/master_utils.go index af3f8897ff511..df97ec34fe9f2 100644 --- a/test/integration/framework/master_utils.go +++ b/test/integration/framework/master_utils.go @@ -272,7 +272,6 @@ func RunAMaster(t *testing.T) (*master.Master, *httptest.Server) { APIPrefix: "/api", Authorizer: apiserver.NewAlwaysAllowAuthorizer(), AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { diff --git a/test/integration/scheduler_test.go b/test/integration/scheduler_test.go index a8d7db1fd72d9..e1733929c7e9c 100644 --- a/test/integration/scheduler_test.go +++ b/test/integration/scheduler_test.go @@ -75,7 +75,6 @@ func TestUnschedulableNodes(t *testing.T) { APIPrefix: "/api", Authorizer: apiserver.NewAlwaysAllowAuthorizer(), AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) restClient := client.NewOrDie(&client.Config{Host: s.URL, Version: testapi.Version()}) diff --git a/test/integration/secret_test.go b/test/integration/secret_test.go index 85ffece763cf4..b6c0ed7d4df0c 100644 --- a/test/integration/secret_test.go +++ b/test/integration/secret_test.go @@ -68,7 +68,6 @@ func TestSecrets(t *testing.T) { APIPrefix: "/api", Authorizer: apiserver.NewAlwaysAllowAuthorizer(), AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) framework.DeleteAllEtcdKeys() diff --git a/test/integration/service_account_test.go b/test/integration/service_account_test.go index 94667b15b0f3d..1c3d692b24403 100644 --- a/test/integration/service_account_test.go +++ b/test/integration/service_account_test.go @@ -419,7 +419,6 @@ func startServiceAccountTestServer(t *testing.T) (*client.Client, client.Config, Authenticator: authenticator, Authorizer: authorizer, AdmissionControl: serviceAccountAdmission, - EnableV1: true, }) // Start the service account and service account token controllers diff --git a/test/integration/utils.go b/test/integration/utils.go index 265c13beab33c..d8e5187b48583 100644 --- a/test/integration/utils.go +++ b/test/integration/utils.go @@ -82,7 +82,6 @@ func runAMaster(t *testing.T) (*master.Master, *httptest.Server) { APIPrefix: "/api", Authorizer: apiserver.NewAlwaysAllowAuthorizer(), AdmissionControl: admit.NewAlwaysAdmit(), - EnableV1: true, }) s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { From 21bea6e8e7181a887890a3853a434f293443140e Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Thu, 4 Jun 2015 11:57:20 -0700 Subject: [PATCH 2/2] since v1 is defaultly enabled, don't explicit enable it in update-swagger-spec.sh --- hack/update-swagger-spec.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/hack/update-swagger-spec.sh b/hack/update-swagger-spec.sh index 6335c50ac8edc..cfe3639c955b9 100755 --- a/hack/update-swagger-spec.sh +++ b/hack/update-swagger-spec.sh @@ -53,7 +53,6 @@ kube::log::status "Starting kube-apiserver" --etcd_servers="http://${ETCD_HOST}:${ETCD_PORT}" \ --public_address_override="127.0.0.1" \ --kubelet_port=${KUBELET_PORT} \ - --runtime_config=api/v1 \ --runtime_config=api/legacy=false \ --service-cluster-ip-range="10.0.0.0/24" 1>&2 & APISERVER_PID=$!