Skip to content

Commit

Permalink
feat: change middleware initialization at right cns channel mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kmurudi committed Jan 25, 2024
1 parent 8776afe commit f457f6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 0 additions & 2 deletions cns/middlewares/SFSwiftV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/Azure/azure-container-networking/cns/logger"
"github.com/Azure/azure-container-networking/cns/types"
"github.com/pkg/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
"time"

Check failure on line 11 in cns/middlewares/SFSwiftV2.go

View workflow job for this annotation

GitHub Actions / Lint (1.21.x, ubuntu-latest)

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
)

Expand All @@ -19,7 +18,6 @@ const (
)

type SFSWIFTv2Middleware struct {

Check failure on line 20 in cns/middlewares/SFSwiftV2.go

View workflow job for this annotation

GitHub Actions / Lint (1.21.x, ubuntu-latest)

File is not `gofumpt`-ed (gofumpt)
Cli client.Client
}

// Verify interface compliance at compile time
Expand Down
24 changes: 12 additions & 12 deletions cns/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,13 @@ func main() {
if platform.HasMellanoxAdapter() {
go platform.MonitorAndSetMellanoxRegKeyPriorityVLANTag(rootCtx, cnsconfig.MellanoxMonitorIntervalSecs)
}
// if swiftv2 scenario is enabled, we need to initialize the Service Fabric (standalone) swiftv2 middleware to process IP configs requests
if cnsconfig.EnableSwiftV2 {
if cnsconfig.SWIFTV2Mode == configuration.SFSWIFTV2 {
swiftV2Middleware := &middlewares.SFSWIFTv2Middleware{}
httpRestService.AttachIPConfigsHandlerMiddleware(swiftV2Middleware)
}
}
}

// Initialze state in if CNS is running in CRD mode
Expand Down Expand Up @@ -1381,19 +1388,12 @@ func InitializeCRDState(ctx context.Context, httpRestService cns.HTTPService, cn
return errors.Wrapf(err, "failed to setup mtpnc reconciler with manager")
}
// if SWIFT v2 is enabled on CNS, attach multitenant middleware to rest service
// switch here for different type of swift v2 middleware (k8s or SF)
var swiftV2Middleware cns.IPConfigsHandlerMiddleware
switch cnsconfig.SWIFTV2Mode {
case configuration.K8sSWIFTV2:
swiftV2Middleware = &middlewares.K8sSWIFTv2Middleware{Cli: manager.GetClient()}
case configuration.SFSWIFTV2:
swiftV2Middleware = &middlewares.SFSWIFTv2Middleware{Cli: manager.GetClient()}
default:
// default to K8s middleware for now, in a later changes we where start to pass in
// SWIFT v2 mode in CNS config, this should throw an error if the mode is not set.
swiftV2Middleware = &middlewares.K8sSWIFTv2Middleware{Cli: manager.GetClient()}
// here for AKS(K8s) swiftv2 middleware to process IP configs requests
if cnsconfig.SWIFTV2Mode == configuration.K8sSWIFTV2 {
swiftV2Middleware := &middlewares.K8sSWIFTv2Middleware{Cli: manager.GetClient()}
httpRestService.AttachIPConfigsHandlerMiddleware(swiftV2Middleware)
}
httpRestService.AttachIPConfigsHandlerMiddleware(swiftV2Middleware)

}

// start the pool Monitor before the Reconciler, since it needs to be ready to receive an
Expand Down

0 comments on commit f457f6a

Please sign in to comment.