Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THREESCALE-10869 Bump Go, controller-runtime, and k8s dependencies #208

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ commands:
jobs:
install-operator:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
steps:
- setup_remote_docker:
docker_layer_caching: true
Expand All @@ -54,7 +54,7 @@ jobs:
- image: circleci/ruby:2.6
steps:
- go/install:
version: 1.19.10
version: '1.20.14'
- checkout
- run: sudo gem install license_finder --version 5.7.1
- run: make licenses-check
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:

run-unit-test:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
steps:
- checkout
- run:
Expand All @@ -122,7 +122,7 @@ jobs:
docker_layer_caching: true
steps:
- go/install:
version: 1.19.10
version: '1.20.14'
- checkout
- run:
name: Install KinD
Expand All @@ -139,7 +139,7 @@ jobs:
no_output_timeout: 30m
lint:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
steps:
- checkout
- run:
Expand All @@ -149,7 +149,7 @@ jobs:

bundle-validate:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
steps:
- checkout
- run: make bundle
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.20 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ test-unit: generate fmt vet manifests ## Run Unit tests.
# 3) Timeout waiting for process kube-apiserver to stop https://github.com/kubernetes-sigs/controller-runtime/issues/1571
test-integration: export USE_EXISTING_CLUSTER=true
test-integration: generate fmt vet manifests ## Run Integration tests.
go test ./... -tags integration -ginkgo.v -ginkgo.progress -v -timeout 600s
carlkyrillos marked this conversation as resolved.
Show resolved Hide resolved
go test ./... -tags integration -ginkgo.v -v -timeout 600s

.PHONY: bundle-validate
bundle-validate: $(OPERATOR_SDK)
Expand Down Expand Up @@ -222,7 +222,7 @@ bundle-run: $(OPERATOR_SDK)
GOLANGCI-LINT=$(PROJECT_PATH)/bin/golangci-lint
$(GOLANGCI-LINT):
mkdir -p $(PROJECT_PATH)/bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.50.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.52.2

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI-LINT)
Expand Down
25 changes: 20 additions & 5 deletions bundle/manifests/apps.3scale.net_apicasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ spec:
type: string
tls:
items:
description: IngressTLS describes the transport layer security associated with an Ingress.
description: IngressTLS describes the transport layer security associated with an ingress.
properties:
hosts:
description: Hosts are a list of hosts included in the TLS certificate. The values in this list must match the name/s used in the tlsSecret. Defaults to the wildcard host setting for the loadbalancer controller fulfilling this Ingress, if left unspecified.
description: hosts is a list of hosts included in the TLS certificate. The values in this list must match the name/s used in the tlsSecret. Defaults to the wildcard host setting for the loadbalancer controller fulfilling this Ingress, if left unspecified.
items:
type: string
type: array
x-kubernetes-list-type: atomic
secretName:
description: SecretName is the name of the secret used to terminate TLS traffic on port 443. Field is left optional to allow TLS routing based on SNI hostname alone. If the SNI host in a listener conflicts with the "Host" header field used by an IngressRule, the SNI host is used for termination and value of the Host header is used for routing.
description: secretName is the name of the secret used to terminate TLS traffic on port 443. Field is left optional to allow TLS routing based on SNI hostname alone. If the SNI host in a listener conflicts with the "Host" header field used by an IngressRule, the SNI host is used for termination and value of the "Host" header is used for routing.
type: string
type: object
type: array
Expand Down Expand Up @@ -267,6 +267,21 @@ spec:
resources:
description: Resources can be used to set custom compute Kubernetes Resource Requirements for the APIcast deployment.
properties:
claims:
description: "Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. \n This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. \n This field is immutable. It can only be set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
Expand All @@ -283,7 +298,7 @@ spec:
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
responseCodesIncluded:
Expand Down Expand Up @@ -335,7 +350,7 @@ spec:
conditions:
description: 'Represents the observations of a foo''s current state. Known .status.conditions.type are: "Available"'
items:
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
Expand Down
37 changes: 30 additions & 7 deletions config/crd/bases/apps.3scale.net_apicasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ spec:
tls:
items:
description: IngressTLS describes the transport layer security
associated with an Ingress.
associated with an ingress.
properties:
hosts:
description: Hosts are a list of hosts included in the TLS
description: hosts is a list of hosts included in the TLS
certificate. The values in this list must match the name/s
used in the tlsSecret. Defaults to the wildcard host setting
for the loadbalancer controller fulfilling this Ingress,
Expand All @@ -171,12 +171,13 @@ spec:
type: array
x-kubernetes-list-type: atomic
secretName:
description: SecretName is the name of the secret used to
description: secretName is the name of the secret used to
terminate TLS traffic on port 443. Field is left optional
to allow TLS routing based on SNI hostname alone. If the
SNI host in a listener conflicts with the "Host" header
field used by an IngressRule, the SNI host is used for
termination and value of the Host header is used for routing.
termination and value of the "Host" header is used for
routing.
type: string
type: object
type: array
Expand Down Expand Up @@ -341,6 +342,27 @@ spec:
description: Resources can be used to set custom compute Kubernetes
Resource Requirements for the APIcast deployment.
properties:
claims:
description: "Claims lists the names of resources, defined in
spec.resourceClaims, that are used by this container. \n This
is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable. It can only be set
for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in pod.spec.resourceClaims
of the Pod where this field is used. It makes that resource
available inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
Expand All @@ -361,7 +383,8 @@ spec:
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
responseCodesIncluded:
Expand Down Expand Up @@ -429,8 +452,8 @@ spec:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a foo's
current state. // Known .status.conditions.type are: \"Available\",
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
Expand Down
17 changes: 10 additions & 7 deletions controllers/apps/apicast_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,20 @@ import (
"context"
"encoding/json"

appsv1alpha1 "github.com/3scale/apicast-operator/apis/apps/v1alpha1"
"github.com/3scale/apicast-operator/pkg/reconcilers"
"github.com/go-logr/logr"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/api/errors"
apimachinerymetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

appsv1alpha1 "github.com/3scale/apicast-operator/apis/apps/v1alpha1"
"github.com/3scale/apicast-operator/pkg/reconcilers"
)

