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

Ver 90388 save restore point before upgrade #920

Draft
wants to merge 65 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4efd5ef
Add new condition type
HaoYang0000 Sep 3, 2024
3b2b403
Add new type in beta type
HaoYang0000 Sep 3, 2024
2f46aa4
add new event type
HaoYang0000 Sep 6, 2024
559be18
Create MakeCreateArchiveReconciler interface
HaoYang0000 Sep 6, 2024
d2f703a
create archive in vc
HaoYang0000 Sep 9, 2024
5ea9d38
create archive opts
HaoYang0000 Sep 9, 2024
2cb92d7
VCreateArchive in VclusterProvider interface
HaoYang0000 Sep 9, 2024
c2539a1
add create_archive_at method
HaoYang0000 Sep 9, 2024
680bef4
Add missing method in vadmin interface
HaoYang0000 Sep 9, 2024
60d0191
bug fix
HaoYang0000 Sep 9, 2024
03567a8
createArchive reconciler
HaoYang0000 Sep 9, 2024
77c5440
Add trigger annotation
HaoYang0000 Sep 9, 2024
c1366d0
add missing mock methods
HaoYang0000 Sep 9, 2024
7e5bd1d
add unit test
HaoYang0000 Sep 9, 2024
135c1bf
apply go.mod change
HaoYang0000 Sep 9, 2024
d1bf37e
push for testing
HaoYang0000 Sep 9, 2024
6bc5e0c
debuging
HaoYang0000 Sep 9, 2024
4306123
debug with name
HaoYang0000 Sep 9, 2024
a7c70c1
fix nul pointer issue
HaoYang0000 Sep 9, 2024
703726e
fix hosts assignment
HaoYang0000 Sep 9, 2024
a755c2c
use hostip
HaoYang0000 Sep 9, 2024
7aa4bf7
create archive based on condition flag SaveRestorePointsNeeded
HaoYang0000 Sep 10, 2024
10690d8
create archive impl test done
HaoYang0000 Sep 10, 2024
c01016e
add save restore point event str
HaoYang0000 Sep 10, 2024
550fed6
create save restore point related vcluster methods
HaoYang0000 Sep 10, 2024
3e44008
create mockops method
HaoYang0000 Sep 10, 2024
1a65916
save restore point impl
HaoYang0000 Sep 10, 2024
e0e943f
undo makefile debug changes
HaoYang0000 Sep 10, 2024
56358e7
condition text change
HaoYang0000 Sep 10, 2024
2e1a214
Merge branch 'main' into VER-90387_create_restore_based_on_condition
HaoYang0000 Sep 10, 2024
8a6e7ab
comment change
HaoYang0000 Sep 10, 2024
4d4b863
add comment
HaoYang0000 Sep 11, 2024
54a2782
rename NumOfArchives to NumRestorePoints
HaoYang0000 Sep 11, 2024
5be8b72
create new event when archive duplicate
HaoYang0000 Sep 11, 2024
08a8a49
switch event to warning
HaoYang0000 Sep 11, 2024
307c187
add new minimal version
HaoYang0000 Sep 11, 2024
c518db9
add version check
HaoYang0000 Sep 11, 2024
693dc3a
Update go version
HaoYang0000 Sep 11, 2024
1a44346
remove unrelated chanegs
HaoYang0000 Sep 11, 2024
32c6e19
create feature flag
HaoYang0000 Sep 11, 2024
b1db019
add job true false status
HaoYang0000 Sep 11, 2024
012afec
create saverestorepoint reconciler
HaoYang0000 Sep 11, 2024
c43de68
create saverestore reconciler
HaoYang0000 Sep 11, 2024
d3a8e9f
replace existing upgrade manager with save restore reconciler logic
HaoYang0000 Sep 11, 2024
923003d
change order of condition check
HaoYang0000 Sep 13, 2024
1233fa9
check deployment method and log error
HaoYang0000 Sep 13, 2024
5663695
change reconciler order
HaoYang0000 Sep 13, 2024
fb93c3b
requeue if no up pod found
HaoYang0000 Sep 13, 2024
2858552
change log error
HaoYang0000 Sep 14, 2024
6bc209f
apply requeue
HaoYang0000 Sep 14, 2024
372fc09
change condition check order
HaoYang0000 Sep 14, 2024
30caca1
fix unit test
HaoYang0000 Sep 14, 2024
73b4c6e
Merge branch 'VER-90387_create_restore_based_on_condition' into VER-9…
HaoYang0000 Sep 14, 2024
83dce05
Update new reconciler
roypaulin Sep 16, 2024
52bae88
Merge remote-tracking branch 'origin/main' into VER-90387_create_rest…
roypaulin Sep 16, 2024
94e8de2
Add e2e test
roypaulin Sep 17, 2024
668189c
Fix test
roypaulin Sep 17, 2024
39a3086
Update vclusterops
roypaulin Sep 17, 2024
22e62c5
Rename e2e test
roypaulin Sep 17, 2024
44a21e1
Merge remote-tracking branch 'origin/main' into VER-90387_create_rest…
roypaulin Sep 17, 2024
cafc23b
Merge branch 'VER-90387_create_restore_based_on_condition' of github.…
HaoYang0000 Sep 18, 2024
0645f2a
merge latest changes with VER-90387_create_restore_based_on_condition
HaoYang0000 Sep 18, 2024
709b161
clean up changes
HaoYang0000 Sep 18, 2024
8038adf
clean up change
HaoYang0000 Sep 18, 2024
c88de60
offline upgrade draft
HaoYang0000 Sep 18, 2024
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
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ docker-build-operator: manifests generate fmt vet ## Build operator docker image
--build-arg GO_VERSION=${GO_VERSION} \
-f docker-operator/Dockerfile .


