networkingress

package
v0.0.0-...-5b0bcf4 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: AGPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespacePlatform     = "platform"
	NamespaceCustomDomain = "custom_domain"
)
View Source
const (
	OperationsMetric = "gram.network_ingress.operation"
	DurationMetric   = "gram.network_ingress.operation.duration"

	OperationAdmission      = "admission"
	OperationAttestation    = "attestation"
	OperationProxy          = "proxy"
	OperationResolution     = "resolution"
	OperationOAuthAuthority = "oauth_authority"
	OperationUnknown        = "unknown"

	ResultAllowed = "allowed"
	ResultDenied  = "denied"
	ResultError   = "error"
	ResultUnknown = "unknown"

	ReasonNone                 = "none"
	ReasonMissingAttestation   = "missing_attestation"
	ReasonInvalidSource        = "invalid_source"
	ReasonAttestationRejected  = "attestation_rejected"
	ReasonVerifierUnavailable  = "verifier_unavailable"
	ReasonHostMismatch         = "host_mismatch"
	ReasonIdentityInvalid      = "identity_invalid"
	ReasonIdentityRequired     = "identity_required"
	ReasonProviderUnsupported  = "provider_unsupported"
	ReasonOriginInvalid        = "origin_invalid"
	ReasonTokenReadFailed      = "token_read_failed"
	ReasonUpstreamFailed       = "upstream_failed"
	ReasonRateLimited          = "rate_limited"
	ReasonCacheHit             = "cache_hit"
	ReasonNegativeCacheHit     = "negative_cache_hit"
	ReasonTokenReviewDenied    = "token_review_denied"
	ReasonAuthorityRejected    = "authority_rejected"
	ReasonAuthorityUnavailable = "authority_unavailable"
	ReasonNamespaceRejected    = "namespace_rejected"
	ReasonEndpointNotFound     = "endpoint_not_found"
	ReasonPolicyDenied         = "policy_denied"
	ReasonDependencyFailed     = "dependency_failed"
	ReasonUnknown              = "unknown"
)
View Source
const ProviderTailscale = "tailscale"

Variables

View Source
var ErrAuthorityUnavailable = errors.New("network ingress authority lookup unavailable")

ErrAuthorityUnavailable identifies a transient failure to read live ingress authority. Callers should return a retryable service-unavailable response; missing, disabled, deleted, or changed authority remains a terminal denial.

Functions

func Attach

func Attach(mux goahttp.Muxer, service *Service, enabled bool)

func ValidateAttestorImageReference

func ValidateAttestorImageReference(value string) error

ValidateAttestorImageReference requires a complete OCI image reference pinned to a valid sha256 digest.

Types

type Authority

type Authority struct {
	Surface          requestorigin.Surface `json:"surface,omitempty"`
	BaseURL          string                `json:"base_url,omitempty"`
	OrganizationID   string                `json:"organization_id,omitempty"`
	NetworkIngressID uuid.UUID             `json:"network_ingress_id,omitempty"`
	NamespaceKind    string                `json:"namespace_kind,omitempty"`
	CustomDomainID   uuid.NullUUID         `json:"custom_domain_id,omitzero"`
}

Authority is the non-sensitive, provider-neutral request authority pinned to short-lived OAuth state. It intentionally excludes advisory network identity and provider credentials.

func FromRequest

func FromRequest(ctx context.Context, baseURL, organizationID string, customDomainID uuid.NullUUID) Authority

FromRequest captures the mint-time authority already established by request middleware and the resolved endpoint namespace. Absence of Origin preserves TTL-bounded compatibility for internal callers and pre-field cached states.

func LoadRequestAuthority

func LoadRequestAuthority(ctx context.Context, db *pgxpool.Pool) (Authority, error)

ValidateLive re-loads the ingress before a global callback performs side effects. A deleted or disabled row is indistinguishable from a missing row. LoadRequestAuthority reconstructs private namespace authority from the live ingress identified by trusted request middleware. It is used by route adapters that need explicit private resolution before the private listener lands.

func (Authority) IsPrivate

func (a Authority) IsPrivate() bool

func (Authority) ValidateBaseURL

func (a Authority) ValidateBaseURL(baseURL string) error

