status

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRetryUpdateFunc

func NewRetryUpdateFunc(
	getter controller.Getter,
	updater K8sUpdater,
	nsname types.NamespacedName,
	obj client.Object,
	logger logr.Logger,
	statusSetter func(client.Object) bool,
) func(ctx context.Context) (bool, error)

NewRetryUpdateFunc returns a function which will be used in wait.ExponentialBackoffWithContext. The function will attempt to Update a kubernetes resource and will be retried in wait.ExponentialBackoffWithContext if an error occurs. Exported for testing purposes.

wait.ExponentialBackoffWithContext will retry if this function returns nil as its error, which is what we want if we encounter an error from the functions we call. However, the linter will complain if we return nil if an error was found.

Types

type AncestorStatus added in v1.2.0

type AncestorStatus struct {
	// GatewayNsName is the Namespaced name of the Gateway, which the ancestorRef references.
	GatewayNsName types.NamespacedName
	// Conditions is the list of conditions that are relevant to the ancestor.
	Conditions []conditions.Condition
}

AncestorStatus holds status-related information related to how the BackendTLSPolicy binds to a specific ancestorRef.

type BackendTLSPolicyStatus added in v1.2.0

type BackendTLSPolicyStatus struct {
	// AncestorStatuses holds the statuses for parentRefs of the BackendTLSPolicy.
	AncestorStatuses []AncestorStatus
	// ObservedGeneration is the generation of the resource that was processed.
	ObservedGeneration int64
}

BackendTLSPolicyStatus holds the status-related information about a BackendTLSPolicy resource.

type BackendTLSPolicyStatuses added in v1.2.0

type BackendTLSPolicyStatuses map[types.NamespacedName]BackendTLSPolicyStatus

BackendTLSPolicyStatuses holds the statuses of BackendTLSPolicies where the key is the namespaced name of a BackendTLSPolicy.

type Clock

type Clock interface {
	Now() metav1.Time
}

Clock returns the current local time.

type GatewayAPIStatuses

type GatewayAPIStatuses struct {
	GatewayClassStatuses     GatewayClassStatuses
	GatewayStatuses          GatewayStatuses
	HTTPRouteStatuses        HTTPRouteStatuses
	BackendTLSPolicyStatuses BackendTLSPolicyStatuses
}

GatewayAPIStatuses holds the status-related information about Gateway API resources.

func (GatewayAPIStatuses) APIGroup

func (g GatewayAPIStatuses) APIGroup() string

type GatewayClassStatus

type GatewayClassStatus struct {
	// Conditions is the list of conditions for this GatewayClass.
	Conditions []conditions.Condition
	// ObservedGeneration is the generation of the resource that was processed.
	ObservedGeneration int64
}

GatewayClassStatus holds status-related information about the GatewayClass resource.

type GatewayClassStatuses

type GatewayClassStatuses map[types.NamespacedName]GatewayClassStatus

GatewayClassStatuses holds the statuses of GatewayClasses where the key is the namespaced name of a GatewayClass.

type GatewayStatus

type GatewayStatus struct {
	// ListenerStatuses holds the statuses of listeners defined on the Gateway.
	ListenerStatuses ListenerStatuses
	// Conditions is the list of conditions for this Gateway.
	Conditions []conditions.Condition
	// Addresses holds the list of GatewayStatusAddresses.
	Addresses []v1.GatewayStatusAddress
	// ObservedGeneration is the generation of the resource that was processed.
	ObservedGeneration int64
	// Ignored tells whether or not this Gateway is ignored.
	Ignored bool
}

GatewayStatus holds the status of the winning Gateway resource.

type GatewayStatuses

type GatewayStatuses map[types.NamespacedName]GatewayStatus

GatewayStatuses holds the statuses of Gateways where the key is the namespaced name of a Gateway.

type HTTPRouteStatus

type HTTPRouteStatus struct {
	// ParentStatuses holds the statuses for parentRefs of the HTTPRoute.
	ParentStatuses []ParentStatus
	// ObservedGeneration is the generation of the resource that was processed.
	ObservedGeneration int64
}

HTTPRouteStatus holds the status-related information about an HTTPRoute resource.

type HTTPRouteStatuses

type HTTPRouteStatuses map[types.NamespacedName]HTTPRouteStatus

HTTPRouteStatuses holds the statuses of HTTPRoutes where the key is the namespaced name of an HTTPRoute.

type K8sUpdater

type K8sUpdater interface {
	// Update is from client.StatusClient.SubResourceWriter.
	Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error
}

K8sUpdater updates a resource from the k8s API. It allows us to mock the client.Reader.Status.Update method.

type ListenerStatus

