Skip to content

Commit db32634

Browse files
committed
[f5] change the way strict is disabled
proactivly remove strict from all childs before removing parent/child dependency. Also, force update of all endpoint/services with sql migration.
1 parent ac2f40d commit db32634

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

internal/agent/f5/bigip/bigip.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@ func (b *BigIP) EnsureRouteDomain(segmentId int, _ *int) error {
207207
Parent: "",
208208
}
209209

210+
// Disable all strict of Children
211+
// TODO: remove code after all strict's disabled
212+
for _, rd := range routeDomains.RouteDomains {
213+
if rd.Strict == "enabled" && rd.Parent != "" {
214+
log.WithField("route domain", rd.Name).Warning("Found route domain with strict enabled, updating to disabled")
215+
rd.Strict = "disabled"
216+
if err = rd.Update(b); err != nil {
217+
log.WithField("route domain", rd.Name).Errorf("failed to disable strict on route domain: %v", err)
218+
}
219+
}
220+
}
221+
210222
for _, rd := range routeDomains.RouteDomains {
211223
if rd.ID != segmentId {
212224
continue
@@ -216,15 +228,6 @@ func (b *BigIP) EnsureRouteDomain(segmentId int, _ *int) error {
216228
// already exists, nothing to do
217229
return nil
218230
}
219-
220-
// Special case where strict isolation and parenting is still on
221-
if rd.Parent != "" && rd.Strict == "enabled" {
222-
c.Parent = rd.Parent
223-
log.WithField("route domain", rd.Name).Warning("Found route domain with strict enabled, updating to disabled, retrying")
224-
if err = c.Update(b); err != nil {
225-
return fmt.Errorf("failed to disable strict on route domain: %w", err)
226-
}
227-
}
228231
}
229232

230233
return c.Update(b)

internal/db/migrations/migration.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,12 @@ var Migrations = mgx.Migrations(
290290
`)
291291
return err
292292
}),
293+
mgx.NewMigration("set_to_pending_update", func(ctx context.Context, commands mgx.Commands) error {
294+
_, err := commands.Exec(ctx, `
295+
-- set all services and endpoints to PENDING_UPDATE to trigger reconciliation
296+
UPDATE service SET status = 'PENDING_UPDATE' WHERE status = 'AVAILABLE' AND provider = 'tenant';
297+
UPDATE endpoint SET status = 'PENDING_UPDATE' WHERE status = 'AVAILABLE' AND endpoint.id IN (SELECT ep.id FROM endpoint ep JOIN service s ON ep.service_id = s.id WHERE s.provider = 'tenant');
298+
`)
299+
return err
300+
}),
293301
)

internal/db/migrations/migration_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/jackc/pgx/v5"
1212
"github.com/sapcc/go-bits/osext"
13+
"github.com/testcontainers/testcontainers-go"
1314
"github.com/testcontainers/testcontainers-go/modules/postgres"
1415
"github.com/z0ne-dev/mgx/v2"
1516
)
@@ -23,6 +24,7 @@ func TestMigrate(t *testing.T) {
2324
// start postgres container
2425
pgContainer, err := postgres.Run(t.Context(),
2526
"postgres:16-alpine",
27+
testcontainers.WithProvider(testcontainers.ProviderPodman),
2628
postgres.BasicWaitStrategies(),
2729
)
2830
if err != nil {

0 commit comments

Comments
 (0)