-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add arbiter node support for HA
Signed-off-by: ehila <[email protected]>
- Loading branch information
Showing
26 changed files
with
271 additions
and
1,845 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
vendor/github.com/openshift/api/config/v1/types_infrastructure.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 3 additions & 1 deletion
4
vendor/github.com/openshift/api/config/v1/zz_generated.featuregated-crd-manifests.yaml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
vendor/github.com/openshift/api/config/v1/zz_generated.swagger_doc_generated.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.