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

Bump k8s.io/apimachinery from 0.26.2 to 0.27.2 #74

Closed
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions controllers/redirect_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"
networkingv1 "k8s.io/api/networking/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -33,7 +34,6 @@ import (
redirectclient "github.com/cedi/urlshortener/pkg/client"
"github.com/cedi/urlshortener/pkg/observability"
redirectpkg "github.com/cedi/urlshortener/pkg/redirect"
"github.com/go-logr/logr"
"github.com/pkg/errors"
)

Expand All @@ -43,17 +43,17 @@ type RedirectReconciler struct {
rClient *redirectclient.RedirectClient

scheme *runtime.Scheme
log *logr.Logger
zapLog *zap.Logger
tracer trace.Tracer
}

// NewRedirectReconciler returns a new RedirectReconciler
func NewRedirectReconciler(client client.Client, rClient *redirectclient.RedirectClient, scheme *runtime.Scheme, log *logr.Logger, tracer trace.Tracer) *RedirectReconciler {
func NewRedirectReconciler(client client.Client, rClient *redirectclient.RedirectClient, scheme *runtime.Scheme, zapLog *zap.Logger, tracer trace.Tracer) *RedirectReconciler {
return &RedirectReconciler{
client: client,
rClient: rClient,
scheme: scheme,
log: log,
zapLog: zapLog,
tracer: tracer,
}
}
Expand Down Expand Up @@ -86,7 +86,7 @@ func (r *RedirectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c

span.SetAttributes(attribute.String("redirect", req.NamespacedName.String()))

log := r.log.WithName("reconciler").WithValues("redirect", req.NamespacedName)
log := r.zapLog.Sugar().With(zap.String("name", "reconciler"), zap.String("redirect", req.NamespacedName.String()))

// Monitor the number of redirects
if redirectList, err := r.rClient.List(ctx); redirectList != nil && err == nil {
Expand All @@ -100,19 +100,19 @@ func (r *RedirectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
// Request object not found, could have been deleted after reconcile request.
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
// Return and don't requeue
observability.RecordInfo(span, &log, "Shortlink resource not found. Ignoring since object must be deleted")
observability.RecordInfo(span, log, "Shortlink resource not found. Ignoring since object must be deleted")
return ctrl.Result{}, nil
}

// Error reading the object - requeue the request.
observability.RecordError(span, &log, err, "Failed to fetch Redirect resource")
observability.RecordError(span, log, err, "Failed to fetch Redirect resource")
return ctrl.Result{}, err
}

// Check if the ingress already exists, if not create a new one
ingress, err := r.upsertRedirectIngress(ctx, redirect)
if err != nil {
observability.RecordError(span, &log, err, "Failed to upsert redirect ingress")
observability.RecordError(span, log, err, "Failed to upsert redirect ingress")
}

// Update the Redirect status with the ingress name and the target
Expand All @@ -123,7 +123,7 @@ func (r *RedirectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
}

if err = r.client.List(ctx, ingressList, listOpts...); err != nil {
observability.RecordError(span, &log, err, "Failed to list ingresses")
observability.RecordError(span, log, err, "Failed to list ingresses")
return ctrl.Result{}, err
}

Expand All @@ -132,7 +132,7 @@ func (r *RedirectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
redirect.Status.Target = ingress.ObjectMeta.Annotations["nginx.ingress.kubernetes.io/permanent-redirect"]
err = r.client.Status().Update(ctx, redirect)
if err != nil {
observability.RecordError(span, &log, err, "Failed to update Redirect status")
observability.RecordError(span, log, err, "Failed to update Redirect status")
return ctrl.Result{}, err
}

Expand Down
14 changes: 7 additions & 7 deletions controllers/shortlink_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -30,23 +31,22 @@ import (
v1alpha1 "github.com/cedi/urlshortener/api/v1alpha1"
shortlinkclient "github.com/cedi/urlshortener/pkg/client"
"github.com/cedi/urlshortener/pkg/observability"
"github.com/go-logr/logr"
)

// ShortLinkReconciler reconciles a ShortLink object
type ShortLinkReconciler struct {
client *shortlinkclient.ShortlinkClient
scheme *runtime.Scheme
log *logr.Logger
zapLog *zap.Logger
tracer trace.Tracer
}

// NewShortLinkReconciler returns a new ShortLinkReconciler
func NewShortLinkReconciler(client *shortlinkclient.ShortlinkClient, scheme *runtime.Scheme, log *logr.Logger, tracer trace.Tracer) *ShortLinkReconciler {
func NewShortLinkReconciler(client *shortlinkclient.ShortlinkClient, scheme *runtime.Scheme, zapLog *zap.Logger, tracer trace.Tracer) *ShortLinkReconciler {
return &ShortLinkReconciler{
client: client,
scheme: scheme,
log: log,
zapLog: zapLog,
tracer: tracer,
}
}
Expand Down Expand Up @@ -76,15 +76,15 @@ func (r *ShortLinkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

span.SetAttributes(attribute.String("shortlink", req.Name))

log := r.log.WithName("reconciler").WithValues("shortlink", req.NamespacedName.String())
log := r.zapLog.Sugar().With(zap.String("name", "reconciler"), zap.String("shortlink", req.NamespacedName.String()))

// Get ShortLink from etcd
shortlink, err := r.client.GetNamespaced(ctx, req.NamespacedName)
if err != nil || shortlink == nil {
if errors.IsNotFound(err) {
observability.RecordInfo(span, &log, "Shortlink resource not found. Ignoring since object must be deleted")
observability.RecordInfo(span, log, "Shortlink resource not found. Ignoring since object must be deleted")
} else {
observability.RecordError(span, &log, err, "Failed to fetch ShortLink resource")
observability.RecordError(span, log, err, "Failed to fetch ShortLink resource")
}
}

Expand Down
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@ require (
github.com/gin-gonic/contrib v0.0.0-20221130124618-7e01895a63f2
github.com/gin-gonic/gin v1.9.0
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.3
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.5.3
github.com/swaggo/swag v1.8.10
github.com/uptrace/opentelemetry-go-extra/otelzap v0.2.1
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.39.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0
go.opentelemetry.io/otel v1.15.1
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0
go.opentelemetry.io/otel v1.16.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.15.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.15.1
go.opentelemetry.io/otel/sdk v1.15.1
go.opentelemetry.io/otel/trace v1.15.1
go.opentelemetry.io/otel/trace v1.16.0
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20230304125523-9ff063c70017
k8s.io/api v0.26.2
k8s.io/apimachinery v0.26.2
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.26.2
sigs.k8s.io/controller-runtime v0.14.5
)

require (
github.com/felixge/httpsnoop v1.0.3 // indirect
go.opentelemetry.io/otel/metric v0.37.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
)

require (
Expand All @@ -46,7 +49,6 @@ require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
Expand All @@ -57,7 +59,7 @@ require (
github.com/goccy/go-json v0.10.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
Expand All @@ -74,20 +76,18 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo/v2 v2.6.1 // indirect
github.com/onsi/gomega v1.24.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/uptrace/opentelemetry-go-extra/otelutil v0.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.15.1 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/net v0.8.0 // indirect
Expand All @@ -96,7 +96,7 @@ require (
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 // indirect
Expand All @@ -107,8 +107,8 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.90.0 // indirect
k8s.io/kube-openapi v0.0.0-20230217203603-ff9a8e8fa21d // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
Expand Down
Loading