Skip to content

Commit

Permalink
fixing maintenance time
Browse files Browse the repository at this point in the history
  • Loading branch information
wejdross committed Jan 7, 2025
1 parent 5b2dee8 commit 610b30f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 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 @@ -64,12 +63,21 @@ func DeployNextcloud(ctx context.Context, comp *vshnv1.VSHNNextcloud, svc *runti
if err != nil {
return runtime.NewWarningResult(fmt.Sprintf("cannot bootstrap instance namespace: %s", err))
}
/*
pointer here to the TimeOfDay struct in common_types.go caused the issue, with cretion of brand new value of TimeOfDay struct the issue was resolved
// AddTime adds duration to current time
func (a *TimeOfDay) AddTime(d time.Duration) TimeOfDay {
a.SetTime(a.GetTime().Add(d))
return *a
}
*/
pgTime := vshnv1.TimeOfDay(comp.GetMaintenanceTimeOfDay().GetTime().Add(20 * time.Minute).Format("11:11:11"))

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 +270,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 +441,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 610b30f

Please sign in to comment.