Repository: Azure/ARO-RP
Pull request #2642 (2023-01-17 16:24:53)

Removes dependency on a versioned operator client
### What this PR does / why we need it:

Operator is not longer dependant on a version config client and is now using a split client.

### Test plan for issue:

Existing tests should cover it

### Is there any documentation that needs to be updated for this PR?

No, just refactoring.


github-actions[bot]: Please rebase pull request.

Patch:
diff --git a/cmd/aro/operator.go b/cmd/aro/operator.go
index 2119bae94..85f9ce506 100644
--- a/cmd/aro/operator.go
+++ b/cmd/aro/operator.go
@@ -10,7 +10,6 @@ import (
 
 	imageregistryclient "github.com/openshift/client-go/imageregistry/clientset/versioned"
 	machineclient "github.com/openshift/client-go/machine/clientset/versioned"
-	operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
 	securityclient "github.com/openshift/client-go/security/clientset/versioned"
 	mcoclient "github.com/openshift/machine-config-operator/pkg/generated/clientset/versioned"
 	"github.com/sirupsen/logrus"
@@ -100,10 +99,6 @@ func operator(ctx context.Context, log *logrus.Entry) error {
 	if err != nil {
 		return err
 	}
-	operatorcli, err := operatorclient.NewForConfig(restConfig)
-	if err != nil {
-		return err
-	}
 	// TODO (NE): dh is sometimes passed, sometimes created later. Can we standardize?
 	dh, err := dynamichelper.New(log, restConfig)
 	if err != nil {
@@ -223,7 +218,7 @@ func operator(ctx context.Context, log *logrus.Entry) error {
 		}
 		if err = (ingress.NewReconciler(
 			log.WithField("controller", ingress.ControllerName),
-			client, operatorcli)).SetupWithManager(mgr); err != nil {
+			client)).SetupWithManager(mgr); err != nil {
 			return fmt.Errorf("unable to create controller %s: %v", ingress.ControllerName, err)
 		}
 		if err = (serviceprincipalchecker.NewReconciler(
@@ -233,12 +228,12 @@ func operator(ctx context.Context, log *logrus.Entry) error {
 		}
 		if err = (clusterdnschecker.NewReconciler(
 			log.WithField("controller", clusterdnschecker.ControllerName),
-			client, operatorcli, role)).SetupWithManager(mgr); err != nil {
+			client, role)).SetupWithManager(mgr); err != nil {
 			return fmt.Errorf("unable to create controller %s: %v", clusterdnschecker.ControllerName, err)
 		}
 		if err = (ingresscertificatechecker.NewReconciler(
 			log.WithField("controller", ingresscertificatechecker.ControllerName),
-			client, operatorcli, role)).SetupWithManager(mgr); err != nil {
+			client, role)).SetupWithManager(mgr); err != nil {
 			return fmt.Errorf("unable to create controller %s: %v", ingresscertificatechecker.ControllerName, err)
 		}
 	}
diff --git a/hack/portalauth/portalauth.go b/hack/portalauth/portalauth.go
index 1c4b8eec4..3194d5188 100644
--- a/hack/portalauth/portalauth.go
+++ b/hack/portalauth/portalauth.go
@@ -5,7 +5,6 @@ package main
 
 import (
 	"context"
-	"encoding/gob"
 	"flag"
 	"fmt"
 	"net/http"
@@ -71,7 +70,7 @@ func run(ctx context.Context, log *logrus.Entry) error {
 
 	session.Values[SessionKeyUsername] = username
 	session.Values[SessionKeyGroups] = strings.Split(*groups, ",")
-	session.Values[SessionKeyExpires] = time.Now().Add(time.Hour)
+	session.Values[SessionKeyExpires] = time.Now().Add(time.Hour).Unix()
 
 	encoded, err := securecookie.EncodeMulti(session.Name(), session.Values,
 		store.Codecs...)
@@ -88,8 +87,6 @@ func run(ctx context.Context, log *logrus.Entry) error {
 func main() {
 	log := utillog.GetLogger()
 
-	gob.Register(time.Time{})
-
 	if err := run(context.Background(), log); err != nil {
 		log.Fatal(err)
 	}
diff --git a/pkg/operator/controllers/checkers/clusterdnschecker/checker.go b/pkg/operator/controllers/checkers/clusterdnschecker/checker.go
index 82e1f4621..40162b7dc 100644
--- a/pkg/operator/controllers/checkers/clusterdnschecker/checker.go
+++ b/pkg/operator/controllers/checkers/clusterdnschecker/checker.go
@@ -8,8 +8,9 @@ import (
 	"fmt"
 	"strings"
 
-	operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	operatorv1 "github.com/openshift/api/operator/v1"
+	"k8s.io/apimachinery/pkg/types"
+	"sigs.k8s.io/controller-runtime/pkg/client"
 )
 
 type clusterDNSChecker interface {
@@ -17,17 +18,18 @@ type clusterDNSChecker interface {
 }
 
 type checker struct {
-	operatorcli operatorclient.Interface
+	client client.Client
 }
 
-func newClusterDNSChecker(operatorcli operatorclient.Interface) *checker {
+func newClusterDNSChecker(client client.Client) *checker {
 	return &checker{
-		operatorcli: operatorcli,
+		client: client,
 	}
 }
 
 func (r *checker) Check(ctx context.Context) error {
-	dns, err := r.operatorcli.OperatorV1().DNSes().Get(ctx, "default", metav1.GetOptions{})
+	dns := &operatorv1.DNS{}
+	err := r.client.Get(ctx, types.NamespacedName{Name: "default"}, dns)
 	if err != nil {
 		return err
 	}
diff --git a/pkg/operator/controllers/checkers/clusterdnschecker/controller.go b/pkg/operator/controllers/checkers/clusterdnschecker/controller.go
index 7286d120e..772f6f67b 100644
--- a/pkg/operator/controllers/checkers/clusterdnschecker/controller.go
+++ b/pkg/operator/controllers/checkers/clusterdnschecker/controller.go
@@ -8,7 +8,6 @@ import (
 	"time"
 
 	operatorv1 "github.com/openshift/api/operator/v1"
-	operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
 	"github.com/sirupsen/logrus"
 	"k8s.io/apimachinery/pkg/types"
 	ctrl "sigs.k8s.io/controller-runtime"
@@ -44,12 +43,12 @@ type Reconciler struct {
 	client client.Client
 }
 
-func NewReconciler(log *logrus.Entry, client client.Client, operatorcli operatorclient.Interface, role string) *Reconciler {
+func NewReconciler(log *logrus.Entry, client client.Client, role string) *Reconciler {
 	return &Reconciler{
 		log:  log,
 		role: role,
 
-		checker: newClusterDNSChecker(operatorcli),
+		checker: newClusterDNSChecker(client),
 
 		client: client,
 	}
diff --git a/pkg/operator/controllers/checkers/ingresscertificatechecker/checker.go b/pkg/operator/controllers/checkers/ingresscertificatechecker/checker.go
index aa07cf9d5..bd2ee0359 100644
--- a/pkg/operator/controllers/checkers/ingresscertificatechecker/checker.go
+++ b/pkg/operator/controllers/checkers/ingresscertificatechecker/checker.go
@@ -16,8 +16,7 @@ import (
 	"fmt"
 
 	configv1 "github.com/openshift/api/config/v1"
-	operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	operatorv1 "github.com/openshift/api/operator/v1"
 	"k8s.io/apimachinery/pkg/types"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 )
@@ -39,14 +38,12 @@ type ingressCertificateChecker interface {
 }
 
 type checker struct {
-	client      client.Client
-	operatorcli operatorclient.Interface
+	client client.Client
 }
 
-func newIngressCertificateChecker(client client.Client, operatorcli operatorclient.Interface) *checker {
+func newIngressCertificateChecker(client client.Client) *checker {
 	return &checker{
-		client:      client,
-		operatorcli: operatorcli,
+		client: client,
 	}
 }
 
@@ -57,7 +54,8 @@ func (r *checker) Check(ctx context.Context) error {
 		return err
 	}
 
-	ingress, err := r.operatorcli.OperatorV1().IngressControllers("openshift-ingress-operator").Get(ctx, "default", metav1.GetOptions{})
+	ingress := &operatorv1.IngressController{}
+	err = r.client.Get(ctx, types.NamespacedName{Namespace: "openshift-ingress-operator", Name: "default"}, ingress)
 	if err != nil {
 		return err
 	}
diff --git a/pkg/operator/controllers/checkers/ingresscertificatechecker/controller.go b/pkg/operator/controllers/checkers/ingresscertificatechecker/controller.go
index 373f904e0..3adbd12e8 100644
--- a/pkg/operator/controllers/checkers/ingresscertificatechecker/controller.go
+++ b/pkg/operator/controllers/checkers/ingresscertificatechecker/controller.go
@@ -10,7 +10,6 @@ import (
 
 	configv1 "github.com/openshift/api/config/v1"
 	operatorv1 "github.com/openshift/api/operator/v1"
-	operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
 	"github.com/sirupsen/logrus"
 	"k8s.io/apimachinery/pkg/types"
 	ctrl "sigs.k8s.io/controller-runtime"
@@ -46,12 +45,12 @@ type Reconciler struct {
 	client client.Client
 }
 
-func NewReconciler(log *logrus.Entry, client client.Client, operatorcli operatorclient.Interface, role string) *Reconciler {
+func NewReconciler(log *logrus.Entry, client client.Client, role string) *Reconciler {
 	return &Reconciler{
 		log:  log,
 		role: role,
 
-		checker: newIngressCertificateChecker(client, operatorcli),
+		checker: newIngressCertificateChecker(client),
 
 		client: client,
 	}
diff --git a/pkg/operator/controllers/ingress/ingress_controller.go b/pkg/operator/controllers/ingress/ingress_controller.go
index 635d5f050..7e3eff1cf 100644
--- a/pkg/operator/controllers/ingress/ingress_controller.go
+++ b/pkg/operator/controllers/ingress/ingress_controller.go
@@ -7,9 +7,8 @@ import (
 	"context"
 
 	"github.com/Azure/go-autorest/autorest/to"
-	operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
+	operatorv1 "github.com/openshift/api/operator/v1"
 	"github.com/sirupsen/logrus"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/types"
 	ctrl "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/builder"
@@ -34,16 +33,13 @@ const (
 type Reconciler struct {
 	log *logrus.Entry
 
-	operatorcli operatorclient.Interface
-
 	client client.Client
 }
 
-func NewReconciler(log *logrus.Entry, client client.Client, operatorcli operatorclient.Interface) *Reconciler {
+func NewReconciler(log *logrus.Entry, client client.Client) *Reconciler {
 	return &Reconciler{
-		log:         log,
-		operatorcli: operatorcli,
-		client:      client,
+		log:    log,
+		client: client,
 	}
 }
 
@@ -60,7 +56,8 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
 	}
 
 	r.log.Debug("running")
-	ingress, err := r.operatorcli.OperatorV1().IngressControllers(openshiftIngressControllerNamespace).Get(ctx, openshiftIngressControllerName, metav1.GetOptions{})
+	ingress := &operatorv1.IngressController{}
+	err = r.client.Get(ctx, types.NamespacedName{Namespace: openshiftIngressControllerNamespace, Name: openshiftIngressControllerName}, ingress)
 	if err != nil {
 		r.log.Error(err)
 		return reconcile.Result{}, err
@@ -68,7 +65,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
 
 	if ingress.Spec.Replicas != nil && *ingress.Spec.Replicas < minimumReplicas {
 		ingress.Spec.Replicas = to.Int32Ptr(minimumReplicas)
-		_, err := r.operatorcli.OperatorV1().IngressControllers(openshiftIngressControllerNamespace).Update(ctx, ingress, metav1.UpdateOptions{})
+		err := r.client.Update(ctx, ingress)
 		if err != nil {
 			r.log.Error(err)
 			return reconcile.Result{}, err
diff --git a/pkg/portal/middleware/aad.go b/pkg/portal/middleware/aad.go
index 1553975b8..a3773bf1c 100644
--- a/pkg/portal/middleware/aad.go
+++ b/pkg/portal/middleware/aad.go
@@ -7,7 +7,6 @@ import (
 	"context"
 	"crypto/rsa"
 	"crypto/x509"
-	"encoding/gob"
 	"errors"
 	"io"
 	"net/http"
@@ -28,17 +27,14 @@ import (
 )
 
 const (
-	SessionName        = "session"
+	SessionName = "session"
+	// Expiration time in unix format
 	SessionKeyExpires  = "expires"
 	sessionKeyState    = "state"
 	SessionKeyUsername = "user_name"
 	SessionKeyGroups   = "groups"
 )
 
-func init() {
-	gob.Register(time.Time{})
-}
-
 // AAD is responsible for ensuring that we have a valid login session with AAD.
 type AAD interface {
 	AAD(http.Handler) http.Handler
@@ -157,8 +153,8 @@ func (a *aad) AAD(h http.Handler) http.Handler {
 			return
 		}
 
-		expires, ok := session.Values[SessionKeyExpires].(time.Time)
-		if !ok || expires.Before(a.now()) {
+		expires, ok := session.Values[SessionKeyExpires].(int64)
+		if !ok || time.Unix(expires, 0).Before(a.now()) {
 			h.ServeHTTP(w, r)
 			return
 		}
@@ -310,7 +306,7 @@ func (a *aad) callback(w http.ResponseWriter, r *http.Request) {
 
 	session.Values[SessionKeyUsername] = claims.PreferredUsername
 	session.Values[SessionKeyGroups] = groupsIntersect
-	session.Values[SessionKeyExpires] = a.now().Add(a.sessionTimeout)
+	session.Values[SessionKeyExpires] = a.now().Add(a.sessionTimeout).Unix()
 
 	err = session.Save(r, w)
 	if err != nil {


Test patch:
diff --git a/pkg/operator/controllers/checkers/clusterdnschecker/checker_test.go b/pkg/operator/controllers/checkers/clusterdnschecker/checker_test.go
index 5c3f33d81..eb0d0e25a 100644
--- a/pkg/operator/controllers/checkers/clusterdnschecker/checker_test.go
+++ b/pkg/operator/controllers/checkers/clusterdnschecker/checker_test.go
@@ -8,8 +8,8 @@ import (
 	"testing"
 
 	operatorv1 "github.com/openshift/api/operator/v1"
-	operatorfake "github.com/openshift/client-go/operator/clientset/versioned/fake"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	ctrlfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
 )
 
 func TestCheck(t *testing.T) {
@@ -73,13 +73,13 @@ func TestCheck(t *testing.T) {
 		},
 	} {
 		t.Run(tt.name, func(t *testing.T) {
-			operatorcliMock := operatorfake.NewSimpleClientset()
+			clientBuilder := ctrlfake.NewClientBuilder()
 			if tt.DNS != nil {
-				operatorcliMock.Tracker().Add(tt.DNS)
+				clientBuilder = clientBuilder.WithObjects(tt.DNS)
 			}
 
 			sp := &checker{
-				operatorcli: operatorcliMock,
+				client: clientBuilder.Build(),
 			}
 
 			err := sp.Check(ctx)
diff --git a/pkg/operator/controllers/checkers/ingresscertificatechecker/checker_test.go b/pkg/operator/controllers/checkers/ingresscertificatechecker/checker_test.go
index 62618c745..c6817c4d2 100644
--- a/pkg/operator/controllers/checkers/ingresscertificatechecker/checker_test.go
+++ b/pkg/operator/controllers/checkers/ingresscertificatechecker/checker_test.go
@@ -9,8 +9,6 @@ import (
 
 	configv1 "github.com/openshift/api/config/v1"
 	operatorv1 "github.com/openshift/api/operator/v1"
-	configfake "github.com/openshift/client-go/config/clientset/versioned/fake"
-	operatorfake "github.com/openshift/client-go/operator/clientset/versioned/fake"
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	ctrlfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
@@ -66,23 +64,17 @@ func TestCheck(t *testing.T) {
 		},
 	} {
 		t.Run(tt.name, func(t *testing.T) {
-			operatorcliFake := operatorfake.NewSimpleClientset()
-			if tt.ingressController != nil {
-				operatorcliFake.Tracker().Add(tt.ingressController)
-			}
-			configcliFake := configfake.NewSimpleClientset()
-			if tt.clusterVersion != nil {
-				configcliFake.Tracker().Add(tt.clusterVersion)
-			}
-
 			clientBuilder := ctrlfake.NewClientBuilder()
 			if tt.clusterVersion != nil {
 				clientBuilder = clientBuilder.WithObjects(tt.clusterVersion)
 			}
 
+			if tt.ingressController != nil {
+				clientBuilder = clientBuilder.WithObjects(tt.ingressController)
+			}
+
 			sp := &checker{
-				client:      clientBuilder.Build(),
-				operatorcli: operatorcliFake,
+				client: clientBuilder.Build(),
 			}
 
 			err := sp.Check(ctx)
diff --git a/pkg/operator/controllers/ingress/ingress_controller_test.go b/pkg/operator/controllers/ingress/ingress_controller_test.go
index 3bfede322..b3b44e017 100644
--- a/pkg/operator/controllers/ingress/ingress_controller_test.go
+++ b/pkg/operator/controllers/ingress/ingress_controller_test.go
@@ -9,9 +9,9 @@ import (
 
 	"github.com/Azure/go-autorest/autorest/to"
 	operatorv1 "github.com/openshift/api/operator/v1"
-	operatorfake "github.com/openshift/client-go/operator/clientset/versioned/fake"
 	"github.com/sirupsen/logrus"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/types"
 	ctrl "sigs.k8s.io/controller-runtime"
 	ctrlfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
 
@@ -20,37 +20,38 @@ import (
 )
 
 func TestReconciler(t *testing.T) {
-	fakeCluster := &arov1alpha1.Cluster{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: arov1alpha1.SingletonClusterName,
-		},
-		Spec: arov1alpha1.ClusterSpec{
-			OperatorFlags: arov1alpha1.OperatorFlags{},
-		},
+	fakeCluster := func(controllerEnabledFlag string) *arov1alpha1.Cluster {
+		return &arov1alpha1.Cluster{
+			ObjectMeta: metav1.ObjectMeta{
+				Name: arov1alpha1.SingletonClusterName,
+			},
+			Spec: arov1alpha1.ClusterSpec{
+				OperatorFlags: arov1alpha1.OperatorFlags{
+					"aro.ingress.enabled": controllerEnabledFlag,
+				},
+			},
+		}
 	}
+
 	tests := []struct {
-		name                     string
-		aroCluster               *arov1alpha1.Cluster
-		aroIngressControllerFlag string
-		ingressController        *operatorv1.IngressController
-		expectedReplica          int32
-		expectedError            string
+		name                  string
+		controllerEnabledFlag string
+		ingressController     *operatorv1.IngressController
+		expectedReplica       int32
+		expectedError         string
 	}{
 		{
-			name:                     "aro ingress controller disabled",
-			aroCluster:               fakeCluster,
-			aroIngressControllerFlag: "false",
+			name:                  "aro ingress controller disabled",
+			controllerEnabledFlag: "false",
 		},
 		{
-			name:                     "openshift ingress controller not found",
-			aroCluster:               fakeCluster,
-			aroIngressControllerFlag: "true",
-			expectedError:            "ingresscontrollers.operator.openshift.io \"default\" not found",
+			name:                  "openshift ingress controller not found",
+			controllerEnabledFlag: "true",
+			expectedError:         "ingresscontrollers.operator.openshift.io \"default\" not found",
 		},
 		{
-			name:                     "openshift ingress controller has 3 replicas",
-			aroCluster:               fakeCluster,
-			aroIngressControllerFlag: "true",
+			name:                  "openshift ingress controller has 3 replicas",
+			controllerEnabledFlag: "true",
 			ingressController: &operatorv1.IngressController{
 				ObjectMeta: metav1.ObjectMeta{
 					Name:      openshiftIngressControllerName,
@@ -63,9 +64,8 @@ func TestReconciler(t *testing.T) {
 			expectedReplica: 3,
 		},
 		{
-			name:                     "openshift ingress controller has 2 replicas (minimum required replicas)",
-			aroCluster:               fakeCluster,
-			aroIngressControllerFlag: "true",
+			name:                  "openshift ingress controller has 2 replicas (minimum required replicas)",
+			controllerEnabledFlag: "true",
 			ingressController: &operatorv1.IngressController{
 				ObjectMeta: metav1.ObjectMeta{
 					Name:      openshiftIngressControllerName,
@@ -78,9 +78,8 @@ func TestReconciler(t *testing.T) {
 			expectedReplica: minimumReplicas,
 		},
 		{
-			name:                     "openshift ingress controller has 1 replica",
-			aroCluster:               fakeCluster,
-			aroIngressControllerFlag: "true",
+			name:                  "openshift ingress controller has 1 replica",
+			controllerEnabledFlag: "true",
 			ingressController: &operatorv1.IngressController{
 				ObjectMeta: metav1.ObjectMeta{
 					Name:      openshiftIngressControllerName,
@@ -93,9 +92,8 @@ func TestReconciler(t *testing.T) {
 			expectedReplica: minimumReplicas,
 		},
 		{
-			name:                     "openshift ingress controller has 0 replica",
-			aroCluster:               fakeCluster,
-			aroIngressControllerFlag: "true",
+			name:                  "openshift ingress controller has 0 replica",
+			controllerEnabledFlag: "true",
 			ingressController: &operatorv1.IngressController{
 				ObjectMeta: metav1.ObjectMeta{
 					Name:      openshiftIngressControllerName,
@@ -111,17 +109,17 @@ func TestReconciler(t *testing.T) {
 
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			tt.aroCluster.Spec.OperatorFlags["aro.ingress.enabled"] = tt.aroIngressControllerFlag
-			operatorcli := operatorfake.NewSimpleClientset()
+			clusterMock := fakeCluster(tt.controllerEnabledFlag)
 
+			clientBuilder := ctrlfake.NewClientBuilder().WithObjects(clusterMock)
 			if tt.ingressController != nil {
-				operatorcli = operatorfake.NewSimpleClientset(tt.ingressController)
+				clientBuilder = clientBuilder.WithObjects(tt.ingressController)
 			}
+			clientFake := clientBuilder.Build()
 
 			r := &Reconciler{
-				log:         logrus.NewEntry(logrus.StandardLogger()),
-				operatorcli: operatorcli,
-				client:      ctrlfake.NewClientBuilder().WithObjects(tt.aroCluster).Build(),
+				log:    logrus.NewEntry(logrus.StandardLogger()),
+				client: clientFake,
 			}
 
 			request := ctrl.Request{}
@@ -133,7 +131,8 @@ func TestReconciler(t *testing.T) {
 			}
 
 			if tt.ingressController != nil {
-				ingress, err := operatorcli.OperatorV1().IngressControllers(openshiftIngressControllerNamespace).Get(ctx, openshiftIngressControllerName, metav1.GetOptions{})
+				ingress := &operatorv1.IngressController{}
+				err = r.client.Get(ctx, types.NamespacedName{Namespace: openshiftIngressControllerNamespace, Name: openshiftIngressControllerName}, ingress)
 				if err != nil {
 					t.Error(err)
 				}
diff --git a/pkg/portal/middleware/aad_test.go b/pkg/portal/middleware/aad_test.go
index 463a866b3..d66e42ff6 100644
--- a/pkg/portal/middleware/aad_test.go
+++ b/pkg/portal/middleware/aad_test.go
@@ -87,7 +87,7 @@ func TestAAD(t *testing.T) {
 				cookie, err := securecookie.EncodeMulti(SessionName, map[interface{}]interface{}{
 					SessionKeyUsername: "username",
 					SessionKeyGroups:   []string{"group1", "group2"},
-					SessionKeyExpires:  time.Unix(1, 0),
+					SessionKeyExpires:  int64(1),
 				}, a.store.Codecs...)
 				if err != nil {
 					return nil, err
@@ -109,7 +109,7 @@ func TestAAD(t *testing.T) {
 				cookie, err := securecookie.EncodeMulti(SessionName, map[interface{}]interface{}{
 					SessionKeyUsername: "username",
 					SessionKeyGroups:   []string{"group1", "group2"},
-					SessionKeyExpires:  time.Unix(-1, 0),
+					SessionKeyExpires:  int64(-1),
 				}, a.store.Codecs...)
 				if err != nil {
 					return nil, err
@@ -374,7 +374,7 @@ func TestLogout(t *testing.T) {
 				cookie, err := securecookie.EncodeMulti(SessionName, map[interface{}]interface{}{
 					SessionKeyUsername: "username",
 					SessionKeyGroups:   []string{"group1", "group2"},
-					SessionKeyExpires:  time.Unix(1, 0),
+					SessionKeyExpires:  int64(0),
 				}, a.store.Codecs...)
 				if err != nil {
 					return nil, err
@@ -788,7 +788,7 @@ func TestCallback(t *testing.T) {
 				}
 
 				for _, l := range deep.Equal(m, cookie{
-					SessionKeyExpires:  time.Unix(3600, 0),
+					SessionKeyExpires:  int64(3600),
 					SessionKeyGroups:   groups,
 					SessionKeyUsername: username,
 				}) {
diff --git a/pkg/portal/security_test.go b/pkg/portal/security_test.go
index 3093739cc..49d048be2 100644
--- a/pkg/portal/security_test.go
+++ b/pkg/portal/security_test.go
@@ -421,7 +421,7 @@ func addAuth(req *http.Request, groups []string) error {
 	cookie, err := securecookie.EncodeMulti(middleware.SessionName, map[interface{}]interface{}{
 		middleware.SessionKeyUsername: "username",
 		middleware.SessionKeyGroups:   groups,
-		middleware.SessionKeyExpires:  time.Now().Add(time.Hour),
+		middleware.SessionKeyExpires:  time.Now().Add(time.Hour).Unix(),
 	}, store.Codecs...)
 	if err != nil {
 		return err
diff --git a/test/e2e/setup.go b/test/e2e/setup.go
index a775319d2..c234b3991 100644
--- a/test/e2e/setup.go
+++ b/test/e2e/setup.go
@@ -6,7 +6,6 @@ package e2e
 import (
 	"bytes"
 	"context"
-	"encoding/gob"
 	"fmt"
 	"image/png"
 	"math"
@@ -199,8 +198,6 @@ func adminPortalSessionSetup() (string, *selenium.WebDriver) {
 
 	log := utillog.GetLogger()
 
-	gob.Register(time.Time{})
-
 	// Navigate to the simple playground interface.
 	host, exists := os.LookupEnv("PORTAL_HOSTNAME")
 	if !exists {