Skip to content

Commit

Permalink
Merge pull request #291 from vshn/fix/maintenanceTime
Browse files Browse the repository at this point in the history
fixing maintenance time
  • Loading branch information
wejdross authored Jan 7, 2025
2 parents 5b2dee8 + 10ca29d commit ddcb939
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pkg/comp-functions/functions/vshnnextcloud/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"
"time"

valid "github.com/asaskevich/govalidator"
xfnproto "github.com/crossplane/function-sdk-go/proto/v1beta1"
xhelmv1 "github.com/vshn/appcat/v4/apis/helm/release/v1beta1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
Expand Down Expand Up @@ -65,11 +64,14 @@ func DeployNextcloud(ctx context.Context, comp *vshnv1.VSHNNextcloud, svc *runti
return runtime.NewWarningResult(fmt.Sprintf("cannot bootstrap instance namespace: %s", err))
}

var pgTime vshnv1.TimeOfDay
pgTime.SetTime(comp.GetMaintenanceTimeOfDay().GetTime().Add(20 * time.Minute))

if comp.Spec.Parameters.Service.UseExternalPostgreSQL {
svc.Log.Info("Adding postgresql instance")
err = common.NewPostgreSQLDependencyBuilder(svc, comp).
AddParameters(comp.Spec.Parameters.Service.PostgreSQLParameters).
SetCustomMaintenanceSchedule(comp.Spec.Parameters.Maintenance.TimeOfDay.AddTime(20 * time.Minute)).
SetCustomMaintenanceSchedule(pgTime).
CreateDependency()
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot create postgresql instance: %s", err))
Expand Down Expand Up @@ -262,7 +264,7 @@ func newValues(ctx context.Context, svc *runtime.ServiceRuntime, comp *vshnv1.VS
}
trustedDomain = append(trustedDomain, comp.Spec.Parameters.Service.FQDN...)

updatedNextcloudConfig := setBackgroundJobMaintenance(comp.Spec.Parameters.Maintenance.GetMaintenanceTimeOfDay(), nextcloudConfig)
updatedNextcloudConfig := setBackgroundJobMaintenance(*comp.GetMaintenanceTimeOfDay(), nextcloudConfig)
values = map[string]any{
"nextcloud": map[string]any{
"host": comp.Spec.Parameters.Service.FQDN[0],
Expand Down Expand Up @@ -433,14 +435,6 @@ func setBackgroundJobMaintenance(t vshnv1.TimeOfDay, nextcloudConfig string) str
// Start Background Job Maintenance no earlier than 20 min after the regular Maintenance
// and no later than 1 hour and 39 min after the regular Maintenance
backgroundJobHour := t.GetTime().Add(40 * time.Minute).Add(time.Hour).Hour()
return strings.Replace(nextcloudConfig, "%maintenance_value%", strconv.Itoa(backgroundJobHour), 1)
}

func validateFQDNs(fqdns []string) error {
for _, fqdn := range fqdns {
if !valid.IsDNSName(fqdn) {
return fmt.Errorf("FQDN %s is not a valid DNS name", fqdn)
}
}
return nil
return strings.Replace(nextcloudConfig, "%maintenance_value%", strconv.Itoa(backgroundJobHour), 1)
}

0 comments on commit ddcb939

Please sign in to comment.