Skip to content

Commit

Permalink
UPSTREAM: <carry>: [o/k-apiserver] Move openshiftfeatures.InitializeF…
Browse files Browse the repository at this point in the history
…eatureGates call outside cmd.RunE

- fixes failing apiserver startup

Signed-off-by: Swarup Ghosh <swghosh@redhat.com>
  • Loading branch information
swghosh committed Feb 7, 2024
1 parent 8d1fa16 commit c813175
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
20 changes: 17 additions & 3 deletions cmd/kube-apiserver/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"os"
"time"

configv1 "github.com/openshift/api/config/v1"
openshiftfeatures "github.com/openshift/library-go/pkg/features"
"k8s.io/kubernetes/openshift-kube-apiserver/admission/admissionenablement"
"k8s.io/kubernetes/openshift-kube-apiserver/enablement"
"k8s.io/kubernetes/openshift-kube-apiserver/openshiftkubeapiserver"
Expand Down Expand Up @@ -82,6 +84,12 @@ import (
"k8s.io/kubernetes/pkg/serviceaccount"
)

// OpenShiftKubeAPIServerFeatureGates contains list of feature gates that
// will be honored by openshift-kube-apiserver
var OpenShiftKubeAPIServerFeatureGates []configv1.FeatureGateName = []configv1.FeatureGateName{
configv1.FeatureGateRouteExternalCertificate,
}

func init() {
utilruntime.Must(logsapi.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
}
Expand Down Expand Up @@ -138,9 +146,7 @@ cluster's shared state through which all other components interact.`,
// print merged flags (merged from OpenshiftConfig)
cliflag.PrintFlags(cmd.Flags())

if err := enablement.ForceGlobalInitializationForOpenShift(); err != nil {
return err
}
enablement.ForceGlobalInitializationForOpenShift()
} else {
// print default flags
cliflag.PrintFlags(cmd.Flags())
Expand Down Expand Up @@ -170,6 +176,14 @@ cluster's shared state through which all other components interact.`,
},
}

// openshift feature gates need to be mandatorily initialized before flag set is used
// feature gates
if err := openshiftfeatures.InitializeFeatureGates(utilfeature.DefaultMutableFeatureGate,
OpenShiftKubeAPIServerFeatureGates...,
); err != nil {
klog.Fatal(err)
}

fs := cmd.Flags()
namedFlagSets := s.Flags()
verflag.AddFlags(namedFlagSets.FlagSet("global"))
Expand Down
10 changes: 1 addition & 9 deletions openshift-kube-apiserver/enablement/intialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import (
osinv1 "github.com/openshift/api/osin/v1"
"github.com/openshift/apiserver-library-go/pkg/securitycontextconstraints/sccadmission"
"github.com/openshift/library-go/pkg/config/helpers"
openshiftfeatures "github.com/openshift/library-go/pkg/features"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/tools/clientcmd/api"
aggregatorapiserver "k8s.io/kube-aggregator/pkg/apiserver"
"k8s.io/kubernetes/openshift-kube-apiserver/configdefault"
Expand Down Expand Up @@ -65,7 +63,7 @@ func GetOpenshiftConfig(openshiftConfigFile string) (*kubecontrolplanev1.KubeAPI
return config, nil
}

func ForceGlobalInitializationForOpenShift() error {
func ForceGlobalInitializationForOpenShift() {
// This allows to move crqs, sccs, and rbrs to CRD
aggregatorapiserver.AddAlwaysLocalDelegateForPrefix("/apis/quota.openshift.io/v1/clusterresourcequotas")
aggregatorapiserver.AddAlwaysLocalDelegateForPrefix("/apis/security.openshift.io/v1/securitycontextconstraints")
Expand Down Expand Up @@ -95,12 +93,6 @@ func ForceGlobalInitializationForOpenShift() error {
// we need to have the authorization chain place something before system:masters
// SkipSystemMastersAuthorizer disable implicitly added system/master authz, and turn it into another authz mode "SystemMasters", to be added via authorization-mode
authorizer.SkipSystemMastersAuthorizer()

// initialize openshift specific feature gates that o-kubeapiserver will honor
return openshiftfeatures.InitializeFeatureGates(
feature.DefaultMutableFeatureGate,
OpenShiftKubeAPIServerFeatureGates...,
)
}

var SCCAdmissionPlugin = sccadmission.NewConstraint()

0 comments on commit c813175

Please sign in to comment.