Skip to content

Commit

Permalink
Add validation on Session Affinity Config
Browse files Browse the repository at this point in the history
  • Loading branch information
sawsa307 committed Sep 12, 2024
1 parent 0cea547 commit f81472a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/i2gw/providers/gce/extensions/input_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ limitations under the License.
package extensions

import (
"fmt"

"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/intermediate"
backendconfigv1 "k8s.io/ingress-gce/pkg/apis/backendconfig/v1"
)

func ValidateBeConfig(beConfig *backendconfigv1.BackendConfig) error {
if beConfig.Spec.SessionAffinity.AffinityCookieTtlSec != nil && beConfig.Spec.SessionAffinity.AffinityType != "GENERATED_COOKIE" {
return fmt.Errorf("BackendConfig has affinityCookieTtlSec set, but affinityType is not GENERATED_COOKIE")
}
return nil
}

func BuildIRSessionAffinityConfig(beConfig *backendconfigv1.BackendConfig) *intermediate.SessionAffinityConfig {
return &intermediate.SessionAffinityConfig{
AffinityType: beConfig.Spec.SessionAffinity.AffinityType,
Expand Down
4 changes: 4 additions & 0 deletions pkg/i2gw/providers/gce/gce_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func buildGceServiceIR(ctx context.Context, storage *storage, ir *intermediate.I
if beConfig == nil {
continue
}
if err := extensions.ValidateBeConfig(beConfig); err != nil {
notify(notifications.ErrorNotification, err.Error(), beConfig)
continue
}
gceServiceIR := beConfigToGceServiceIR(beConfig)
services := beConfigToSvcs[beConfigKey]
for _, svcKey := range services {
Expand Down

0 comments on commit f81472a

Please sign in to comment.