Skip to content

Commit

Permalink
feat: add arbiter node support for HA
Browse files Browse the repository at this point in the history
Signed-off-by: ehila <[email protected]>
  • Loading branch information
eggfoobar committed Nov 18, 2024
1 parent 570755c commit 9e6bd74
Show file tree
Hide file tree
Showing 26 changed files with 271 additions and 1,845 deletions.
14 changes: 8 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ require (
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/go-test/deep v1.0.5
github.com/google/go-cmp v0.6.0
github.com/openshift/api v0.0.0-20241108125904-424692fe047e
github.com/openshift/api v0.0.0-20241001152557-e415140e5d5f
github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f
github.com/openshift/library-go v0.0.0-20241023193830-022ad9c25e39
github.com/openshift/library-go v0.0.0-20241031155608-38d7fa78906f
github.com/spf13/cobra v1.8.1
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.31.1
k8s.io/api v0.31.2
k8s.io/apiextensions-apiserver v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
k8s.io/component-base v0.31.1
k8s.io/apimachinery v0.31.2
k8s.io/client-go v0.31.2
k8s.io/component-base v0.31.2
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6
)
Expand Down Expand Up @@ -117,3 +117,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/openshift/api => github.com/eggfoobar/api v0.0.0-20241104223900-c174c2e87bad
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/eggfoobar/api v0.0.0-20241104223900-c174c2e87bad h1:vS60IJcnvwTgddV2ws7T5qpVEx8+RNZCoS4qDOBwcwk=
github.com/eggfoobar/api v0.0.0-20241104223900-c174c2e87bad/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
Expand Down Expand Up @@ -146,14 +148,12 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
github.com/openshift/api v0.0.0-20241108125904-424692fe047e h1:zFI0guz2FQa7NnrCPPCDpDrivKtfzHvE1OPv8nj2IZ8=
github.com/openshift/api v0.0.0-20241108125904-424692fe047e/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660 h1:F0zE2bmdVvaEd18VXuGYQdJJ1FYJu4MIDW9PYZWc9No=
github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f h1:FRc0bVNWprihWS0GqQWzb3dY4dkCwpOP3mDw5NwSoR4=
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f/go.mod h1:KiZi2mJRH1TOJ3FtBDYS6YvUL30s/iIXaGSUrSa36mo=
github.com/openshift/library-go v0.0.0-20241023193830-022ad9c25e39 h1:QUoMgNRHKDX0BXCbsdYHwoIyqYBGSJy9dNBAph9WqEU=
github.com/openshift/library-go v0.0.0-20241023193830-022ad9c25e39/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0=
github.com/openshift/library-go v0.0.0-20241031155608-38d7fa78906f h1:icrlLxyaweoVL33EvqEzz7glD3WflXNuXlpCfCvJCPg=
github.com/openshift/library-go v0.0.0-20241031155608-38d7fa78906f/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0=
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -319,18 +319,18 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.31.1 h1:Xe1hX/fPW3PXYYv8BlozYqw63ytA92snr96zMW9gWTU=
k8s.io/api v0.31.1/go.mod h1:sbN1g6eY6XVLeqNsZGLnI5FwVseTrZX7Fv3O26rhAaI=
k8s.io/api v0.31.2 h1:3wLBbL5Uom/8Zy98GRPXpJ254nEFpl+hwndmk9RwmL0=
k8s.io/api v0.31.2/go.mod h1:bWmGvrGPssSK1ljmLzd3pwCQ9MgoTsRCuK35u6SygUk=
k8s.io/apiextensions-apiserver v0.31.1 h1:L+hwULvXx+nvTYX/MKM3kKMZyei+UiSXQWciX/N6E40=
k8s.io/apiextensions-apiserver v0.31.1/go.mod h1:tWMPR3sgW+jsl2xm9v7lAyRF1rYEK71i9G5dRtkknoQ=
k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U=
k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo=
k8s.io/apimachinery v0.31.2 h1:i4vUt2hPK56W6mlT7Ry+AO8eEsyxMD1U44NR22CLTYw=
k8s.io/apimachinery v0.31.2/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo=
k8s.io/apiserver v0.31.1 h1:Sars5ejQDCRBY5f7R3QFHdqN3s61nhkpaX8/k1iEw1c=
k8s.io/apiserver v0.31.1/go.mod h1:lzDhpeToamVZJmmFlaLwdYZwd7zB+WYRYIboqA1kGxM=
k8s.io/client-go v0.31.1 h1:f0ugtWSbWpxHR7sjVpQwuvw9a3ZKLXX0u0itkFXufb0=
k8s.io/client-go v0.31.1/go.mod h1:sKI8871MJN2OyeqRlmA4W4KM9KBdBUpDLu/43eGemCg=
k8s.io/component-base v0.31.1 h1:UpOepcrX3rQ3ab5NB6g5iP0tvsgJWzxTyAo20sgYSy8=
k8s.io/component-base v0.31.1/go.mod h1:WGeaw7t/kTsqpVTaCoVEtillbqAhF2/JgvO0LDOMa0w=
k8s.io/client-go v0.31.2 h1:Y2F4dxU5d3AQj+ybwSMqQnpZH9F30//1ObxOKlTI9yc=
k8s.io/client-go v0.31.2/go.mod h1:NPa74jSVR/+eez2dFsEIHNa+3o09vtNaWwWwb1qSxSs=
k8s.io/component-base v0.31.2 h1:Z1J1LIaC0AV+nzcPRFqfK09af6bZ4D1nAOpWsy9owlA=
k8s.io/component-base v0.31.2/go.mod h1:9PeyyFN/drHjtJZMCTkSpQJS3U9OXORnHQqMLDz0sUQ=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kms v0.31.1 h1:cGLyV3cIwb0ovpP/jtyIe2mEuQ/MkbhmeBF2IYCA9Io=
Expand Down
2 changes: 1 addition & 1 deletion pkg/console/controllers/oidcsetup/oidcsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (c *oidcSetupController) syncAuthTypeOIDC(ctx context.Context, authnConfig
recorder,
caCM.Namespace, caCM.Name,
api.TargetNamespace, caCM.Name,
sets.New[string]("ca-bundle.crt"),
sets.New("ca-bundle.crt"),
[]metav1.OwnerReference{*utilsub.OwnerRefFrom(operatorConfig)})

