Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Saratura committed Jan 24, 2025
1 parent 09a01f7 commit 83aca56
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
3 changes: 1 addition & 2 deletions pkg/auth/stackgres/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ func New(username, password, sgNamespace string) (*StackgresClient, error) {
if err != nil {
return nil, fmt.Errorf("cannot marshal login json: %w", err)
}
//prefixUrl := "https://stackgres-restapi." + sgNamespace + ".svc"
prefixUrl := "https://localhost:8081"
prefixUrl := "https://stackgres-restapi." + sgNamespace + ".svc"
resp, err := httpClient.Post(prefixUrl+"/stackgres/auth/login", "application/json", bytes.NewBuffer(byteAuth))
if err != nil {
return nil, fmt.Errorf("cannot login: %w", err)
Expand Down
24 changes: 12 additions & 12 deletions pkg/comp-functions/functions/vshnpostgres/major_version_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func MajorVersionUpgrade(ctx context.Context, comp *vshnv1.VSHNPostgreSQL, svc *
comp, err := getVSHNPostgreSQL(ctx, svc)

if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot get composite from function io: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot get composite from function io: %v", err))
}

expectedV := comp.Spec.Parameters.Service.MajorVersion
Expand All @@ -36,11 +36,11 @@ func MajorVersionUpgrade(ctx context.Context, comp *vshnv1.VSHNPostgreSQL, svc *
if currentV != "" && currentV != expectedV {
err = upgradePGSettings(comp, svc)
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot upgrade PG settings: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot upgrade PG settings: %v", err))
}
majorUpgradeDbOps, err := getSgDbOpsIfExists(err, svc, comp)
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot get major upgrade SgDbOps resource: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot get major upgrade SgDbOps resource: %v", err))
}

// If SGDBOps resource does not exist create it and keep during upgrade otherwise cleanup if successful
Expand All @@ -60,7 +60,7 @@ func getSgDbOpsIfExists(err error, svc *runtime.ServiceRuntime, comp *vshnv1.VSH
majorUpgradeDbOps := &stackgresv1.SGDbOps{}
err = svc.GetObservedKubeObject(majorUpgradeDbOps, fmt.Sprintf("%s-%s", comp.GetName(), majorUpgradeSuffix))
if err != nil && !errors.Is(err, runtime.ErrNotFound) {
return nil, fmt.Errorf("cannot get observed kube object major upgrade sgdbops: %w", err)
return nil, fmt.Errorf("cannot get observed kube object major upgrade sgdbops: %v", err)
}
if errors.Is(err, runtime.ErrNotFound) {
return nil, nil
Expand All @@ -78,7 +78,7 @@ func upgradePGSettings(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRuntime)
conf := &stackgresv1.SGPostgresConfig{}
err := svc.GetObservedKubeObject(conf, fmt.Sprintf("%s-%s-%s", comp.GetName(), configResourceName, comp.Status.CurrentVersion))
if err != nil {
return fmt.Errorf("cannot get observed kube object postgres config: %w", err)
return fmt.Errorf("cannot get observed kube object postgres config: %v", err)
}

expectedV := comp.Spec.Parameters.Service.MajorVersion
Expand All @@ -94,7 +94,7 @@ func upgradePGSettings(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRuntime)
}
err = svc.SetDesiredKubeObject(upgradeVersionConfig, fmt.Sprintf("%s-%s-%s", comp.GetName(), configResourceName, expectedV))
if err != nil {
return fmt.Errorf("cannot create current version postgres config: %w", err)
return fmt.Errorf("cannot create current version postgres config: %v", err)
}
return nil
}
Expand All @@ -114,7 +114,7 @@ func updateStatusVersion(svc *runtime.ServiceRuntime, comp *vshnv1.VSHNPostgreSQ
comp.Status.CurrentVersion = v
err := svc.SetDesiredCompositeStatus(comp)
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot update status field with the newest major postgres version: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot update status field with the newest major postgres version: %v", err))
}
return runtime.NewNormalResult("Major upgrade successfully finished, SGDBOps cleaned up")
}
Expand All @@ -139,27 +139,27 @@ func createMajorUpgradeSgDbOps(ctx context.Context, svc *runtime.ServiceRuntime,
cluster := &stackgresv1.SGCluster{}
err := svc.GetObservedKubeObject(cluster, "cluster")
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot get observed kube object cluster: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot get observed kube object cluster: %v", err))
}

sgNamespace := svc.Config.Data["sgNamespace"]
username, password, err := getCredentials(ctx, sgNamespace)
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot get stackgres rest api credentials: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot get stackgres rest api credentials: %v", err))
}
stackgresClient, err := stackgres.New(username, password, sgNamespace)
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot initialize stackgres client: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot initialize stackgres client: %v", err))
}

vList, err := stackgresClient.GetAvailableVersions()
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot get postgres version list: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot get postgres version list: %v", err))
}

majorMinorVersion, err := stackgres.GetLatestMinorVersion(expectedV, vList)
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot get latest minor version: %w", err))
return runtime.NewWarningResult(fmt.Sprintf("cannot get latest minor version: %v", err))
}

sgdbops := &stackgresv1.SGDbOps{
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/webhooks/postgresql_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package webhooks

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/maintenance/postgresql_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package maintenance

import (
Expand Down

0 comments on commit 83aca56

Please sign in to comment.