ValidateRequest requires a private continuation to arrive through the same attested ingress and externally visible origin. Public/custom continuations retain their existing endpoint checks.

func (Authority) ValidateEndpointRef

func (a Authority) ValidateEndpointRef(baseURL string, customDomainID uuid.NullUUID) error

ValidateEndpointRef ensures the duplicated endpoint-address fields used for rolling compatibility agree with the authoritative namespace snapshot.

func (Authority) ValidateLive

func (a Authority) ValidateLive(ctx context.Context, db *pgxpool.Pool) error

func (Authority) ValidateRequest

func (a Authority) ValidateRequest(ctx context.Context) error

type Executor

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

Executor reconciles one ingress at a time across all workers and attempts.

func (*Executor) FindOrphans

func (e *Executor) FindOrphans(ctx context.Context) ([]k8s.NetworkIngressOrphan, error)

FindOrphans reports unmatched provider resources; it never deletes them.

func (*Executor) Reconcile

func (e *Executor) Reconcile(ctx context.Context, organizationID string, id uuid.UUID) (ReconcileResult, error)

type ExecutorOptions

type ExecutorOptions struct {
	// Queue is the authoritative reconciliation task queue.
	Queue string

	// Image is the attestor image used by Apply.
	Image string

	// BackendService is the private backend Service name.
	BackendService string

	// BackendPort is the private backend Service port.
	BackendPort int32

	// CanApply is checked on every attempt before credential decryption.
	CanApply func(context.Context) error

	// PublicationRequester atomically records organization invalidations for
	// committed DNS authority changes. A nil requester keeps the producer off.
	PublicationRequester PublicationRequester

	// PublicationActor identifies the reconciler actor in publication hints.
	PublicationActor string
}

ExecutorOptions contains only runtime configuration, never provider credentials.

type ExpansionAdmission

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

ExpansionAdmission authorizes actions that expand private-network access. Durable entitlement and global runtime readiness are both required. Missing, disabled, or errored state fails closed.

func NewExpansionAdmission

func NewExpansionAdmission(features *productfeatures.Client, ready, enabled bool) *ExpansionAdmission

func (*ExpansionAdmission) CheckExpansion

func (a *ExpansionAdmission) CheckExpansion(ctx context.Context, organizationID string) error

func (*ExpansionAdmission) PrepareNetworkAccess

func (*ExpansionAdmission) SetReconcilerReady

func (a *ExpansionAdmission) SetReconcilerReady(ready bool)

type HealthRefresher

type HealthRefresher interface {
	RefreshNetworkIngress(context.Context, string, uuid.UUID) error
}

HealthRefresher waits only for an interactive refresh, not for config writes.

type OutboxRequester

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

OutboxRequester routes lifecycle wakes to the environment's authoritative queue.

func NewOutboxRequester

func NewOutboxRequester(queue string) *OutboxRequester

func (*OutboxRequester) Enqueue

func (r *OutboxRequester) Enqueue(ctx context.Context, tx pgx.Tx, organizationID string, ingressID uuid.UUID) error

type PublicationRequester

type PublicationRequester interface {
	Organization(context.Context, pgx.Tx, string, string) error
}

PublicationRequester atomically records an organization publication hint. Implementations must not commit the transaction or perform external work.

type ReconcileError

type ReconcileError struct {
	// Code is a bounded diagnostic suitable for orchestration history.
	Code string

	// Retryable controls retries within the current workflow run.
	Retryable bool
}

ReconcileError deliberately has no wrapped cause or provider-supplied message.

func (*ReconcileError) Error

func (e *ReconcileError) Error() string

type ReconcileHandler

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

ReconcileHandler coalesces durable wakes by ingress before contacting Temporal.

func NewReconcileHandler

func NewReconcileHandler(logger *slog.Logger, queue string, signal func(context.Context, string, uuid.UUID) error) *ReconcileHandler

func (*ReconcileHandler) HandleBatchWithResult

func (h *ReconcileHandler) HandleBatchWithResult(ctx context.Context, messages []streams.BatchMessage[*networkingressv1.ReconcileRequested]) error

type ReconcileRequester

type ReconcileRequester interface {
	Enqueue(context.Context, pgx.Tx, string, uuid.UUID) error
}

ReconcileRequester atomically records lifecycle work with its desired state.