.PHONY: docker-build-vlogger
docker-build-vlogger: ## Build vertica logger docker image
docker pull ${VLOGGER_BASE_IMG}:${VLOGGER_ALPINE_VERSION} # Ensure we have the latest alpine version
Expand Down
12 changes: 12 additions & 0 deletions api/v1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,12 +868,24 @@ func (r *RestorePointPolicy) IsValidRestorePointPolicy() bool {
return r != nil && r.Archive != "" && ((r.Index > 0) != (r.ID != ""))
}

// IsValidForSaveRestorePoint returns true id archive name to be used
// for creating a restore point is set.
func (r *RestorePointPolicy) IsValidForSaveRestorePoint() bool {
return r != nil && r.Archive != ""
}

// IsRestoreEnabled will return whether the vdb is configured to initialize by reviving from
// a restore point in an archive
func (v *VerticaDB) IsRestoreEnabled() bool {
return v.Spec.InitPolicy == CommunalInitPolicyRevive && v.Spec.RestorePoint != nil
}

// IsSaveRestorepointEnabled returns true if the status condition that
// control restore point is set to true.
func (v *VerticaDB) IsSaveRestorepointEnabled() bool {
return v.IsStatusConditionTrue(SaveRestorePointsNeeded)
}

// IsHTTPSTLSConfGenerationEnabled return true if the httpstls.json file should
// be generated by the installer.
func (v *VerticaDB) IsHTTPSTLSConfGenerationEnabled() (bool, error) {
Expand Down
2 changes: 2 additions & 0 deletions api/v1/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const (
SandboxSupportedMinVersion = "v24.3.0"
// Starting in v24.3.0, we call vclusterops API to get node details instead of executing vsql within the pod
FetchNodeDetailsWithVclusterOpsMinVersion = "v24.3.0"
// Starting in v24.4.0, nma server will support create restore point to an existing archive
SaveRestorePointNMAOpsMinVersion = "v24.4.0"
)

// GetVerticaVersionStr returns the vertica version, in string form, that is stored
Expand Down
19 changes: 19 additions & 0 deletions api/v1/verticadb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,21 @@ type VerticaDBStatus struct {
// +optional
// The sandbox statuses
Sandboxes []SandboxStatus `json:"sandboxes,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=status
// +optional
// The details about the last created restore point
RestorePoint *RestorePointInfo `json:"restorePoint"`
}

type RestorePointInfo struct {
// +operator-sdk:csv:customresourcedefinitions:type=status
// Name of the archive that this restore point was created in.
Archive string `json:"archive"`
// +operator-sdk:csv:customresourcedefinitions:type=status
StartTimestamp string `json:"startTimestamp"`
// +operator-sdk:csv:customresourcedefinitions:type=status
EndTimestamp string `json:"endTimestamp"`
}

type SandboxUpgradeState struct {
Expand Down Expand Up @@ -890,6 +905,10 @@ const (
// VerticaRestartNeeded is a condition that when set to true will force the
// operator to stop/start the vertica pods.
VerticaRestartNeeded = "VerticaRestartNeeded"
// SaveRestorePointsNeeded is a condition that when set to true will,
// the operator will create the archive, using the spec.restorePoint.archive
// as the archive name to save to.
SaveRestorePointsNeeded = "SaveRestorePointsNeeded"
)

const (
Expand Down
12 changes: 12 additions & 0 deletions api/v1/verticadb_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (v *VerticaDB) validateVerticaDBSpec() field.ErrorList {
allErrs = v.hasValidSubclusterTypes(allErrs)
allErrs = v.hasValidInitPolicy(allErrs)
allErrs = v.hasValidRestorePolicy(allErrs)
allErrs = v.hasValidSaveRestorePointConfig(allErrs)
allErrs = v.hasValidDBName(allErrs)
allErrs = v.hasPrimarySubcluster(allErrs)
allErrs = v.validateKsafety(allErrs)
Expand Down Expand Up @@ -304,6 +305,17 @@ func (v *VerticaDB) hasValidRestorePolicy(allErrs field.ErrorList) field.ErrorLi
return allErrs
}

func (v *VerticaDB) hasValidSaveRestorePointConfig(allErrs field.ErrorList) field.ErrorList {
if v.IsSaveRestorepointEnabled() && !v.Spec.RestorePoint.IsValidForSaveRestorePoint() {
err := field.Invalid(field.NewPath("spec").Child("restorePoint"),
v.Spec.RestorePoint,
"restorePoint is invalid. When save restore point is enabled, "+
"archive must be specified.")
allErrs = append(allErrs, err)
}
return allErrs
}

func (v *VerticaDB) validateCommunalPath(allErrs field.ErrorList) field.ErrorList {
if v.Spec.InitPolicy == CommunalInitPolicyScheduleOnly {
return allErrs
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/verticadb_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func convertToStatus(src *VerticaDBStatus) v1.VerticaDBStatus {
Conditions: make([]metav1.Condition, 0),
UpgradeStatus: src.UpgradeStatus,
Sandboxes: make([]v1.SandboxStatus, len(src.Sandboxes)),
RestorePoint: (*v1.RestorePointInfo)(src.RestorePoint),
}
for i := range src.Subclusters {
dst.Subclusters[i] = convertToSubclusterStatus(src.Subclusters[i])
Expand All @@ -285,6 +286,7 @@ func convertFromStatus(src *v1.VerticaDBStatus) VerticaDBStatus {
Conditions: make([]VerticaDBCondition, len(src.Conditions)),
UpgradeStatus: src.UpgradeStatus,
Sandboxes: make([]SandboxStatus, len(src.Sandboxes)),
RestorePoint: (*RestorePointInfo)(src.RestorePoint),
}
for i := range src.Subclusters {
dst.Subclusters[i] = convertFromSubclusterStatus(src.Subclusters[i])
Expand Down
19 changes: 19 additions & 0 deletions api/v1beta1/verticadb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,21 @@ type VerticaDBStatus struct {
// +optional
// The sandbox statuses
Sandboxes []SandboxStatus `json:"sandboxes,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=status
// +optional
// The details about the last created restore point
RestorePoint *RestorePointInfo `json:"restorePoint"`
}

type RestorePointInfo struct {
// +operator-sdk:csv:customresourcedefinitions:type=status
// Name of the archive that this restore point was created in.
Archive string `json:"archive"`
// +operator-sdk:csv:customresourcedefinitions:type=status
StartTimestamp string `json:"startTimestamp"`
// +operator-sdk:csv:customresourcedefinitions:type=status
EndTimestamp string `json:"endTimestamp"`
}

type SandboxUpgradeState struct {
Expand Down Expand Up @@ -974,6 +989,10 @@ const (
// VerticaRestartNeeded is a condition that when set to true will force the
// operator to stop/start the vertica pods.
VerticaRestartNeeded VerticaDBConditionType = "VerticaRestartNeeded"
// SaveRestorePointsNeeded is a condition that when set to true will,
// the operator will create the archive, using the spec.restorePoint.archive
// as the archive name to save to.
SaveRestorePointsNeeded VerticaDBConditionType = "SaveRestorePointsNeeded"
)

// VerticaDBCondition defines condition for VerticaDB
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/onsi/gomega v1.24.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/vertica/vcluster v1.2.1-0.20240824015949-397ced8a6708
github.com/vertica/vcluster v1.2.1-0.20240916125930-0654788be326
github.com/vertica/vertica-sql-go v1.1.1
go.uber.org/zap v1.25.0
golang.org/x/text v0.14.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ github.com/theckman/yacspin v0.13.12 h1:CdZ57+n0U6JMuh2xqjnjRq5Haj6v1ner2djtLQRz
github.com/theckman/yacspin v0.13.12/go.mod h1:Rd2+oG2LmQi5f3zC3yeZAOl245z8QOvrH4OPOJNZxLg=
github.com/tonglil/buflogr v1.0.1 h1:WXFZLKxLfqcVSmckwiMCF8jJwjIgmStJmg63YKRF1p0=
github.com/tonglil/buflogr v1.0.1/go.mod h1:yYWwvSpn/3uAaqjf6mJg/XMiAciaR0QcRJH2gJGDxNE=
github.com/vertica/vcluster v1.2.1-0.20240824015949-397ced8a6708 h1:wjYVhJxvlymSIlBYfRMJuBngPzm/qavKhH/vLcKxzf0=
github.com/vertica/vcluster v1.2.1-0.20240824015949-397ced8a6708/go.mod h1:yZ3lnvlwuXWgyCZ9Z6bMYisVjP6Ecffl+Lk5wGX/lPQ=
github.com/vertica/vcluster v1.2.1-0.20240916125930-0654788be326 h1:ZLUnWRhcMQDMDePS+qKZAmQkx/qn/mt6gcrL3y4iaaI=
github.com/vertica/vcluster v1.2.1-0.20240916125930-0654788be326/go.mod h1:yZ3lnvlwuXWgyCZ9Z6bMYisVjP6Ecffl+Lk5wGX/lPQ=
github.com/vertica/vertica-sql-go v1.1.1 h1:sZYijzBbvdAbJcl4cYlKjR+Eh/X1hGKzukWuhh8PjvI=
github.com/vertica/vertica-sql-go v1.1.1/go.mod h1:fGr44VWdEvL+f+Qt5LkKLOT7GoxaWdoUCnPBU9h6t04=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
11 changes: 11 additions & 0 deletions pkg/controllers/vdb/offlineupgrade_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@

// Functions to perform when the image changes. Order matters.
funcs := []func(context.Context) (ctrl.Result, error){
// Save restore point before start upgrade
o.saveRestorePoint,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@roypaulin For offline and read-only upgrade, we want the job "o.saveRestorePoint" before "startUpgrade", right? or other orders

// Initiate an upgrade by setting condition and event recording
o.startUpgrade,
o.logEventIfThisUpgradeWasNotChosen,
Expand Down Expand Up @@ -151,6 +153,15 @@
return ctrl.Result{}, o.Manager.logUpgradeSucceeded(sandbox)
}

func (o *OfflineUpgradeReconciler) saveRestorePoint(ctx context.Context) (ctrl.Result, error) {
actor := MakeSaveRestorePointReconciler(o.Rec, o.Vdb, o.Log, o.PFacts, o.Dispatcher, o.Rec.GetClient())

Check failure on line 157 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / unittests / ut

cannot use o.Rec (variable of type vdbconfig.ReconcilerInterface) as *VerticaDBReconciler value in argument to MakeSaveRestorePointReconciler: need type assertion

Check failure on line 157 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build-release-assets / release-artifacts

cannot use o.Rec (variable of type vdbconfig.ReconcilerInterface) as *VerticaDBReconciler value in argument to MakeSaveRestorePointReconciler: need type assertion

Check failure on line 157 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build-release-assets / release-artifacts

cannot use o.Rec (variable of type vdbconfig.ReconcilerInterface) as *VerticaDBReconciler value in argument to MakeSaveRestorePointReconciler: need type assertion

Check failure on line 157 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build / build-operator

cannot use o.Rec (variable of type vdbconfig.ReconcilerInterface) as *VerticaDBReconciler value in argument to MakeSaveRestorePointReconciler: need type assertion
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@roypaulin is this the proper way to call the other Reconciler and its method?
MakeSaveRestorePointReconciler takes a VerticaDBReconciler which does not exist here, should I also create a VerticaDBReconciler here and pass it down to this make method?

saveRestoreRec := actor.(*SaveRestorePoint)

hostIP, ok := pfacts.FindFirstUpPodIP(true, "")

Check failure on line 160 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / unittests / ut

ok declared and not used

Check failure on line 160 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / unittests / ut

undefined: pfacts

Check failure on line 160 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build-release-assets / release-artifacts

ok declared and not used

Check failure on line 160 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build-release-assets / release-artifacts

undefined: pfacts

Check failure on line 160 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build-release-assets / release-artifacts

ok declared and not used

Check failure on line 160 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build / build-operator

ok declared and not used

Check failure on line 160 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build / build-operator

undefined: pfacts
saveRestoreRec.runSaveRestorePointVclusterAPI(ctx, hostIP, archive, pf.sandbox)

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / unittests / ut

undefined: archive

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / unittests / ut

undefined: pf

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / unittests / ut

too many arguments in call to saveRestoreRec.runSaveRestorePointVclusterAPI

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build-release-assets / release-artifacts

undefined: archive

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build-release-assets / release-artifacts

undefined: pf

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build-release-assets / release-artifacts

too many arguments in call to saveRestoreRec.runSaveRestorePointVclusterAPI

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build / build-operator

undefined: archive

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build / build-operator

undefined: pf

Check failure on line 161 in pkg/controllers/vdb/offlineupgrade_reconciler.go

View workflow job for this annotation

GitHub Actions / build / build-operator

too many arguments in call to saveRestoreRec.runSaveRestorePointVclusterAPI
return o.Manager.startUpgrade(ctx, o.PFacts.GetSandboxName())
}

func (o *OfflineUpgradeReconciler) startUpgrade(ctx context.Context) (ctrl.Result, error) {
return o.Manager.startUpgrade(ctx, o.PFacts.GetSandboxName())
}
Expand Down
Loading
Loading