Skip to content

use a more 'normal' storage factory #20741

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/cmd/openshift-apiserver/openshiftapiserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"github.com/openshift/origin/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing"
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
originadmission "github.com/openshift/origin/pkg/cmd/server/origin/admission"
originrest "github.com/openshift/origin/pkg/cmd/server/origin/rest"
"github.com/openshift/origin/pkg/image/apiserver/registryhostname"
sccstorage "github.com/openshift/origin/pkg/security/apiserver/registry/securitycontextconstraints/etcd"
usercache "github.com/openshift/origin/pkg/user/cache"
"github.com/openshift/origin/pkg/util/restoptions"
"github.com/openshift/origin/pkg/version"
)

Expand All @@ -49,7 +49,7 @@ func NewOpenshiftAPIConfig(openshiftAPIServerConfig *configapi.MasterConfig) (*O
if err != nil {
return nil, err
}
restOptsGetter, err := originrest.StorageOptions(*openshiftAPIServerConfig)
restOptsGetter, err := restoptions.NewConfigGetter(*openshiftAPIServerConfig)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package configprocessing

import (
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
cmdflags "github.com/openshift/origin/pkg/cmd/util/flags"
"k8s.io/apimachinery/pkg/runtime/schema"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apiserver/pkg/server/options"
"k8s.io/apiserver/pkg/storage/storagebackend"
)

// GetEtcdOptions takes configuration information and flag overrides to produce the upstream etcdoptions.
func GetEtcdOptions(startingFlags map[string][]string, etcdConnectionInfo configapi.EtcdConnectionInfo, storagePrefix string, defaultWatchCacheSizes map[schema.GroupResource]int) (*options.EtcdOptions, error) {
storageConfig := storagebackend.NewDefaultConfig(storagePrefix, nil)
storageConfig.Type = "etcd3"
storageConfig.ServerList = etcdConnectionInfo.URLs
storageConfig.KeyFile = etcdConnectionInfo.ClientCert.KeyFile
storageConfig.CertFile = etcdConnectionInfo.ClientCert.CertFile
storageConfig.CAFile = etcdConnectionInfo.CA

etcdOptions := options.NewEtcdOptions(storageConfig)
etcdOptions.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
etcdOptions.DefaultWatchCacheSize = 0
if err := cmdflags.ResolveIgnoreMissing(startingFlags, etcdOptions.AddFlags); len(err) > 0 {
return nil, utilerrors.NewAggregate(err)
}

if etcdOptions.EnableWatchCache {
watchCacheSizes := map[schema.GroupResource]int{}
for k, v := range defaultWatchCacheSizes {
watchCacheSizes[k] = v
}

if userSpecified, err := options.ParseWatchCacheSizes(etcdOptions.WatchCacheSizes); err == nil {
for resource, size := range userSpecified {
watchCacheSizes[resource] = size
}
}

var err error
etcdOptions.WatchCacheSizes, err = options.WriteWatchCacheSizes(watchCacheSizes)
if err != nil {
return nil, err
}
}

return etcdOptions, nil
}
14 changes: 4 additions & 10 deletions pkg/cmd/server/kubernetes/master/master_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,10 @@ func BuildKubeAPIserverOptions(masterConfig configapi.MasterConfig) (*kapiserver
}
}

server.Etcd.EnableGarbageCollection = true
server.Etcd.StorageConfig.Type = "etcd3"
server.Etcd.DefaultStorageMediaType = "application/json" // TODO(post-1.6.1-rebase): enable protobuf with etcd3 as upstream
server.Etcd.StorageConfig.Quorum = true
server.Etcd.StorageConfig.Prefix = masterConfig.EtcdStorageConfig.KubernetesStoragePrefix
server.Etcd.StorageConfig.ServerList = masterConfig.EtcdClientInfo.URLs
server.Etcd.StorageConfig.KeyFile = masterConfig.EtcdClientInfo.ClientCert.KeyFile
server.Etcd.StorageConfig.CertFile = masterConfig.EtcdClientInfo.ClientCert.CertFile
server.Etcd.StorageConfig.CAFile = masterConfig.EtcdClientInfo.CA
server.Etcd.DefaultWatchCacheSize = 0
server.Etcd, err = configprocessing.GetEtcdOptions(masterConfig.KubernetesMasterConfig.APIServerArguments, masterConfig.EtcdClientInfo, masterConfig.EtcdStorageConfig.KubernetesStoragePrefix, nil)
if err != nil {
return nil, err
}

