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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.25.5
1.25.6
59 changes: 20 additions & 39 deletions api/v1/coherence_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates.
* Copyright (c) 2020, 2026, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -1514,20 +1514,10 @@ type ServiceMonitorSpec struct {
// See https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api-reference/api.md#endpoint
// +optional
ScrapeTimeout monitoringv1.Duration `json:"scrapeTimeout,omitempty"`
// TLS configuration to use when scraping the endpoint
// See https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api-reference/api.md#endpoint
// +optional
TLSConfig *monitoringv1.TLSConfig `json:"tlsConfig,omitempty"`
// File to read bearer token for scraping targets.
// Deprecated: use `authorization` instead.
// +optional
BearerTokenFile string `json:"bearerTokenFile,omitempty"`
// Secret to mount to read bearer token for scraping targets. The secret
// needs to be in the same namespace as the service monitor and accessible by
// the Prometheus Operator.
// Deprecated: use `authorization` instead.
// +optional
BearerTokenSecret *corev1.SecretKeySelector `json:"bearerTokenSecret,omitempty"`
// `authorization` configures the Authorization header credentials to use when
// scraping the target.
// See https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api-reference/api.md#endpoint
Expand All @@ -1544,11 +1534,6 @@ type ServiceMonitorSpec struct {
// See https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api-reference/api.md#endpoint
// +optional
HonorTimestamps *bool `json:"honorTimestamps,omitempty"`
// BasicAuth allow an endpoint to authenticate over basic authentication
// More info: https://prometheus.io/docs/operating/configuration/#endpoints
// See https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api-reference/api.md#endpoint
// +optional
BasicAuth *monitoringv1.BasicAuth `json:"basicAuth,omitempty"`
// MetricRelabelings to apply to samples before ingestion.
// See https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api-reference/api.md#endpoint
// +listType=atomic
Expand All @@ -1560,10 +1545,11 @@ type ServiceMonitorSpec struct {
// +listType=atomic
// +optional
Relabelings []monitoringv1.RelabelConfig `json:"relabelings,omitempty"`
// ProxyURL eg http://proxyserver:2195 Directs scrapes to proxy through this endpoint.
// See https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api-reference/api.md#endpoint
// +optional
ProxyURL *string `json:"proxyURL,omitempty"`
// TODO: VP
// HTTPConfigWithProxyAndTLSFiles defines the configuration for the HTTP client
// with proxy configuration and TLS configuration. It is used for
// ServiceMonitor endpoints.
HTTPConfigWithProxyAndTLSFiles monitoringv1.HTTPConfigWithProxyAndTLSFiles `json:",inline"`
}

func (in *ServiceMonitorSpec) CreateServiceMonitor() monitoringv1.ServiceMonitorSpec {
Expand All @@ -1585,22 +1571,17 @@ func (in *ServiceMonitorSpec) CreateEndpoint() monitoringv1.Endpoint {
}

return monitoringv1.Endpoint{
Path: in.Path,
Scheme: in.Scheme,
Params: in.Params,
Interval: in.Interval,
ScrapeTimeout: in.ScrapeTimeout,
TLSConfig: in.TLSConfig,
BearerTokenFile: in.BearerTokenFile,
BearerTokenSecret: in.BearerTokenSecret,
HonorLabels: in.HonorLabels,
HonorTimestamps: in.HonorTimestamps,
BasicAuth: in.BasicAuth,
MetricRelabelConfigs: in.MetricRelabelings,
RelabelConfigs: in.Relabelings,
ProxyConfig: monitoringv1.ProxyConfig{
ProxyURL: in.ProxyURL,
},
Path: in.Path,
Scheme: in.Scheme,
Params: in.Params,
Interval: in.Interval,
ScrapeTimeout: in.ScrapeTimeout,
BearerTokenFile: in.BearerTokenFile,
HonorLabels: in.HonorLabels,
HonorTimestamps: in.HonorTimestamps,
MetricRelabelConfigs: in.MetricRelabelings,
RelabelConfigs: in.Relabelings,
HTTPConfigWithProxyAndTLSFiles: in.HTTPConfigWithProxyAndTLSFiles,
}
}

Expand Down Expand Up @@ -2047,7 +2028,7 @@ type ServiceSpec struct {
// can be specified for headless services when proxying is not required.
// Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if
// type is ExternalName.
// More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
// More info: https://kubernetes.io/docs/reference/networking/virtual-ips/
// +optional
ClusterIP *string `json:"clusterIP,omitempty"`
// ClusterIPs is a list of IP addresses assigned to this service, and are
Expand Down Expand Up @@ -2075,7 +2056,7 @@ type ServiceSpec struct {
// entries (dual-stack IPs, in either order). These IPs must correspond to
// the values of the ipFamilies field. Both clusterIPs and ipFamilies are
// governed by the ipFamilyPolicy field.
// More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
// More info: https://kubernetes.io/docs/reference/networking/virtual-ips/
// +listType=atomic
// +optional
ClusterIPs []string `json:"clusterIPs,omitempty"`
Expand All @@ -2094,7 +2075,7 @@ type ServiceSpec struct {
// Enable client IP based session affinity.
// Must be ClientIP or None.
// Defaults to None.
// More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
// More info: https://kubernetes.io/docs/reference/networking/virtual-ips/
// +optional
SessionAffinity *corev1.ServiceAffinity `json:"sessionAffinity,omitempty"`
// If specified and supported by the platform, this will restrict traffic through the cloud-provider
Expand Down
20 changes: 10 additions & 10 deletions controllers/coherence_controller.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates.
* Copyright (c) 2020, 2026, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -114,7 +114,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
}
// else... error reading the current deployment state from k8s.
msg := fmt.Sprintf("failed to find Coherence resource, %s", err.Error())
in.GetEventRecorder().Event(deployment, coreV1.EventTypeWarning, reconciler.EventReasonFailed, msg)
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeWarning, reconciler.EventReasonFailed, "GetResource", msg)
// returning an error will requeue the event so we will try again
wrappedErr := errorhandling.NewGetResourceError(request.Name, request.Namespace, err)
return reconcile.Result{}, wrappedErr
Expand All @@ -129,10 +129,10 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
// Run finalization logic.
// If the finalization logic fails, don't remove the finalizer so
// that we can retry during the next reconciliation.
in.GetEventRecorder().Event(deployment, coreV1.EventTypeNormal, reconciler.EventReasonDeleted, "running finalizers")
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeNormal, reconciler.EventReasonDeleted, "Finalize", "running finalizers")
if err := in.finalizerManager.FinalizeDeployment(ctx, deployment, in.MaybeFindStatefulSet); err != nil {
msg := fmt.Sprintf("failed to finalize Coherence resource, %s", err.Error())
in.GetEventRecorder().Event(deployment, coreV1.EventTypeWarning, reconciler.EventReasonDeleted, msg)
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeWarning, reconciler.EventReasonFailed, "Finalize", msg)
log.Error(err, "Failed to remove finalizer")
return ctrl.Result{RequeueAfter: time.Minute}, nil
}
Expand All @@ -145,7 +145,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
return ctrl.Result{}, nil
}
msg := fmt.Sprintf("failed to remove finalizers from Coherence resource, %s", err.Error())
in.GetEventRecorder().Event(deployment, coreV1.EventTypeWarning, reconciler.EventReasonDeleted, msg)
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeWarning, reconciler.EventReasonFailed, "RemoveFinalizer", msg)
wrappedErr := errorhandling.NewOperationError("remove_finalizer", err).
WithContext("resource", deployment.GetName()).
WithContext("namespace", deployment.GetNamespace())
Expand Down Expand Up @@ -179,9 +179,9 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
var msg string
if err != nil {
msg = fmt.Sprintf("failed to add finalizers to Coherence resource, %s", err.Error())
in.GetEventRecorder().Event(deployment, coreV1.EventTypeWarning, reconciler.EventReasonFailed, msg)
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeWarning, reconciler.EventReasonFailed, "AddFinalizer", msg)
} else {
in.GetEventRecorder().Event(deployment, coreV1.EventTypeNormal, reconciler.EventReasonUpdated, "added finalizer")
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeNormal, reconciler.EventReasonUpdated, "AddFinalizer", "added finalizer")
}
// we need to requeue as we have updated the Coherence resource
return ctrl.Result{RequeueAfter: time.Minute}, err
Expand All @@ -208,13 +208,13 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
patch.Spec.Replicas = &replicas
_, err = in.ThreeWayPatch(ctx, deployment.Name, deployment, deployment, patch)
if err != nil {
in.GetEventRecorder().Event(deployment, coreV1.EventTypeWarning, reconciler.EventReasonFailed,
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeWarning, reconciler.EventReasonFailed, "PatchReplicas",
fmt.Sprintf("failed to add default replicas to Coherence resource, %s", err.Error()))
return reconcile.Result{}, errors.Wrap(err, "failed to add default replicas to Coherence resource")
}
msg := "Added default replicas to Coherence resource, re-queuing request"
log.Info(msg, "Replicas", strconv.Itoa(int(replicas)))
in.GetEventRecorder().Event(deployment, coreV1.EventTypeNormal, reconciler.EventReasonUpdated, msg)
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeNormal, reconciler.EventReasonUpdated, "PatchReplicas", msg)
return reconcile.Result{}, err
}

