gcp

package
v0.1.89 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gcp reconciles the managed GCP worker firewall rule (<infra-id>-internal-cluster) for a HostedControlPlane. The reconcile is name-based and idempotent, and is designed to "degrade, don't wedge": expected recoverable states (missing WIF credentials, insufficient IAM permissions, unresolvable project/VPC, ownership conflicts, in-flight operations) are reported through the GCPFirewallRulesReady condition without failing the overall HCP reconcile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FirewallManager

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

FirewallManager reconciles the managed worker firewall rule for a single HCP.

func NewFirewallManager

func NewFirewallManager(hcp *hyperv1.HostedControlPlane, logger logr.Logger) (*FirewallManager, error)

NewFirewallManager builds a FirewallManager from the HCP's GCP configuration. It does not build the Compute client; that happens lazily on the first API call so a missing WIF token degrades gracefully rather than erroring.

func (*FirewallManager) Delete

func (m *FirewallManager) Delete(ctx context.Context, skipOnWIFUnavailableReason string) error

Delete removes the managed firewall rule, verifying ownership first. A missing rule is success. An ownership conflict (a same-named rule without our marker) is a terminal skip: it is logged and returns nil so the caller can finish deletion, since retrying can never change the rule's ownership. Any other failure returns an error so the caller retains the finalizer and retries.

skipOnWIFUnavailableReason lets the caller allow deletion to proceed even though WIF credentials are unavailable (and the rule's existence therefore cannot be checked). It must be empty unless the caller has independently established that this is safe (e.g. the rule was never created, or an operator has manually confirmed no rule is left behind); passing a non-empty reason when that does not hold risks leaking the firewall rule. When empty, Delete returns an error so the caller retains the finalizer and retries.

func (*FirewallManager) Reconcile

func (m *FirewallManager) Reconcile(ctx context.Context) Result

Reconcile drives the managed firewall rule to its desired state and returns a classified Result.

func (*FirewallManager) SetProvisioningAttemptHook

func (m *FirewallManager) SetProvisioningAttemptHook(fn func(ctx context.Context) error)

SetProvisioningAttemptHook registers a hook the manager calls to durably record that a managed firewall rule creation is being attempted or that an owned rule exists, before it mutates GCP. A nil hook is a no-op.

type OutcomeStatus

type OutcomeStatus int

OutcomeStatus classifies the result of a firewall reconcile so the caller can decide how to react.

const (
	// OutcomeConverged means the managed rule matches the desired state.
	OutcomeConverged OutcomeStatus = iota
	// OutcomeDegraded means an expected, recoverable state was hit (missing
	// creds, 403, unresolvable infra, conflict, in-flight op). The caller sets
	// GCPFirewallRulesReady=False with the given reason/message and returns NO
	// aggregate error.
	OutcomeDegraded
	// OutcomeError means an unexpected failure occurred. The caller sets
	// GCPFirewallRulesReady=False and returns the error into the reconcile
	// aggregate so it is retried and surfaced.
	OutcomeError
)

type Result

type Result struct {
	Status  OutcomeStatus
	Reason  string
	Message string
	// Err is set only when Status is OutcomeError.
	Err error
}

Result is the classified outcome of Reconcile/Delete.

func (Result) Condition

func (r Result) Condition(observedGeneration int64) metav1.Condition

Condition renders the Result as a GCPFirewallRulesReady condition observing the provided generation.

Jump to

Keyboard shortcuts

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