Skip to content

Commit

Permalink
Revert "Merge pull request openshift#1536 from benluddy/runtime-config"
Browse files Browse the repository at this point in the history
This reverts commit 7864ef2, reversing
changes made to 7d5e2e0.
  • Loading branch information
stbenjam committed Aug 22, 2023
1 parent a0ae1f0 commit 04846d9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 316 deletions.
1 change: 0 additions & 1 deletion bindata/assets/config/defaultconfig.yaml
Expand Up @@ -75,7 +75,6 @@ apiServerArguments:
- StorageObjectInUseProtection
- TaintNodesByCondition
- ValidatingAdmissionWebhook
- ValidatingAdmissionPolicy
- authorization.openshift.io/RestrictSubjectBindings
- authorization.openshift.io/ValidateRoleBindingRestriction
- config.openshift.io/DenyDeleteClusterConfiguration
Expand Down
2 changes: 0 additions & 2 deletions bindata/bootkube/config/bootstrap-config-overrides.yaml
Expand Up @@ -63,8 +63,6 @@ apiServerArguments:
- /etc/kubernetes/secrets/apiserver-proxy.key
requestheader-client-ca-file:
- /etc/kubernetes/secrets/aggregator-signer.crt
runtime-config: {{range .RuntimeConfig}}
- {{.}}{{end}}
service-account-key-file:
- /etc/kubernetes/secrets/service-account.pub
- /etc/kubernetes/secrets/bound-service-account-signing-key.pub
Expand Down
21 changes: 1 addition & 20 deletions pkg/cmd/render/render.go
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
"io/ioutil"
"net"
"os"
Expand All @@ -18,17 +19,14 @@ import (
configv1 "github.com/openshift/api/config/v1"
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
"github.com/openshift/cluster-kube-apiserver-operator/bindata"
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/configobservation/apienablement"
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/configobservation/auth"
libgoaudit "github.com/openshift/library-go/pkg/operator/apiserver/audit"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
genericrender "github.com/openshift/library-go/pkg/operator/render"
genericrenderoptions "github.com/openshift/library-go/pkg/operator/render/options"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
kyaml "k8s.io/apimachinery/pkg/util/yaml"
auditv1 "k8s.io/apiserver/pkg/apis/audit/v1"
"k8s.io/klog/v2"
Expand All @@ -45,16 +43,10 @@ type renderOpts struct {
clusterConfigFile string
clusterAuthFile string
infraConfigFile string

groupVersionsByFeatureGate map[configv1.FeatureGateName][]schema.GroupVersion
}

// NewRenderCommand creates a render command.
func NewRenderCommand() *cobra.Command {
return newRenderCommand()
}

func newRenderCommand(testOverrides ...func(*renderOpts)) *cobra.Command {
renderOpts := renderOpts{
generic: *genericrenderoptions.NewGenericOptions(),
manifest: *genericrenderoptions.NewManifestOptions("kube-apiserver", "openshift/origin-hyperkube:latest"),
Expand All @@ -63,9 +55,6 @@ func newRenderCommand(testOverrides ...func(*renderOpts)) *cobra.Command {
etcdServerURLs: []string{"https://127.0.0.1:2379"},
etcdServingCA: "root-ca.crt",
}
for _, f := range testOverrides {
f(&renderOpts)
}
cmd := &cobra.Command{
Use: "render",
Short: "Render kubernetes API server bootstrap manifests, secrets and configMaps",
Expand Down Expand Up @@ -137,9 +126,6 @@ func (r *renderOpts) Complete() error {
if err := r.generic.Complete(); err != nil {
return err
}
if r.groupVersionsByFeatureGate == nil {
r.groupVersionsByFeatureGate = apienablement.DefaultGroupVersionsByFeatureGate
}
return nil
}

Expand All @@ -162,9 +148,6 @@ type TemplateData struct {
// FeatureGates is list of featuregates to apply
FeatureGates []string

// RuntimeConfig is a list of API group-versions to enable or disable.
RuntimeConfig []string

// ServiceClusterIPRange is the IP range for service IPs.
ServiceCIDR []string

Expand Down Expand Up @@ -208,8 +191,6 @@ func (r *renderOpts) Run() error {
return err
}

renderConfig.RuntimeConfig = apienablement.RuntimeConfigFromFeatureGates(featureGates, r.groupVersionsByFeatureGate)

if len(r.clusterConfigFile) > 0 {
clusterConfigFileData, err := ioutil.ReadFile(r.clusterConfigFile)
if err != nil {
Expand Down
44 changes: 11 additions & 33 deletions pkg/cmd/render/render_test.go
Expand Up @@ -13,14 +13,15 @@ import (

configv1 "github.com/openshift/api/config/v1"
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/configobservation/configobservercontroller"
libgoaudit "github.com/openshift/library-go/pkg/operator/apiserver/audit"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
genericrenderoptions "github.com/openshift/library-go/pkg/operator/render/options"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
kyaml "k8s.io/apimachinery/pkg/util/yaml"
)

Expand Down Expand Up @@ -228,13 +229,17 @@ func TestRenderCommand(t *testing.T) {
}
templateDir := filepath.Join("..", "..", "..", "bindata", "bootkube")

tempDisabledFeatureGates := configobservercontroller.FeatureBlacklist
if tempDisabledFeatureGates == nil {
tempDisabledFeatureGates = sets.New[configv1.FeatureGateName]()
}

defaultFGDir := filepath.Join("testdata", "rendered", "default-fg")

tests := []struct {
// note the name is used as a name for a temporary directory
name string
args []string
overrides []func(*renderOpts)
setupFunction func() error
testFunction func(cfg *kubecontrolplanev1.KubeAPIServerConfig) error
podTestFunction func(cfg *corev1.Pod) error
Expand All @@ -249,13 +254,6 @@ func TestRenderCommand(t *testing.T) {
"--payload-version=test",
"--rendered-manifest-files=" + defaultFGDir,
},
overrides: []func(*renderOpts){
func(opts *renderOpts) {
opts.groupVersionsByFeatureGate = map[configv1.FeatureGateName][]schema.GroupVersion{
"Foo": {{Group: "foos.example.com", Version: "v4alpha7"}},
}
},
},
testFunction: func(cfg *kubecontrolplanev1.KubeAPIServerConfig) error {
actualGates, ok := cfg.APIServerArguments["feature-gates"]
if !ok {
Expand All @@ -278,21 +276,6 @@ func TestRenderCommand(t *testing.T) {
return fmt.Errorf("%q not found on the list of expected feature gates %v", actualGate, expectedGates)
}
}

actualRuntimeConfig, ok := cfg.APIServerArguments["runtime-config"]
if !ok {
return fmt.Errorf(`missing expected "runtime-config" entry in APIServerArguments`)
}
expectedRuntimeConfig := []string{"foos.example.com/v4alpha7=true"}
if len(expectedRuntimeConfig) != len(actualRuntimeConfig) {
return fmt.Errorf("expected runtime-config of len %d, got: %v (len %d)", len(expectedRuntimeConfig), actualRuntimeConfig, len(actualRuntimeConfig))
}
for i := 0; i < len(expectedRuntimeConfig); i++ {
if expectedRuntimeConfig[i] != actualRuntimeConfig[i] {
return fmt.Errorf("expected %dth runtime-config entry %q, got %q", i+1, expectedRuntimeConfig[i], actualRuntimeConfig[i])
}
}

return nil
},
},
Expand Down Expand Up @@ -612,7 +595,7 @@ spec:
}

test.args = setOutputFlags(test.args, outputDir)
err = runRender(test.args, test.overrides)
err = runRender(test.args...)
if err != nil {
t.Fatalf("%s: got unexpected error %v", test.name, err)
}
Expand Down Expand Up @@ -715,14 +698,9 @@ func setOutputFlags(args []string, dir string) []string {
return newArgs
}

func runRender(args []string, overrides []func(*renderOpts)) error {
defaultTestOverrides := []func(*renderOpts){
func(opts *renderOpts) {
opts.groupVersionsByFeatureGate = map[configv1.FeatureGateName][]schema.GroupVersion{}
},
}
c := newRenderCommand(append(defaultTestOverrides, overrides...)...)
c.SetArgs(args)
func runRender(args ...string) error {
c := NewRenderCommand()
os.Args = append([]string{""}, args...)
return c.Execute()
}

Expand Down

This file was deleted.

0 comments on commit 04846d9

Please sign in to comment.