type ListenerStatus struct {
	// Name is the name of the Listener that this status corresponds to.
	Name v1.SectionName
	// Conditions is the list of conditions for this listener.
	Conditions []conditions.Condition
	// SupportedKinds is the list of SupportedKinds for this listener.
	SupportedKinds []v1.RouteGroupKind
	// AttachedRoutes is the number of routes attached to the listener.
	AttachedRoutes int32
}

ListenerStatus holds the status-related information about a listener in the Gateway resource.

type ListenerStatuses

type ListenerStatuses []ListenerStatus

ListenerStatuses holds the statuses of listeners.

type NginxGatewayStatus

type NginxGatewayStatus struct {
	// NsName is the NamespacedName of the NginxGateway resource.
	NsName types.NamespacedName
	// Conditions is the list of conditions for this NginxGateway.
	Conditions []conditions.Condition
	// ObservedGeneration is the generation of the resource that was processed.
	ObservedGeneration int64
}

NginxGatewayStatus holds status-related information about the NginxGateway resource.

func (*NginxGatewayStatus) APIGroup

func (n *NginxGatewayStatus) APIGroup() string

type ParentStatus

type ParentStatus struct {
	// GatewayNsName is the Namespaced name of the Gateway, which the parentRef references.
	GatewayNsName types.NamespacedName
	// SectionName is the SectionName of the parentRef.
	SectionName *v1.SectionName
	// Conditions is the list of conditions that are relevant to the parentRef.
	Conditions []conditions.Condition
}

ParentStatus holds status-related information related to how the HTTPRoute binds to a specific parentRef.

type RealClock

type RealClock struct{}

RealClock returns the current local time.

func NewRealClock

func NewRealClock() *RealClock

NewRealClock creates a new RealClock.

func (*RealClock) Now

func (c *RealClock) Now() metav1.Time

Now returns the current local time.

type Status

type Status interface {
	// APIGroup returns the GroupName of the resources contained in the status
	APIGroup() string
}

Status is the status of one or more Kubernetes resources that the StatusUpdater will update.

type Updater

type Updater interface {
	// Update updates the statuses of the resources.
	Update(context.Context, Status)
	// UpdateAddresses updates the Gateway Addresses when the Gateway Service changes.
	UpdateAddresses(context.Context, []v1.GatewayStatusAddress)
	// Enable enables status updates. The updater will update the statuses in Kubernetes API to ensure they match the
	// statuses of the last Update invocation.
	Enable(ctx context.Context)
	// Disable disables status updates.
	Disable()
}

Updater updates statuses of the Gateway API resources. Updater can be disabled. In this case, it will stop updating the statuses of resources, while always saving the statuses of the last Update call. This is used to support multiple replicas of control plane being able to run simultaneously where only the leader will update statuses.

type UpdaterConfig

type UpdaterConfig struct {
	// Client is a Kubernetes API client.
	Client client.Client
	// Clock is used as a source of time for the LastTransitionTime field in Conditions in resource statuses.
	Clock Clock
	// Logger holds a logger to be used.
	Logger logr.Logger
	// GatewayCtlrName is the name of the Gateway controller.
	GatewayCtlrName string
	// GatewayClassName is the name of the GatewayClass resource.
	GatewayClassName string
	// UpdateGatewayClassStatus enables updating the status of the GatewayClass resource.
	UpdateGatewayClassStatus bool
	// LeaderElectionEnabled indicates whether Leader Election is enabled.
	// If it is not enabled, the updater will always write statuses to the Kubernetes API.
	LeaderElectionEnabled bool
}

UpdaterConfig holds configuration parameters for Updater.

type UpdaterImpl

type UpdaterImpl struct {
	// contains filtered or unexported fields
}

UpdaterImpl needs to be modified to support new resources. Consider making UpdaterImpl extendable, so that it goes along the Open-closed principle.

func NewUpdater

func NewUpdater(cfg UpdaterConfig) *UpdaterImpl

NewUpdater creates a new Updater.

func (*UpdaterImpl) Disable

func (upd *UpdaterImpl) Disable()

func (*UpdaterImpl) Enable

func (upd *UpdaterImpl) Enable(ctx context.Context)

Enable writes the last saved statuses for the Gateway API resources. Used in leader election when the Pod starts leading. It's possible that during a leader change, some statuses are missed. This will ensure that the latest statuses are written when a new leader takes over.

func (*UpdaterImpl) Update

func (upd *UpdaterImpl) Update(ctx context.Context, status Status)

func (*UpdaterImpl) UpdateAddresses

func (upd *UpdaterImpl) UpdateAddresses(ctx context.Context, addresses []v1.GatewayStatusAddress)

UpdateAddresses is called when the Gateway Status needs its addresses updated.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL