Skip to content
Open
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
16 changes: 15 additions & 1 deletion cmd/ateapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var (
postgresSchema = pflag.String("postgres-schema", "public", "PostgreSQL schema for Substrate tables. This overrides a search_path connection parameter.")

actorIDJWTPoolFile = pflag.String("actor-id-jwt-pool", "", "The file that contains the serialized JWT authority pool for signing actor JWTs")
egressGatewayAddress = pflag.String("egress-gateway-address", "", "Address of the egress PEP. Empty disables tunneled egress.")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1689 would have it say empty means there's no egress support, so you have ingress only. That seems reasonable for some use cases.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the long term, we plan to support per-Actor egress gateway configuration #1591.

egressGatewayAddress = pflag.String("egress-gateway-address", "", "Address of the egress PEP. Required.")

actorIDCAPoolFile = pflag.String("actor-id-ca-pool", "", "The file that contains the CA pool for signing actor JWTs")
podIdentityCACerts = pflag.String("pod-identity-ca-certs", "", "The file that contains the pod-identity CA bundle, used both for verifying client certificates presented to the gRPC server and for verifying atelet serving certificates when dialing atelet. If empty, client-cert verification is disabled and atelet dials will fail.")
Expand Down Expand Up @@ -106,6 +106,9 @@ func main() {
if *templateResyncInterval < minResyncInterval {
serverboot.Fatal(ctx, "Invalid --template-resync-interval", fmt.Errorf("must be at least %s", minResyncInterval))
}
if err := validateEgressGatewayAddress(); err != nil {
serverboot.Fatal(ctx, "Invalid --egress-gateway-address", err)
}

// Kept separate from ctx so that in-progress work (clients, informers) is
// not cancelled the moment SIGTERM arrives. The drainOnShutdown
Expand Down Expand Up @@ -375,6 +378,17 @@ func newObjectStore(ctx context.Context) (objectstore.Store, error) {
}
}

// validateEgressGatewayAddress refuses a configuration with no egress gateway.
// An actor started without one is not tunneled through the PEP at all, so its
// EgressPolicy goes unenforced; failing at startup keeps a cluster from
// reaching that state by omitting a flag.
func validateEgressGatewayAddress() error {
if *egressGatewayAddress == "" {
return fmt.Errorf("--egress-gateway-address is required")
}
return nil
}

// connectStore builds the PostgreSQL-backed store.Interface. Startup fails if
// its configuration is missing or the database can't be reached.
func connectStore(ctx context.Context) (store.Interface, error) {
Expand Down
27 changes: 27 additions & 0 deletions cmd/ateapi/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,30 @@ func TestConnectStoreRequiresPostgresConnectionString(t *testing.T) {
t.Fatalf("connectStore() error = %v, want missing-connection-string error", err)
}
}

func TestValidateEgressGatewayAddress(t *testing.T) {
for _, tc := range []struct {
name string
address string
wantErr bool
}{
{name: "empty", address: "", wantErr: true},
{name: "set", address: "atenet-egress.ate-system.svc:443"},
} {
t.Run(tc.name, func(t *testing.T) {
oldAddress := *egressGatewayAddress
t.Cleanup(func() {
*egressGatewayAddress = oldAddress
})
*egressGatewayAddress = tc.address

err := validateEgressGatewayAddress()
if gotErr := err != nil; gotErr != tc.wantErr {
t.Fatalf("validateEgressGatewayAddress() error = %v, wantErr %t", err, tc.wantErr)
}
if tc.wantErr && !strings.Contains(err.Error(), "--egress-gateway-address is required") {
t.Errorf("validateEgressGatewayAddress() error = %v, want missing-address error", err)
}
})
}
}
Loading