// APIcastReconciler reconciles a APIcast object
Expand Down Expand Up @@ -142,8 +140,13 @@ func (r *APIcastReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&appsv1alpha1.APIcast{}).
Watches(
&source.Kind{Type: &v1.Secret{}},
handler.EnqueueRequestsFromMapFunc(secretToApicastEventMapper.Map),
&corev1.Secret{},
handler.EnqueueRequestsFromMapFunc(
func(ctx context.Context, obj client.Object) []reconcile.Request {
secret := &corev1.Secret{}
reqs := secretToApicastEventMapper.Map(secret)
carlkyrillos marked this conversation as resolved.
Show resolved Hide resolved
return reqs
}),
builder.WithPredicates(labelSelectorPredicate),
).
Owns(&appsv1.Deployment{}).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

appsv1alpha1 "github.com/3scale/apicast-operator/apis/apps/v1alpha1"
"github.com/3scale/apicast-operator/pkg/apicast"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/apicast_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down
77 changes: 39 additions & 38 deletions controllers/apps/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ import (
"path/filepath"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

Expand All @@ -49,53 +48,55 @@ func testClient() client.Client { return k8sClient }

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
RunSpecs(t, "Controller Suite")
}

var _ = BeforeSuite(func() {
// Set controller-runtime output to GinkgoWriter
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
ErrorIfCRDPathMissing: true,
}
done := make(chan interface{})
go func() {
// Set controller-runtime output to GinkgoWriter
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

var err error
cfg, err = testEnv.Start()
Expect(err).ToNot(HaveOccurred())
Expect(cfg).ToNot(BeNil())
By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
ErrorIfCRDPathMissing: true,
}

err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
var err error
cfg, err = testEnv.Start()
Expect(err).ToNot(HaveOccurred())
Expect(cfg).ToNot(BeNil())

// +kubebuilder:scaffold:scheme
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).NotTo(BeNil())
// +kubebuilder:scaffold:scheme

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme.Scheme,
})
Expect(err).ToNot(HaveOccurred())
err = (&APIcastReconciler{
BaseControllerReconciler: reconcilers.NewBaseControllerReconciler(mgr.GetClient(), mgr.GetAPIReader(), mgr.GetScheme()),
Log: ctrl.Log.WithName("controllers").WithName("APIcast"),
}).SetupWithManager(mgr)
Expect(err).ToNot(HaveOccurred())
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).NotTo(BeNil())

go func() {
defer GinkgoRecover()
err = mgr.Start(ctrl.SetupSignalHandler())
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme.Scheme,
})
Expect(err).ToNot(HaveOccurred())
err = (&APIcastReconciler{
BaseControllerReconciler: reconcilers.NewBaseControllerReconciler(mgr.GetClient(), mgr.GetAPIReader(), mgr.GetScheme()),
Log: ctrl.Log.WithName("controllers").WithName("APIcast"),
}).SetupWithManager(mgr)
Expect(err).ToNot(HaveOccurred())
}()

}, 60)
go func() {
carlkyrillos marked this conversation as resolved.
Show resolved Hide resolved
defer GinkgoRecover()
err = mgr.Start(ctrl.SetupSignalHandler())
Expect(err).ToNot(HaveOccurred())
}()

close(done)
}()
Eventually(done, 60).Should(BeClosed())
})

var _ = AfterSuite(func() {
By("tearing down the test environment")
Expand Down
Loading