Skip to content

Commit

Permalink
tested on OSD with managed DB and fixed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes94 committed Sep 5, 2023
1 parent 20e29f3 commit 9b6968e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
10 changes: 5 additions & 5 deletions dev/env/scripts/exec_fleetshard_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export AWS_AUTH_HELPER="${AWS_AUTH_HELPER:-aws-saml}"
source "${GITROOT}/scripts/lib/external_config.sh"
init_chamber

CLUSTER_NAME="cluster-acs-dev-dp-01"
CLUSTER_NAME="${CLUSTER_NAME:-cluster-acs-dev-dp-01}"

ARGS="CLUSTER_ID=${CLUSTER_ID:-$(chamber read ${CLUSTER_NAME} ID -q -b ssm)} \
MANAGED_DB_SECURITY_GROUP=${MANAGED_DB_SECURITY_GROUP:-$(chamber read ${CLUSTER_NAME} MANAGED_DB_SECURITY_GROUP -q -b ssm)} \
MANAGED_DB_SUBNET_GROUP=${MANAGED_DB_SUBNET_GROUP:-$(chamber read ${CLUSTER_NAME} MANAGED_DB_SUBNET_GROUP -q -b ssm)} \
SECRET_ENCRYPTION_KEY_ID=${SECRET_ENCRYPTION_KEY_ID:-$(chamber read ${CLUSTER_NAME} SECRET_ENCRYPTION_KEY_ID -q -b ssm)} \
ARGS="CLUSTER_ID=${CLUSTER_ID:-$(chamber read "${CLUSTER_NAME}" ID -q -b ssm)} \
MANAGED_DB_SECURITY_GROUP=${MANAGED_DB_SECURITY_GROUP:-$(chamber read "${CLUSTER_NAME}" MANAGED_DB_SECURITY_GROUP -q -b ssm)} \
MANAGED_DB_SUBNET_GROUP=${MANAGED_DB_SUBNET_GROUP:-$(chamber read "${CLUSTER_NAME}" MANAGED_DB_SUBNET_GROUP -q -b ssm)} \
SECRET_ENCRYPTION_KEY_ID=${SECRET_ENCRYPTION_KEY_ID:-$(chamber read "${CLUSTER_NAME}" SECRET_ENCRYPTION_KEY_ID -q -b ssm)} \
AWS_ROLE_ARN=${FLEETSHARD_SYNC_AWS_ROLE_ARN:-$(chamber read fleetshard-sync AWS_ROLE_ARN -q -b ssm)} \
$ARGS"

Expand Down
4 changes: 2 additions & 2 deletions docs/development/howto-e2e-test-rds.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ At the point in time this documentation was written AWS RDS DB creation and dele
# Prepare environment
export AWS_AUTH_HELPER=aws-saml
export MANAGED_DB_ENABLED=true
# flip the PublicAcessible flag to true in rds.go line 354
export CLUSTER_NAME=local_cluster
# flip the PubliclyAccessible flag to true in rds.go line 514
make binary
./dev/env/scripts/exec_fleetshard_sync.sh
Expand Down
7 changes: 6 additions & 1 deletion internal/dinosaur/pkg/handlers/admin_dinosaur.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type AdminCentralHandler interface {
SetCentralDefaultVersion(w http.ResponseWriter, r *http.Request)
// GetCentralDefaultVersion gets the default version for a central
GetCentralDefaultVersion(w http.ResponseWriter, r *http.Request)
// Restore restores a tenant that was already marked as deleted
Restore(w http.ResponseWriter, r *http.Request)
}

type adminCentralHandler struct {
Expand Down Expand Up @@ -198,7 +200,6 @@ func (h adminCentralHandler) Restore(w http.ResponseWriter, r *http.Request) {
id := mux.Vars(r)["id"]
ctx := r.Context()
err := h.service.Restore(ctx, id)
h.telemetry.TrackDeletionRequested(ctx, id, true, err.AsError())
return nil, err
},
}
Expand Down Expand Up @@ -461,3 +462,7 @@ func (g gitOpsAdminHandler) SetCentralDefaultVersion(w http.ResponseWriter, r *h
func (g gitOpsAdminHandler) GetCentralDefaultVersion(w http.ResponseWriter, r *http.Request) {
http.Error(w, "not implemented", http.StatusNotImplemented)
}

func (g gitOpsAdminHandler) Restore(w http.ResponseWriter, r *http.Request) {
http.Error(w, "not implemented", http.StatusNotImplemented)
}
2 changes: 1 addition & 1 deletion internal/dinosaur/pkg/routes/route_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (s *options) buildAPIBaseRouter(mainRouter *mux.Router, basePath string, op
adminCentralsRouter.HandleFunc("/{id}", adminCentralHandler.Update).
Name(logger.NewLogEvent("admin-update-central", "[admin] update central by id").ToString()).
Methods(http.MethodPatch)
adminCentralsRouter.HandleFunc("/{id}/restore", func(w http.ResponseWriter, r *http.Request) { /*Placeholde*/ }).
adminCentralsRouter.HandleFunc("/{id}/restore", adminCentralHandler.Restore).
Name(logger.NewLogEvent("admin-restore-central", "[admin] restore central by id").ToString()).
Methods(http.MethodPost)

Expand Down
6 changes: 4 additions & 2 deletions internal/dinosaur/pkg/services/dinosaur.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,10 @@ func (k *dinosaurService) Restore(ctx context.Context, id string) *errors.Servic
// use a new central request, so that unset field for columnsToReset will automatically be set to the zero value
// this Update only changes columns listed in columnsToReset
resetRequest := &dbapi.CentralRequest{}
resetRequest.Status = dinosaurConstants.CentralRequestStatusProvisioning.String()
if err := dbConn.Model(&centralRequest).Select(columnsToReset).Updates(resetRequest).Error; err != nil {
resetRequest.Status = dinosaurConstants.CentralRequestStatusPreparing.String()
resetRequest.CreatedAt = time.Now()

if err := dbConn.Unscoped().Model(&centralRequest).Select(columnsToReset).Updates(resetRequest).Error; err != nil {
return errors.NewWithCause(errors.ErrorGeneral, err, "Unable to reset CentralRequest status")
}

Expand Down

0 comments on commit 9b6968e

Please sign in to comment.