Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing maintenance time #291

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this line we defaulted maintenance time to "00:20:00" for all instances :D

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)
wejdross marked this conversation as resolved.
Show resolved Hide resolved
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
Comment on lines -439 to -445
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a cleanup of unused function

return strings.Replace(nextcloudConfig, "%maintenance_value%", strconv.Itoa(backgroundJobHour), 1)
}
Loading