-
Notifications
You must be signed in to change notification settings - Fork 567
ROSAENG-8224: feat(operator): add --hcp-egress-block-cidrs flag to stabilize NetworkPolicy egress exceptions #8689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -847,6 +847,24 @@ func TestBuildArgs(t *testing.T) { | |
| fmt.Sprintf("--private-platform=%s", hyperv1.AWSPlatform), | ||
| }, | ||
| }, | ||
| { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jparrill added the additional test case for flag propagation. |
||
| name: "When HCPEgressBlockCIDRs is set, it should include one flag per CIDR", | ||
| deployment: HyperShiftOperatorDeployment{ | ||
| PrivatePlatform: string(hyperv1.NonePlatform), | ||
| HCPEgressBlockCIDRs: []string{"10.0.0.0/16", "10.1.0.0/16"}, | ||
| }, | ||
| expectContains: []string{ | ||
| "--hcp-egress-block-cidrs=10.0.0.0/16", | ||
| "--hcp-egress-block-cidrs=10.1.0.0/16", | ||
| }, | ||
| }, | ||
| { | ||
| name: "When HCPEgressBlockCIDRs is empty, it should not include the flag", | ||
| deployment: HyperShiftOperatorDeployment{ | ||
| PrivatePlatform: string(hyperv1.NonePlatform), | ||
| }, | ||
| expectNotContains: []string{"--hcp-egress-block-cidrs"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import ( | |
| "encoding/json" | ||
| "fmt" | ||
| "io" | ||
| "net" | ||
| "os" | ||
| "strconv" | ||
| "strings" | ||
|
|
@@ -156,6 +157,7 @@ type Options struct { | |
| ScaleFromZeroCredentialsSecret string | ||
| ScaleFromZeroCredentialsSecretKey string | ||
| RenderSensitive bool | ||
| HCPEgressBlockCIDRs []string | ||
| } | ||
|
|
||
| func (o *Options) Validate() error { | ||
|
|
@@ -173,10 +175,21 @@ func (o *Options) Validate() error { | |
| errs = append(errs, o.validateScaleFromZeroConfig()...) | ||
| errs = append(errs, o.validateMonitoringConfig()...) | ||
| errs = append(errs, o.validateMiscConfig()...) | ||
| errs = append(errs, o.validateHCPEgressBlockCIDRs()...) | ||
|
|
||
| return errors.NewAggregate(errs) | ||
| } | ||
|
|
||
| func (o *Options) validateHCPEgressBlockCIDRs() []error { | ||
| var errs []error | ||
| for _, cidr := range o.HCPEgressBlockCIDRs { | ||
| if _, _, err := net.ParseCIDR(cidr); err != nil { | ||
| errs = append(errs, fmt.Errorf("invalid --hcp-egress-block-cidrs value %q: %w", cidr, err)) | ||
| } | ||
| } | ||
| return errs | ||
| } | ||
|
|
||
| func (o *Options) validatePlatformConfig() []error { | ||
| var errs []error | ||
| switch hyperv1.PlatformType(o.PrivatePlatform) { | ||
|
|
@@ -439,6 +452,7 @@ func NewCommand() *cobra.Command { | |
| cmd.PersistentFlags().StringVar(&opts.ScaleFromZeroCreds, "scale-from-zero-creds", opts.ScaleFromZeroCreds, "Path to credentials file for scale-from-zero instance type queries") | ||
| cmd.PersistentFlags().StringVar(&opts.ScaleFromZeroCredentialsSecret, "scale-from-zero-secret", opts.ScaleFromZeroCredentialsSecret, "Name of existing secret containing scale-from-zero credentials (alternative to --scale-from-zero-creds)") | ||
| cmd.PersistentFlags().StringVar(&opts.ScaleFromZeroCredentialsSecretKey, "scale-from-zero-secret-key", opts.ScaleFromZeroCredentialsSecretKey, "Key within the scale-from-zero credentials secret (default: credentials)") | ||
| cmd.PersistentFlags().StringArrayVar(&opts.HCPEgressBlockCIDRs, "hcp-egress-block-cidrs", nil, "Static CIDRs to block in HCP namespace egress NetworkPolicies instead of dynamically-discovered hosting cluster KAS endpoint IPs. When specified, eliminates NetworkPolicy churn during hosting cluster KAS rolling restarts and avoids OVN port-group reconciliation races that can drop traffic to HCP routers. May be specified multiple times.") | ||
|
coderabbitai[bot] marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The operator's
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the validations for the |
||
|
|
||
| cmd.RunE = func(cmd *cobra.Command, args []string) error { | ||
| return InstallHyperShiftOperator(cmd.Context(), cmd.OutOrStdout(), opts) | ||
|
|
@@ -1294,6 +1308,7 @@ func setupOperatorResources(opts Options, userCABundleCM *corev1.ConfigMap, trus | |
| ScaleFromZeroSecret: scaleFromZeroSecret, | ||
| ScaleFromZeroSecretKey: opts.ScaleFromZeroCredentialsSecretKey, | ||
| ScaleFromZeroProvider: opts.ScaleFromZeroProvider, | ||
| HCPEgressBlockCIDRs: opts.HCPEgressBlockCIDRs, | ||
| }.Build() | ||
| operatorService := assets.HyperShiftOperatorService{ | ||
| Namespace: operatorNamespace, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.