Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
name: release
namespace: openshift
tag: rhel-8-release-golang-1.16-openshift-4.10
tag: rhel-8-release-golang-1.17-openshift-4.10
2 changes: 1 addition & 1 deletion Dockerfile.rhel7
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.16-openshift-4.10 AS builder
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.17-openshift-4.10 AS builder
WORKDIR /go/src/github.com/openshift/console-operator
COPY . .
ENV GO_PACKAGE github.com/openshift/console-operator
Expand Down
25 changes: 3 additions & 22 deletions cmd/console/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,24 @@ package main

import (
// standard lib
goflag "flag"
"fmt"
"math/rand"
"os"
"time"

// 3rd party
"github.com/spf13/cobra"
"github.com/spf13/pflag"

// kube / openshift
utilflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
"k8s.io/component-base/cli"

// us
"github.com/openshift/console-operator/pkg/cmd/operator"
"github.com/openshift/console-operator/pkg/cmd/version"
)

func main() {
// random seed, set it & forget it
rand.Seed(time.Now().UTC().UnixNano())
// normalize flags, if _ use -
pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
// add the default flag set for go
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)

logs.InitLogs()
defer logs.FlushLogs()

// build a new cobra command
command := NewOperatorCommand()
// die on errors
if err := command.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
code := cli.Run(command)
os.Exit(code)
}

// create the root "console" command
Expand Down
22 changes: 10 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ require (
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/go-test/deep v1.0.5
github.com/google/gofuzz v1.2.0 // indirect
github.com/openshift/api v0.0.0-20211103080632-8981c8822dfa
github.com/openshift/build-machinery-go v0.0.0-20210712174854-1bb7fd1518d3
github.com/openshift/client-go v0.0.0-20211104174419-390ab1a408da
github.com/openshift/library-go v0.0.0-20210330121117-68dd4a4c9d9e
github.com/openshift/api v0.0.0-20211209135129-c58d9f695577
github.com/openshift/build-machinery-go v0.0.0-20211213093930-7e33a7eb4ce3
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3
github.com/openshift/library-go v0.0.0-20211220195323-eca2c467c492
github.com/pkg/profile v1.4.0 // indirect
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
github.com/spf13/cobra v1.2.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.22.1
k8s.io/apiextensions-apiserver v0.22.1 // indirect
k8s.io/apimachinery v0.22.1
k8s.io/client-go v0.22.1
k8s.io/component-base v0.22.1
k8s.io/klog/v2 v2.9.0
k8s.io/api v0.23.0
k8s.io/apimachinery v0.23.0
k8s.io/client-go v0.23.0
k8s.io/component-base v0.23.0
k8s.io/klog/v2 v2.30.0
)