type ReconcileResult

type ReconcileResult struct {
	// Requeue means desired state changed during this pass.
	Requeue bool
}

ReconcileResult is safe to persist in orchestration history.

type ResourceNames

type ResourceNames = k8s.NetworkIngressResourceNames

ResourceNames aliases the canonical provider-neutral resource identity contract owned by the Kubernetes provisioner layer.

func NewResourceNames

func NewResourceNames(id uuid.UUID) (ResourceNames, error)

NewResourceNames is retained for compatibility with management callers while delegating construction and validation to the canonical provisioner contract.

type RuntimeConfig

type RuntimeConfig struct {
	// ReconcileTaskQueue is explicit and never falls back to a general worker queue.
	ReconcileTaskQueue string

	// ProviderMutationsEnabled permits apply and rotation, not admission or cleanup.
	ProviderMutationsEnabled bool

	// Tailscale configures operator resources and private backend network access.
	Tailscale k8s.TailscaleNetworkIngressConfig

	// AttestorImage is the digest-pinned image deployed for each ingress.
	AttestorImage string

	// BackendService names the private HTTPS Service in Tailscale.BackendNamespace.
	BackendService string

	// BackendPort is the private HTTPS Service port; zero means unconfigured.
	BackendPort int32

	// IngressClass must explicitly select the supported tailscale ingress class.
	IngressClass string

	// TokenAudience must match the private listener's projected token audience.
	TokenAudience string
}

RuntimeConfig separates optional lifecycle configuration from permission to apply provider changes. Its zero value disables lifecycle delivery and mutation.

func (RuntimeConfig) MutationReady

func (c RuntimeConfig) MutationReady() bool

MutationReady reports configuration readiness for apply and rotation only. Callers must independently verify clients and admission integration readiness. Observe and Delete must not depend on this result.

func (RuntimeConfig) Validate

func (c RuntimeConfig) Validate() error

Validate rejects invalid supplied values without requiring apply-only settings. Missing configuration leaves mutation unavailable without preventing cleanup.

type Service

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

func NewService

func NewService(logger *slog.Logger, tracerProvider trace.TracerProvider, db *pgxpool.Pool, sessions *sessions.Manager, authzEngine *authz.Engine, enc *encryption.Client, auditLogger *audit.Logger, admission *ExpansionAdmission, requester ReconcileRequester, health HealthRefresher) *Service

func NewServiceWithPublication

func NewServiceWithPublication(logger *slog.Logger, tracerProvider trace.TracerProvider, db *pgxpool.Pool, sessions *sessions.Manager, authzEngine *authz.Engine, enc *encryption.Client, auditLogger *audit.Logger, admission *ExpansionAdmission, requester ReconcileRequester, publicationRequester PublicationRequester, health HealthRefresher) *Service

NewServiceWithPublication configures the optional durable publication invalidator. A nil requester preserves the dormant producer behavior.

func (*Service) APIKeyAuth

func (s *Service) APIKeyAuth(ctx context.Context, key string, schema *security.APIKeyScheme) (context.Context, error)

func (*Service) CheckHealth

func (s *Service) CheckHealth(ctx context.Context, _ *gen.CheckHealthPayload) (*gen.NetworkIngress, error)

func (*Service) CreateIngress

func (s *Service) CreateIngress(ctx context.Context, payload *gen.CreateIngressPayload) (*gen.NetworkIngress, error)

func (*Service) DeleteIngress

func (s *Service) DeleteIngress(ctx context.Context, _ *gen.DeleteIngressPayload) error

func (*Service) GetDeleteImpact

func (*Service) GetIngress

func (*Service) RotateCredentials

func (s *Service) RotateCredentials(ctx context.Context, payload *gen.RotateCredentialsPayload) (*gen.NetworkIngress, error)

func (*Service) UpdateIngress

func (s *Service) UpdateIngress(ctx context.Context, payload *gen.UpdateIngressPayload) (*gen.NetworkIngress, error)

type Telemetry

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

func NewTelemetry

func NewTelemetry(logger *slog.Logger, meterProvider metric.MeterProvider) *Telemetry

func (*Telemetry) Record

func (t *Telemetry) Record(ctx context.Context, operation, result, reason, provider string, duration time.Duration)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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