if err != nil {
Expand Down
96 changes: 96 additions & 0 deletions pkg/console/operatorclient/operatorclient.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package operatorclient

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"

operatorv1 "github.com/openshift/api/operator/v1"
applyoperatorv1 "github.com/openshift/client-go/operator/applyconfigurations/operator/v1"
operatorv1client "github.com/openshift/client-go/operator/clientset/versioned/typed/operator/v1"
operatorv1informers "github.com/openshift/client-go/operator/informers/externalversions"
"github.com/openshift/console-operator/pkg/api"
"github.com/openshift/library-go/pkg/apiserver/jsonpatch"
)

type OperatorClient struct {
Informers operatorv1informers.SharedInformerFactory
Client operatorv1client.ConsolesGetter
Context context.Context
}

func (c *OperatorClient) Informer() cache.SharedIndexInformer {
return c.Informers.Operator().V1().Consoles().Informer()
}

func (c OperatorClient) GetObjectMeta() (*metav1.ObjectMeta, error) {
instance, err := c.Informers.Operator().V1().Consoles().Lister().Get(api.ConfigResourceName)
if err != nil {
return nil, err
}
return &instance.ObjectMeta, nil
}

func (c *OperatorClient) GetOperatorState() (*operatorv1.OperatorSpec, *operatorv1.OperatorStatus, string, error) {
instance, err := c.Informers.Operator().V1().Consoles().Lister().Get(api.ConfigResourceName)
if err != nil {
return nil, nil, "", err
}

return &instance.Spec.OperatorSpec, &instance.Status.OperatorStatus, instance.ResourceVersion, nil
}

