Feat/separate functions (#19)
* chore: work save * fix: refactor flavors * fix: refactor pg user and database * fix: refactor flavor parameters * fix: refactor tf script * chore: work save * chore: work save * chore: work save --------- Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
This commit is contained in:
parent
910551f09d
commit
0150fea302
54 changed files with 6010 additions and 2826 deletions
|
|
@ -94,6 +94,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.ListUsersRequestExecute(ctx, projectId, region, instanceId)
|
||||
|
|
@ -114,7 +115,7 @@ func CreateInstanceWaitHandler(
|
|||
},
|
||||
)
|
||||
// Sleep before wait is set because sometimes API returns 404 right after creation request
|
||||
handler.SetTimeout(45 * time.Minute).SetSleepBeforeWait(15 * time.Second)
|
||||
handler.SetTimeout(90 * time.Minute).SetSleepBeforeWait(30 * time.Second)
|
||||
return handler
|
||||
}
|
||||
|
||||
|
|
@ -154,72 +155,72 @@ func PartialUpdateInstanceWaitHandler(
|
|||
return handler
|
||||
}
|
||||
|
||||
// DeleteInstanceWaitHandler will wait for instance deletion
|
||||
func DeleteInstanceWaitHandler(
|
||||
ctx context.Context,
|
||||
a APIClientInstanceInterface,
|
||||
projectId, region, instanceId string,
|
||||
) *wait.AsyncActionHandler[struct{}] {
|
||||
handler := wait.New(
|
||||
func() (waitFinished bool, response *struct{}, err error) {
|
||||
s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
|
||||
return false, nil, nil
|
||||
}
|
||||
// TODO - maybe we want to validate status if no 404 error (only unknown or terminating should be valid)
|
||||
// switch *s.Status {
|
||||
// default:
|
||||
// return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
|
||||
// case InstanceStateSuccess:
|
||||
// return false, nil, nil
|
||||
// case InstanceStateTerminating:
|
||||
// return false, nil, nil
|
||||
// }
|
||||
|
||||
// TODO - add tflog for ignored cases
|
||||
oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
|
||||
if !ok {
|
||||
return false, nil, err
|
||||
}
|
||||
if oapiErr.StatusCode != 404 {
|
||||
return false, nil, err
|
||||
}
|
||||
return true, nil, nil
|
||||
},
|
||||
)
|
||||
handler.SetTimeout(5 * time.Minute)
|
||||
return handler
|
||||
}
|
||||
|
||||
// TODO - remove
|
||||
// ForceDeleteInstanceWaitHandler will wait for instance deletion
|
||||
func ForceDeleteInstanceWaitHandler(
|
||||
ctx context.Context,
|
||||
a APIClientInstanceInterface,
|
||||
projectId, region, instanceId string,
|
||||
) *wait.AsyncActionHandler[struct{}] {
|
||||
handler := wait.New(
|
||||
func() (waitFinished bool, response *struct{}, err error) {
|
||||
_, err = a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
|
||||
if err == nil {
|
||||
return false, nil, nil
|
||||
}
|
||||
oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
|
||||
if !ok {
|
||||
return false, nil, err
|
||||
}
|
||||
if oapiErr.StatusCode != 404 {
|
||||
return false, nil, err
|
||||
}
|
||||
return true, nil, nil
|
||||
},
|
||||
)
|
||||
handler.SetTimeout(15 * time.Minute)
|
||||
return handler
|
||||
}
|
||||
//// DeleteInstanceWaitHandler will wait for instance deletion
|
||||
//func DeleteInstanceWaitHandler(
|
||||
// ctx context.Context,
|
||||
// a APIClientInstanceInterface,
|
||||
// projectId, region, instanceId string,
|
||||
//) *wait.AsyncActionHandler[struct{}] {
|
||||
// handler := wait.New(
|
||||
// func() (waitFinished bool, response *struct{}, err error) {
|
||||
// s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
|
||||
// if err != nil {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
|
||||
// return false, nil, nil
|
||||
// }
|
||||
// // TODO - maybe we want to validate status if no 404 error (only unknown or terminating should be valid)
|
||||
// // switch *s.Status {
|
||||
// // default:
|
||||
// // return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
|
||||
// // case InstanceStateSuccess:
|
||||
// // return false, nil, nil
|
||||
// // case InstanceStateTerminating:
|
||||
// // return false, nil, nil
|
||||
// // }
|
||||
//
|
||||
// // TODO - add tflog for ignored cases
|
||||
// oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
|
||||
// if !ok {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// if oapiErr.StatusCode != 404 {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// return true, nil, nil
|
||||
// },
|
||||
// )
|
||||
// handler.SetTimeout(5 * time.Minute)
|
||||
// return handler
|
||||
//}
|
||||
//
|
||||
//// TODO - remove
|
||||
//// ForceDeleteInstanceWaitHandler will wait for instance deletion
|
||||
//func ForceDeleteInstanceWaitHandler(
|
||||
// ctx context.Context,
|
||||
// a APIClientInstanceInterface,
|
||||
// projectId, region, instanceId string,
|
||||
//) *wait.AsyncActionHandler[struct{}] {
|
||||
// handler := wait.New(
|
||||
// func() (waitFinished bool, response *struct{}, err error) {
|
||||
// _, err = a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
|
||||
// if err == nil {
|
||||
// return false, nil, nil
|
||||
// }
|
||||
// oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
|
||||
// if !ok {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// if oapiErr.StatusCode != 404 {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// return true, nil, nil
|
||||
// },
|
||||
// )
|
||||
// handler.SetTimeout(15 * time.Minute)
|
||||
// return handler
|
||||
//}
|
||||
|
||||
// DeleteUserWaitHandler will wait for delete
|
||||
func DeleteUserWaitHandler(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue