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 )