func (c *OperatorClient) UpdateOperatorSpec(ctx context.Context, resourceVersion string, spec *operatorv1.OperatorSpec) (*operatorv1.OperatorSpec, string, error) {
original, err := c.Informers.Operator().V1().Consoles().Lister().Get(api.ConfigResourceName)
if err != nil {
return nil, "", err
}
copy := original.DeepCopy()
copy.ResourceVersion = resourceVersion
copy.Spec.OperatorSpec = *spec

ret, err := c.Client.Consoles().Update(c.Context, copy, metav1.UpdateOptions{})
if err != nil {
return nil, "", err
}

return &ret.Spec.OperatorSpec, ret.ResourceVersion, nil
}
func (c *OperatorClient) UpdateOperatorStatus(ctx context.Context, resourceVersion string, status *operatorv1.OperatorStatus) (*operatorv1.OperatorStatus, error) {
original, err := c.Informers.Operator().V1().Consoles().Lister().Get(api.ConfigResourceName)
if err != nil {
return nil, err
}
copy := original.DeepCopy()
copy.ResourceVersion = resourceVersion
copy.Status.OperatorStatus = *status

ret, err := c.Client.Consoles().UpdateStatus(c.Context, copy, metav1.UpdateOptions{})
if err != nil {
return nil, err
}

return &ret.Status.OperatorStatus, nil
}

func (c OperatorClient) GetOperatorStateWithQuorum(ctx context.Context) (*operatorv1.OperatorSpec, *operatorv1.OperatorStatus, string, error) {
instance, err := c.Client.Consoles().Get(ctx, api.ConfigResourceName, metav1.GetOptions{})
if err != nil {
return nil, nil, "", err
}

return &instance.Spec.OperatorSpec, &instance.Status.OperatorStatus, instance.GetResourceVersion(), nil
}

func (c OperatorClient) ApplyOperatorSpec(ctx context.Context, fieldManager string, applyConfiguration *applyoperatorv1.OperatorSpecApplyConfiguration) (err error) {
return nil
}

func (c OperatorClient) ApplyOperatorStatus(ctx context.Context, fieldManager string, applyConfiguration *applyoperatorv1.OperatorStatusApplyConfiguration) (err error) {
return nil
}

func (c OperatorClient) PatchOperatorStatus(ctx context.Context, jsonPatch *jsonpatch.PatchSet) (err error) {
return nil
}
4 changes: 2 additions & 2 deletions pkg/console/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle
recorder,
)

configUpgradeableController := unsupportedconfigoverridescontroller.NewUnsupportedConfigOverridesController(operatorClient, controllerContext.EventRecorder)
configUpgradeableController := unsupportedconfigoverridescontroller.NewUnsupportedConfigOverridesController("configUpgradeableController", operatorClient, controllerContext.EventRecorder)
logLevelController := loglevel.NewClusterOperatorLoggingController(operatorClient, controllerContext.EventRecorder)
managementStateController := managementstatecontroller.NewOperatorManagementStateController(api.ClusterOperatorName, operatorClient, controllerContext.EventRecorder)

Expand Down Expand Up @@ -613,7 +613,7 @@ func getResourceSyncer(controllerContext *controllercmd.ControllerContext, kubeC
api.OpenShiftConfigManagedNamespace,
)
resourceSyncer := resourcesynccontroller.NewResourceSyncController(
"console",
"resourceSyncer",
operatorClient,
resourceSyncerInformers,
v1helpers.CachedSecretGetter(kubeClient.CoreV1(), resourceSyncerInformers),
Expand Down
1 change: 1 addition & 0 deletions pkg/console/subresource/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func DefaultDownloadsDeployment(
// otherwise it should be deployed in HA mode based on the ControlPlaneTopology.
func ShouldDeployHA(infrastructureConfig *configv1.Infrastructure) bool {
return infrastructureConfig.Status.ControlPlaneTopology == configv1.HighlyAvailableTopologyMode ||
infrastructureConfig.Status.ControlPlaneTopology == configv1.HighlyAvailableArbiter ||
(infrastructureConfig.Status.ControlPlaneTopology == configv1.ExternalTopologyMode &&
infrastructureConfig.Status.InfrastructureTopology == configv1.HighlyAvailableTopologyMode)
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/openshift/api/config/v1/types_node.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9e6bd74

Please sign in to comment.