server.GenericServerRunOptions.CorsAllowedOriginList = masterConfig.CORSAllowedOrigins
server.GenericServerRunOptions.MaxRequestsInFlight = masterConfig.ServingInfo.MaxRequestsInFlight
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/server/origin/master_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
kubernetes "github.com/openshift/origin/pkg/cmd/server/kubernetes/master"
originadmission "github.com/openshift/origin/pkg/cmd/server/origin/admission"
originrest "github.com/openshift/origin/pkg/cmd/server/origin/rest"
imageadmission "github.com/openshift/origin/pkg/image/apiserver/admission/limitrange"
imageinformer "github.com/openshift/origin/pkg/image/generated/informers/internalversion"
_ "github.com/openshift/origin/pkg/printers/internalversion"
Expand Down Expand Up @@ -131,7 +130,7 @@ func BuildMasterConfig(
informers = realLoopbackInformers
}

restOptsGetter, err := originrest.StorageOptions(options)
restOptsGetter, err := restoptions.NewConfigGetter(options)
if err != nil {
return nil, err
}
Expand Down
59 changes: 0 additions & 59 deletions pkg/cmd/server/origin/rest/storage_options.go

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/cmd/server/start/master_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,6 @@ func (args MasterArgs) BuildSerializeableMasterConfig() (*configapi.MasterConfig
// When creating a new config, use Protobuf
configapi.SetProtobufClientDefaults(config.MasterClients.OpenShiftLoopbackClientConnectionOverrides)

// Default storage backend to etcd3 with protobuf storage for our innate config when starting both
// Kubernetes and etcd.
if config.EtcdConfig != nil {
if len(config.KubernetesMasterConfig.APIServerArguments) == 0 {
config.KubernetesMasterConfig.APIServerArguments = configapi.ExtendedArguments{}
config.KubernetesMasterConfig.APIServerArguments["storage-media-type"] = []string{"application/vnd.kubernetes.protobuf"}
config.KubernetesMasterConfig.APIServerArguments["storage-backend"] = []string{"etcd3"}
}
}

return config, nil
}

Expand Down
16 changes: 13 additions & 3 deletions pkg/cmd/util/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import (

// Apply stores the provided arguments onto a flag set, reporting any errors
// encountered during the process.
func Apply(args map[string][]string, flags *pflag.FlagSet) []error {
func apply(args map[string][]string, flags *pflag.FlagSet, ignoreMissing bool) []error {
var errs []error
for key, value := range args {
flag := flags.Lookup(key)
if flag == nil {
errs = append(errs, field.Invalid(field.NewPath("flag"), key, "is not a valid flag"))
if !ignoreMissing {
errs = append(errs, field.Invalid(field.NewPath("flag"), key, "is not a valid flag"))
}
continue
}
for _, s := range value {
Expand All @@ -33,7 +35,15 @@ func Apply(args map[string][]string, flags *pflag.FlagSet) []error {
func Resolve(args map[string][]string, fn func(*pflag.FlagSet)) []error {
fs := pflag.NewFlagSet("extended", pflag.ContinueOnError)
fn(fs)
return Apply(args, fs)
return apply(args, fs, false)
}

// ResolveIgnoreMissing resolves flags in the args, but does not fail on missing flags. It silently skips those.
// It's useful for building subsets of the full options, but validation should do a normal binding.
func ResolveIgnoreMissing(args map[string][]string, fn func(*pflag.FlagSet)) []error {
fs := pflag.NewFlagSet("extended", pflag.ContinueOnError)
fn(fs)
return apply(args, fs, true)
}

// ComponentFlag represents a set of enabled components used in a command line.
Expand Down
2 changes: 0 additions & 2 deletions pkg/oc/clusterup/coreinstall/kubeapiserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ func (opt KubeAPIServerStartConfig) MakeMasterConfig(dockerClient dockerhelper.I
return "", err
}

masterconfig.KubernetesMasterConfig.APIServerArguments["feature-gates"] = []string{"CustomResourceSubresources=true"}
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 now on by default.


if err := componentinstall.WriteMasterConfig(masterconfigFilename, masterconfig); err != nil {
return "", err
}
Expand Down
Loading