fix: remove identity from postgres-flex

[skip ci]
This commit is contained in:
Marcel S. Henselin 2026-03-16 15:45:53 +01:00
parent c1f463935b
commit ba579760d5
20 changed files with 570 additions and 581 deletions

View file

@ -53,8 +53,8 @@ type APIClientDatabaseInterface interface {
// CreateInstanceWaitHandler will wait for instance creation
func CreateInstanceWaitHandler(
ctx context.Context, a APIClientInstanceInterface, projectId, region,
instanceId string,
ctx context.Context, a APIClientInstanceInterface, projectID, region,
instanceID string,
) *wait.AsyncActionHandler[v3alpha1api.GetInstanceResponse] {
instanceCreated := false
var instanceGetResponse *v3alpha1api.GetInstanceResponse
@ -67,11 +67,11 @@ func CreateInstanceWaitHandler(
handler := wait.New(
func() (waitFinished bool, response *v3alpha1api.GetInstanceResponse, err error) {
if !instanceCreated {
s, err := a.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
if err != nil {
return false, nil, err
s, getErr := a.GetInstanceRequest(ctx, projectID, region, instanceID).Execute()
if getErr != nil {
return false, nil, getErr
}
if s == nil || s.Id != instanceId {
if s == nil || s.Id != instanceID {
return false, nil, nil
}
tflog.Debug(
@ -81,7 +81,7 @@ func CreateInstanceWaitHandler(
)
switch s.Status {
default:
return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, s.Status)
return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceID, s.Status)
case InstanceStateEmpty:
return false, nil, nil
case InstanceStatePending:
@ -98,30 +98,15 @@ func CreateInstanceWaitHandler(
"Wait handler still got status %s after %v for instance: %s",
InstanceStateProgressing,
maxWait,
instanceId,
instanceID,
),
)
if extendedTimeout < 3 {
maxWait += time.Minute * 5
extendedTimeout++
if *s.Network.AccessScope == "SNA" {
ready := true
if s.Network.InstanceAddress == nil {
tflog.Warn(ctx, "Waiting for instance_address")
ready = false
}
if s.Network.RouterAddress == nil {
tflog.Warn(ctx, "Waiting for router_address")
ready = false
}
if !ready {
return false, nil, nil
}
}
return false, nil, nil
}
instanceCreated = true
instanceGetResponse = s
return false, nil, fmt.Errorf("instance after max timeout still in state %s", InstanceStateProgressing)
case InstanceStateSuccess:
if s.Network.AccessScope != nil && *s.Network.AccessScope == "SNA" {
if s.Network.InstanceAddress == nil {
@ -144,9 +129,9 @@ func CreateInstanceWaitHandler(
},
)
var waitCounter int64 = 1
maxWait := big.NewInt(7)
n, err := rand.Int(rand.Reader, maxWait)
if err == nil {
maxWaitInt := big.NewInt(7)
n, randErr := rand.Int(rand.Reader, maxWaitInt)
if randErr == nil {
waitCounter = n.Int64() + 1
}
time.Sleep(time.Duration(waitCounter*30) * time.Second) //nolint:gosec // not that important and temporary
@ -154,7 +139,7 @@ func CreateInstanceWaitHandler(
}
return true, s, fmt.Errorf(
"update got status FAILURE for instance with id %s after %d retries",
instanceId,
instanceID,
failedCount,
)
// API responds with FAILURE for some seconds and then the instance goes to READY
@ -165,7 +150,7 @@ func CreateInstanceWaitHandler(
tflog.Info(ctx, "Waiting for instance (calling list users")
// // User operations aren't available right after an instance is deemed successful
// // To check if they are, perform a users request
_, err = a.ListUsersRequest(ctx, projectId, region, instanceId).Execute()
_, err = a.ListUsersRequest(ctx, projectID, region, instanceID).Execute()
if err == nil {
return true, instanceGetResponse, nil
}