Skip to content

Commit

Permalink
simplify iptables eip nat (#2137)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobz965 authored Dec 8, 2022
1 parent ef4e755 commit c410d8b
Show file tree
Hide file tree
Showing 7 changed files with 495 additions and 513 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func ParseFlags() (*Configuration, error) {
argOvnNbAddr = pflag.String("ovn-nb-addr", "", "ovn-nb address")
argOvnSbAddr = pflag.String("ovn-sb-addr", "", "ovn-sb address")
argOvnTimeout = pflag.Int("ovn-timeout", 60, "")
argCustCrdRetryMinDelay = pflag.Int("cust-crd-retry-min-delay", 2, "The min delay seconds between custom crd two retries")
argCustCrdRetryMinDelay = pflag.Int("cust-crd-retry-min-delay", 1, "The min delay seconds between custom crd two retries")
argCustCrdRetryMaxDelay = pflag.Int("cust-crd-retry-max-delay", 20, "The max delay seconds between custom crd two retries")
argKubeConfigFile = pflag.String("kubeconfig", "", "Path to kubeconfig file with authorization and master location information. If not set use the inCluster token.")

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (c *Controller) InitIPAM() error {
return err
}
for _, eip := range eips {
if _, _, _, err = c.ipam.GetStaticAddress(eip.Name, eip.Name, eip.Spec.V4ip, eip.Spec.MacAddress, util.VpcExternalNet, false); err != nil {
if _, _, _, err = c.ipam.GetStaticAddress(eip.Name, eip.Name, eip.Status.IP, eip.Spec.MacAddress, util.VpcExternalNet, true); err != nil {
klog.Errorf("failed to init ipam from iptables eip cr %s: %v", eip.Name, err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/pod_iptables_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ func (c *Controller) handleAddPodAnnotatedIptablesEip(key string) error {
return err
}
// update pod eip annotation
if eip.Spec.V4ip != "" {
newPod.Annotations[util.EipAnnotation] = eip.Spec.V4ip
if eip.Status.IP != "" {
newPod.Annotations[util.EipAnnotation] = eip.Status.IP
patch, err := util.GenerateStrategicMergePatchPayload(cachedPod, newPod)
if err != nil {
return err
Expand Down
Loading

0 comments on commit c410d8b

Please sign in to comment.