Skip to content

Commit

Permalink
Merge pull request #226 from vshn/fix/timescaledb_extension_bug
Browse files Browse the repository at this point in the history
fixing timescaledb extension bug
  • Loading branch information
wejdross committed Sep 2, 2024
2 parents 514a14c + bf8fe2a commit 397fbbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/comp-functions/functions/vshnpostgres/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func AddExtensions(ctx context.Context, comp *vshnv1.VSHNPostgreSQL, svc *runtim
}

if _, ok := extensionsMap["timescaledb"]; ok {
err := enableTimescaleDB(ctx, svc)
err := enableTimescaleDB(ctx, svc, comp.GetName())
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("cannot add timescaldb to config: %w", err))
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func AddExtensions(ctx context.Context, comp *vshnv1.VSHNPostgreSQL, svc *runtim
return nil
}

func enableTimescaleDB(ctx context.Context, svc *runtime.ServiceRuntime) error {
func enableTimescaleDB(ctx context.Context, svc *runtime.ServiceRuntime, name string) error {

config := &stackgresv1.SGPostgresConfig{}

Expand All @@ -105,7 +105,7 @@ func enableTimescaleDB(ctx context.Context, svc *runtime.ServiceRuntime) error {
config.Spec.PostgresqlConf[sharedLibraries] = fmt.Sprintf("%s,%s", toAppend, timescaleExtName)
}

return svc.SetDesiredKubeObject(config, configResourceName)
return svc.SetDesiredKubeObjectWithName(config, name+"-"+configResourceName, configResourceName)
}

func disableTimescaleDB(ctx context.Context, svc *runtime.ServiceRuntime) error {
Expand Down
11 changes: 10 additions & 1 deletion pkg/comp-functions/functions/vshnpostgres/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,17 @@ func Test_enableTimescaleDB(t *testing.T) {
ctx := context.TODO()
svc := commontest.LoadRuntimeFromFile(t, tt.iofFile)

comp := &vshnv1.VSHNPostgreSQL{}

err := svc.GetDesiredComposite(comp)
if err != nil {
t.Fatal("Can't get composite", err)
}

t.Log("Composite", comp.GetName())

t.Run(tt.name, func(t *testing.T) {
if err := enableTimescaleDB(ctx, svc); (err != nil) != tt.wantErr {
if err := enableTimescaleDB(ctx, svc, comp.GetName()); (err != nil) != tt.wantErr {
t.Errorf("enableTimescaleDB() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down

0 comments on commit 397fbbb

Please sign in to comment.