Expand All @@ -230,7 +230,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
err = errorhandling.NewOperationError("obtain_state_store", err).
WithContext("resource", deployment.GetName()).
WithContext("namespace", deployment.GetNamespace())
in.GetEventRecorder().Event(deployment, coreV1.EventTypeWarning, reconciler.EventReasonFailed,
in.GetEventRecorder().Eventf(deployment, nil, coreV1.EventTypeWarning, reconciler.EventReasonFailed, "GetStateStore",
fmt.Sprintf("failed to obtain state store: %s", err.Error()))
return in.HandleErrAndRequeue(ctx, err, deployment, fmt.Sprintf(reconcileFailedMessage, request.Name, request.Namespace, err), in.Log)
}
Expand Down
32 changes: 16 additions & 16 deletions controllers/errorhandling/error_handler.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates.
* Copyright (c) 2020, 2026, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand All @@ -20,7 +20,7 @@ import (
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/tools/events"
"k8s.io/client-go/util/retry"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -51,7 +51,7 @@ const (
type ErrorHandler struct {
Client client.Client
Log logr.Logger
EventRecorder record.EventRecorder
EventRecorder events.EventRecorder
}

// HandleError handles an error in the reconciliation loop
Expand Down Expand Up @@ -81,7 +81,7 @@ func (eh *ErrorHandler) HandleError(ctx context.Context, err error, resource coh
eventType := corev1.EventTypeWarning
eventReason := "ReconcileError"
eventMsg := fmt.Sprintf("%s: %s (Category: %s)", msg, err.Error(), category)
eh.EventRecorder.Event(resource, eventType, eventReason, eventMsg)
eh.EventRecorder.Eventf(resource, nil, eventType, eventReason, "HandleError", eventMsg)

// Update the status to reflect the error
if statusErr := eh.updateStatus(ctx, resource, category); statusErr != nil {
Expand Down Expand Up @@ -415,7 +415,7 @@ func (eh *ErrorHandler) attemptRecovery(ctx context.Context, err error, resource
"deletionTimestamp", latest.GetDeletionTimestamp())

// Record an event with detailed information
eh.EventRecorder.Event(resource, corev1.EventTypeNormal, "RecoveryAttempt",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeNormal, "RecoveryAttempt", "AttemptRecovery",
fmt.Sprintf("Attempting to recover from error: %s", err.Error()))

// Implement recovery logic based on the error
Expand Down Expand Up @@ -474,7 +474,7 @@ func (eh *ErrorHandler) recoverFromServiceSuspensionFailure(ctx context.Context,
"namespace", resource.GetNamespace())

// 2. Record an event
eh.EventRecorder.Event(resource, corev1.EventTypeNormal, "RecoveryAttempt",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeNormal, "RecoveryAttempt", "RecoverServiceSuspension",
"Attempting to recover from service suspension failure")

// 3. Implement the recovery logic
Expand Down Expand Up @@ -510,7 +510,7 @@ func (eh *ErrorHandler) recoverFromServiceSuspensionFailure(ctx context.Context,
"resource", resource.GetName(),
"namespace", resource.GetNamespace())

eh.EventRecorder.Event(resource, corev1.EventTypeNormal, "RecoveryAction",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeNormal, "RecoveryAction", "BypassFinalizer",
"Added finalizer bypass annotation to allow deletion despite service suspension failure")
}

Expand All @@ -526,7 +526,7 @@ func (eh *ErrorHandler) recoverFromPDBIssue(ctx context.Context, resource coh.Co
"namespace", resource.GetNamespace())

// Record an event
eh.EventRecorder.Event(resource, corev1.EventTypeNormal, "RecoveryAttempt",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeNormal, "RecoveryAttempt", "RecoverPDB",
"Attempting to recover from Pod Disruption Budget issue")

// For PDB issues, we'll add an annotation to indicate that we're aware of the issue
Expand Down Expand Up @@ -559,7 +559,7 @@ func (eh *ErrorHandler) recoverFromPDBIssue(ctx context.Context, resource coh.Co
"resource", resource.GetName(),
"namespace", resource.GetNamespace())

eh.EventRecorder.Event(resource, corev1.EventTypeNormal, "RecoveryAction",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeNormal, "RecoveryAction", "AnnotatePDBIssue",
"Added PDB issue annotation to resource")

// Return a result that requeues after a delay
Expand All @@ -574,7 +574,7 @@ func (eh *ErrorHandler) recoverFromStatefulSetPatchIssue(ctx context.Context, re
"namespace", resource.GetNamespace())

// Record an event
eh.EventRecorder.Event(resource, corev1.EventTypeNormal, "RecoveryAttempt",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeNormal, "RecoveryAttempt", "RecoverStatefulSetPatch",
"Attempting to recover from StatefulSet patching issue")

// For StatefulSet patching issues, we'll add an annotation to force a recreation
Expand Down Expand Up @@ -605,7 +605,7 @@ func (eh *ErrorHandler) recoverFromStatefulSetPatchIssue(ctx context.Context, re
"resource", resource.GetName(),
"namespace", resource.GetNamespace())

eh.EventRecorder.Event(resource, corev1.EventTypeNormal, "RecoveryAction",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeNormal, "RecoveryAction", "ForceReconcile",
"Added force-reconcile annotation to resource to address StatefulSet patching issue")

// Return a result that requeues after a delay
Expand All @@ -620,7 +620,7 @@ func (eh *ErrorHandler) recoverFromQuotaIssue(ctx context.Context, resource coh.
"namespace", resource.GetNamespace())

// Record an event
eh.EventRecorder.Event(resource, corev1.EventTypeWarning, "RecoveryAttempt",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeWarning, "RecoveryAttempt", "RecoverQuota",
"Attempting to recover from resource quota issue - this may require manual intervention")

// For quota issues, we'll add an annotation to indicate the issue
Expand Down Expand Up @@ -652,7 +652,7 @@ func (eh *ErrorHandler) recoverFromQuotaIssue(ctx context.Context, resource coh.
"resource", resource.GetName(),
"namespace", resource.GetNamespace())

eh.EventRecorder.Event(resource, corev1.EventTypeWarning, "ResourceQuotaIssue",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeWarning, "ResourceQuotaIssue", "QuotaIssue",
"Resource quota exceeded - manual intervention may be required to increase quota or reduce resource requests")

// Return a result that requeues after a longer delay
Expand All @@ -667,7 +667,7 @@ func (eh *ErrorHandler) recoverFromSchedulingIssue(ctx context.Context, resource
"namespace", resource.GetNamespace())

// Record an event
eh.EventRecorder.Event(resource, corev1.EventTypeWarning, "RecoveryAttempt",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeWarning, "RecoveryAttempt", "RecoverScheduling",
"Attempting to recover from pod scheduling issue - this may require manual intervention")

// For scheduling issues, we'll add an annotation to indicate the issue
Expand Down Expand Up @@ -699,7 +699,7 @@ func (eh *ErrorHandler) recoverFromSchedulingIssue(ctx context.Context, resource
"resource", resource.GetName(),
"namespace", resource.GetNamespace())

eh.EventRecorder.Event(resource, corev1.EventTypeWarning, "SchedulingIssue",
eh.EventRecorder.Eventf(resource, nil, corev1.EventTypeWarning, "SchedulingIssue", "SchedulingIssue",
"Pod scheduling issue detected - manual intervention may be required to address node resources or affinity rules")

// Return a result that requeues after a longer delay
Expand Down Expand Up @@ -995,7 +995,7 @@ func GetCallerInfo(skip int) string {
}

// NewErrorHandler creates a new ErrorHandler
func NewErrorHandler(client client.Client, log logr.Logger, recorder record.EventRecorder) *ErrorHandler {
func NewErrorHandler(client client.Client, log logr.Logger, recorder events.EventRecorder) *ErrorHandler {
return &ErrorHandler{
Client: client,
Log: log,
Expand Down
Loading