replace (
Expand Down
311 changes: 238 additions & 73 deletions go.sum

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions manifests/03-rbac-role-ns-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ rules:
- get
- list
- watch
- apiGroups:
- config.openshift.io
resources:
- infrastructures
verbs:
- get
- list
- watch
2 changes: 1 addition & 1 deletion pkg/console/controllers/downloadsdeployment/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (c *DownloadsDeploymentSyncController) SyncDownloadsDeployment(ctx context.
updatedOperatorConfig := operatorConfig.DeepCopy()
requiredDownloadsDeployment := deploymentsub.DefaultDownloadsDeployment(updatedOperatorConfig, infrastructureConfig)

return resourceapply.ApplyDeployment(
return resourceapply.ApplyDeployment(ctx,
c.deploymentClient,
controllerContext.Recorder(),
requiredDownloadsDeployment,
Expand Down
2 changes: 1 addition & 1 deletion pkg/console/controllers/route/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestValidateCustomCertSecret(t *testing.T) {
},
want: want{
customTLSCert: nil,
err: fmt.Errorf("failed to verify custom certificate PEM: asn1: syntax error: data truncated"),
err: fmt.Errorf("failed to verify custom certificate PEM: x509: malformed certificate"),
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions pkg/console/controllers/service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *ServiceSyncController) Sync(ctx context.Context, controllerContext fact
routeConfig := routesub.NewRouteConfig(updatedOperatorConfig, ingressConfig, c.serviceName)

requiredSvc := c.getDefaultService()
_, _, svcErr := resourceapply.ApplyService(c.serviceClient, controllerContext.Recorder(), requiredSvc)
_, _, svcErr := resourceapply.ApplyService(ctx, c.serviceClient, controllerContext.Recorder(), requiredSvc)
statusHandler.AddConditions(status.HandleProgressingOrDegraded("ServiceSync", "FailedApply", svcErr))
if svcErr != nil {
return statusHandler.FlushAndReturn(svcErr)
Expand All @@ -137,7 +137,7 @@ func (c *ServiceSyncController) SyncRedirectService(ctx context.Context, routeCo
return "", nil
}
requiredRedirectService := c.getRedirectService()
_, _, redirectSvcErr := resourceapply.ApplyService(c.serviceClient, controllerContext.Recorder(), requiredRedirectService)
_, _, redirectSvcErr := resourceapply.ApplyService(ctx, c.serviceClient, controllerContext.Recorder(), requiredRedirectService)
if redirectSvcErr != nil {
return "FailedApply", redirectSvcErr
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/console/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (c *consoleOperator) removeConsole(ctx context.Context, recorder events.Rec
// NOTE: CVO controls the deployment for downloads, console-operator cannot delete it.
errs = append(errs, c.deploymentClient.Deployments(api.TargetNamespace).Delete(ctx, deployment.Stub().Name, metav1.DeleteOptions{}))
// clear the console URL from the public config map in openshift-config-managed
_, _, updateConfigErr := resourceapply.ApplyConfigMap(c.configMapClient, recorder, configmap.EmptyPublicConfig())
_, _, updateConfigErr := resourceapply.ApplyConfigMap(ctx, c.configMapClient, recorder, configmap.EmptyPublicConfig())
errs = append(errs, updateConfigErr)

return utilerrors.FilterOut(utilerrors.NewAggregate(errs), errors.IsNotFound)
Expand Down
11 changes: 6 additions & 5 deletions pkg/console/operator/sync_v400.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (co *consoleOperator) sync_v400(ctx context.Context, controllerContext fact
return statusHandler.FlushAndReturn(consoleConfigErr)
}

_, _, consolePublicConfigErr := co.SyncConsolePublicConfig(consoleURL.String(), controllerContext.Recorder())
_, _, consolePublicConfigErr := co.SyncConsolePublicConfig(ctx, consoleURL.String(), controllerContext.Recorder())
statusHandler.AddCondition(status.HandleDegraded("ConsolePublicConfigMap", "FailedApply", consolePublicConfigErr))
if consolePublicConfigErr != nil {
klog.Errorf("could not update public console config status: %v", consolePublicConfigErr)
Expand Down Expand Up @@ -225,9 +225,9 @@ func (co *consoleOperator) SyncConsoleConfig(ctx context.Context, consoleConfig
return consoleConfig, nil
}

func (co *consoleOperator) SyncConsolePublicConfig(consoleURL string, recorder events.Recorder) (*corev1.ConfigMap, bool, error) {
func (co *consoleOperator) SyncConsolePublicConfig(ctx context.Context, consoleURL string, recorder events.Recorder) (*corev1.ConfigMap, bool, error) {
requiredConfigMap := configmapsub.DefaultPublicConfig(consoleURL)
return resourceapply.ApplyConfigMap(co.configMapClient, recorder, requiredConfigMap)
return resourceapply.ApplyConfigMap(ctx, co.configMapClient, recorder, requiredConfigMap)
}

func (co *consoleOperator) SyncDeployment(
Expand All @@ -253,6 +253,7 @@ func (co *consoleOperator) SyncDeployment(
deploymentsub.LogDeploymentAnnotationChanges(co.deploymentClient, requiredDeployment, ctx)

deployment, deploymentChanged, applyDepErr := resourceapply.ApplyDeployment(
ctx,
co.deploymentClient,
recorder,
requiredDeployment,
Expand Down Expand Up @@ -289,7 +290,7 @@ func (co *consoleOperator) SyncOAuthClient(
func (co *consoleOperator) SyncSecret(ctx context.Context, operatorConfig *operatorv1.Console, recorder events.Recorder) (*corev1.Secret, bool, error) {
secret, err := co.secretsClient.Secrets(api.TargetNamespace).Get(ctx, secretsub.Stub().Name, metav1.GetOptions{})
if apierrors.IsNotFound(err) || secretsub.GetSecretString(secret) == "" {
return resourceapply.ApplySecret(co.secretsClient, recorder, secretsub.DefaultSecret(operatorConfig, crypto.Random256BitsString()))
return resourceapply.ApplySecret(ctx, co.secretsClient, recorder, secretsub.DefaultSecret(operatorConfig, crypto.Random256BitsString()))
}
// any error should be returned & kill the sync loop
if err != nil {
Expand Down Expand Up @@ -345,7 +346,7 @@ func (co *consoleOperator) SyncConfigMap(
if err != nil {
return nil, false, "FailedConsoleConfigBuilder", err
}
cm, cmChanged, cmErr := resourceapply.ApplyConfigMap(co.configMapClient, recorder, defaultConfigmap)
cm, cmChanged, cmErr := resourceapply.ApplyConfigMap(ctx, co.configMapClient, recorder, defaultConfigmap)
if cmErr != nil {
return nil, false, "FailedApply", cmErr
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/console/operatorclient/operatorclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c *OperatorClient) GetOperatorState() (*operatorv1.OperatorSpec, *operator
return &instance.Spec.OperatorSpec, &instance.Status.OperatorStatus, instance.ResourceVersion, nil
}

func (c *OperatorClient) UpdateOperatorSpec(resourceVersion string, spec *operatorv1.OperatorSpec) (*operatorv1.OperatorSpec, string, error) {
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
Expand All @@ -55,7 +55,7 @@ func (c *OperatorClient) UpdateOperatorSpec(resourceVersion string, spec *operat

return &ret.Spec.OperatorSpec, ret.ResourceVersion, nil
}
func (c *OperatorClient) UpdateOperatorStatus(resourceVersion string, status *operatorv1.OperatorStatus) (*operatorv1.OperatorStatus, error) {
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
Expand Down
4 changes: 2 additions & 2 deletions pkg/console/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/openshift/console-operator/pkg/console/controllers/service"
"github.com/openshift/console-operator/pkg/console/operatorclient"
"github.com/openshift/library-go/pkg/controller/controllercmd"
"github.com/openshift/library-go/pkg/operator/management"
"github.com/openshift/library-go/pkg/operator/managementstatecontroller"
"github.com/openshift/library-go/pkg/operator/resourcesynccontroller"
"github.com/openshift/library-go/pkg/operator/staleconditions"
"github.com/openshift/library-go/pkg/operator/status"
Expand Down Expand Up @@ -353,7 +353,7 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle

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

for _, informer := range []interface {
Start(stopCh <-chan struct{})
Expand Down
3 changes: 2 additions & 1 deletion pkg/console/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package status

import (
"bytes"
"context"
"fmt"
"strings"

Expand Down Expand Up @@ -119,7 +120,7 @@ func (c *StatusHandler) AddConditions(newStatusFuncs []v1helpers.UpdateStatusFun
}

func (c *StatusHandler) FlushAndReturn(returnErr error) error {
if _, _, updateErr := v1helpers.UpdateStatus(c.client, c.statusFuncs...); updateErr != nil {
if _, _, updateErr := v1helpers.UpdateStatus(context.TODO(), c.client, c.statusFuncs...); updateErr != nil {
return updateErr
}
return returnErr
Expand Down
1 change: 1 addition & 0 deletions pkg/console/subresource/configmap/brand_ocp.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build ocp
// +build ocp

package configmap
Expand Down
1 change: 1 addition & 0 deletions pkg/console/subresource/configmap/brand_okd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !ocp
// +build !ocp

package configmap
Expand Down
4 changes: 2 additions & 2 deletions pkg/console/subresource/deployment/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ func TestDefaultDownloadsDeployment(t *testing.T) {
ContainerPort: api.DownloadsPort,
}},
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(api.DownloadsPort),
Expand All @@ -1370,7 +1370,7 @@ func TestDefaultDownloadsDeployment(t *testing.T) {
FailureThreshold: 3,
},
LivenessProbe: &corev1.Probe{
Handler: corev1.Handler{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(api.DownloadsPort),
Expand Down
1 change: 1 addition & 0 deletions pkg/dependencymagnet/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

// go mod won't pull in code that isn't depended upon, but we have some code we don't depend on from code that must be included
Expand Down

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.

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

Loading