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

Add reconciler to shutdown a subcluster #777

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e3780ce
VCluster API Refresh (#741)
Mar 21, 2024
5fe8480
Merge branch 'main' into vnext
Mar 22, 2024
3cd7e32
VerticaReplicator Skeleton API and Controller (#740)
jizhuoyu Mar 22, 2024
7d60ec3
Add replicated upgradePolicy (#743)
Mar 23, 2024
ba19325
Merge branch 'main' into vnext
Mar 23, 2024
c857fa1
VCluster API Refresh
Apr 1, 2024
b880bb6
Assign subclusters to replica groups for replicated upgrade (#748)
Apr 1, 2024
2445c97
Add new sandbox controller (#749)
roypaulin Apr 2, 2024
9396ab1
Remove labels in `vrep` sample config (#753)
jizhuoyu Apr 2, 2024
7899c88
Add webhook rules for replicated upgrade (#755)
Apr 3, 2024
9a52d24
Merge branch 'main' into vnext
Apr 4, 2024
447ee00
Merge branch 'main' into vnext
Apr 5, 2024
cb1cc81
Collect sandbox name in podfacts (#762)
roypaulin Apr 5, 2024
770b760
Add new leg for 24.3.0 tests (#763)
Apr 5, 2024
03f626b
`vrep` reconciler enforces minimum version of source and target `vdb`…
jizhuoyu Apr 9, 2024
8149ce2
Replicated upgrade: create secondaries based on primaries (#765)
Apr 9, 2024
ffe6c59
Add webhook rules for sandboxes (#767)
cchen-vertica Apr 10, 2024
fd79c1b
Add restart reconciler to sandbox controller (#766)
roypaulin Apr 11, 2024
f75c502
Add stubs for replicated upgrade (#768)
Apr 12, 2024
5510318
Add a new webhook rule for sandboxes (#770)
cchen-vertica Apr 12, 2024
2934f95
Use VClusterOps API to get node details in podfacts (#769)
cchen-vertica Apr 15, 2024
7fcfd32
Redirect clients to replica group B during replicated upgrade (#771)
Apr 17, 2024
3773a48
Update upgrade reconciler to handle subclusters in sandbox (#772)
roypaulin Apr 19, 2024
91fce6b
Merge branch 'main' into vnext
Apr 19, 2024
baf6174
Add replication reconciler for VerticaReplicator (#773)
jizhuoyu Apr 22, 2024
a8e5184
Add stop-sc reconciler
roypaulin Apr 23, 2024
52ce42c
Merge remote-tracking branch 'origin/vnext' into roypaulin/stop-sc
roypaulin Apr 23, 2024
28edf0c
Fix unit tests
roypaulin Apr 23, 2024
037ea13
Add event when different upgrade policy is picked (#776)
Apr 24, 2024
43d0658
Add Sandbox Reconciler to VerticaDB Controller (#775)
cchen-vertica Apr 26, 2024
ed6d3ca
Add status messages for replicated upgrade (#778)
Apr 27, 2024
0ff6d31
Address comments
roypaulin Apr 29, 2024
0c78877
Change operator version to 2.2.0 (#784)
github-actions[bot] Apr 30, 2024
af4e5c3
Merge branch 'main' into vnext
Apr 30, 2024
46e9b1a
e2e tests for `vrep` (#779)
jizhuoyu Apr 30, 2024
c412f95
Decouple subcluster name from its statefulset name (#780)
May 1, 2024
c7e47ed
Give the vdb verification exactly once semantics for vrep (#782)
chinhtranvan May 1, 2024
2350358
Add offline upgrade reconciler to sandbox controller (#785)
roypaulin May 3, 2024
4e5ab99
Vcluster API Refresh (#792)
chinhtranvan May 3, 2024
ded5b41
Use static labels in pods (#791)
May 3, 2024
cb54f6e
fix tests (#794)
chinhtranvan May 4, 2024
f216467
Create sandbox config maps in sandbox reconciler (#790)
cchen-vertica May 6, 2024
410d11b
add test for `vrep` custom username / password and tls config (#786)
jizhuoyu May 7, 2024
aac39ab
Update sandbox label (#798)
chinhtranvan May 7, 2024
ce73ec8
Add sandbox option in vrep (#795)
chinhtranvan May 7, 2024
656356a
Merge branch 'main' into vnext
May 7, 2024
fbea432
Set VerticaDB name in ConfigMap (#802)
May 8, 2024
c600f8b
Add support for multiple subclusters in a sandbox (#799)
May 9, 2024
4153fb2
Use ForceRemoval option with revive (#804)
May 10, 2024
b7a1afb
Add status reconciler to sandbox controller (#793)
roypaulin May 13, 2024
40520b8
Add test step for `verify-vrep` to verify replication from empty db (…
jizhuoyu May 13, 2024
dcf0dd9
Vcluster-API-Refresh (#801)
chinhtranvan May 14, 2024
91522be
Call sandbox reconciler during replicated upgrade (#807)
May 14, 2024
c223904
Decouple sandbox image from vdb.spec image (#812)
roypaulin May 14, 2024
22ba363
Add unsandbox reconciler to vdb and sandbox controllers (#803)
cchen-vertica May 14, 2024
e8384e6
Use subcluster status to update podfacts (#814)
roypaulin May 15, 2024
79d9952
Fix for many subclusters sandboxed at the same time (#815)
May 17, 2024
8982c40
Applied new option --hosts-in-sandbox of vclusterOps start_db on the …
cchen-vertica May 17, 2024
6444c3f
Fixed polling timeout issue of start_db and start_node (#818)
cchen-vertica May 18, 2024
e7b91a8
Merge remote-tracking branch 'origin/vnext' into roypaulin/stop-sc
roypaulin May 18, 2024
e16c306
Address comments
roypaulin May 21, 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
9 changes: 9 additions & 0 deletions .github/actions/run-e2e-leg/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ inputs:
description: 'Whether BASE_VERTICA_IMG is required'
required: false
default: 'false'
vertica-license:
description: 'Contents of a vertica license to use with the tests'
required: false
default: ''
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -94,6 +98,11 @@ runs:
export OPERATOR_IMG=${{ inputs.operator-image }}
export VLOGGER_IMG=${{ inputs.vlogger-image }}

if [[ "${{ inputs.vertica-license }}" != "" ]]; then
export LICENSE_FILE=/tmp/vertica-license.dat
echo -n "${{ inputs.vertica-license }}" > $LICENSE_FILE
fi

# Set DEPLOY_WITH
export DEPLOY_WITH="${{ inputs.deploy-with }}";

Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ on:
- vcluster leg 6
- vcluster leg 7
- leg 8
- vcluster leg 9
- vcluster server upgrade
- vcluster udx
run_security_scan:
Expand Down Expand Up @@ -436,6 +437,29 @@ jobs:
communal-storage-type: azb
minimum-vertica-image: '24.2.0'

e2e-leg-9-vcluster:
if: ${{ ! github.event.pull_request.head.repo.fork && (inputs.e2e_test_suites == 'all' || inputs.e2e_test_suites == 'vcluster leg 9' || inputs.e2e_test_suites == '')}}
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
uses: ./.github/actions/run-e2e-leg
with:
leg-identifier: 'leg-9'
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
vlogger-image: ${{ needs.build.outputs.vlogger-image }}
operator-image: ${{ needs.build.outputs.operator-image }}
vertica-image: ${{ needs.build.outputs.minimal-vertica-image }}
vertica-deployment-method: vclusterops
communal-storage-type: s3
minimum-vertica-image: '24.3.0'
# Include the vertica license so we can test scaling past 3 nodes.
vertica-license: ${{ secrets.VERTICA_LICENSE }}
need-base-vertica-image: 'true'

e2e-server-upgrade-admintools:
if: ${{ inputs.e2e_test_suites == 'all' || inputs.e2e_test_suites == 'admintools server upgrade' || inputs.e2e_test_suites == '' }}
needs: [build]
Expand Down Expand Up @@ -536,4 +560,4 @@ jobs:
# We must pass the full image since the minimal image cannot run Java UDx's
vertica-image: ${{ needs.build.outputs.full-vertica-image }}
vertica-deployment-method: vclusterops
communal-storage-type: s3
communal-storage-type: s3
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,15 @@ CONCURRENCY_VERTICAAUTOSCALER?=1
CONCURRENCY_EVENTTRIGGER?=1
CONCURRENCY_VERTICARESTOREPOINTSQUERY?=1
CONCURRENCY_VERTICASCRUTINIZE?=1
CONCURRENCY_SANDBOXCONFIGMAP?=1
CONCURRENCY_VERTICAREPLICATOR?=1
export CONCURRENCY_VERTICADB \
CONCURRENCY_VERTICAAUTOSCALER \
CONCURRENCY_EVENTTRIGGER \
CONCURRENCY_VERTICARESTOREPOINTSQUERY \
CONCURRENCY_VERTICASCRUTINIZE
CONCURRENCY_VERTICASCRUTINIZE \
CONCURRENCY_SANDBOXCONFIGMAP \
CONCURRENCY_VERTICAREPLICATOR

# Clear this variable if you don't want to wait for the helm deployment to
# finish before returning control. This exists to allow tests to attempt deploy
Expand Down
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,12 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: vertica.com
kind: VerticaReplicator
path: github.com/vertica/vertica-kubernetes/api/v1beta1
version: v1beta1
version: "3"
123 changes: 121 additions & 2 deletions api/v1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (

RFC1123DNSSubdomainNameRegex = `^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
RFC1035DNSLabelNameRegex = `^[a-z]([a-z0-9\-]{0,61}[a-z0-9])?$`

MainCluster = ""
)

// ExtractNamespacedName gets the name and returns it as a NamespacedName
Expand All @@ -57,6 +59,20 @@ func MakeVDBName() types.NamespacedName {
return types.NamespacedName{Name: "vertica-sample", Namespace: "default"}
}

// GenerateOwnerReference creates an owner reference for the current VerticaDB
func (v *VerticaDB) GenerateOwnerReference() metav1.OwnerReference {
isController := true
blockOwnerDeletion := false
return metav1.OwnerReference{
APIVersion: GroupVersion.String(),
Kind: VerticaDBKind,
Name: v.Name,
UID: v.GetUID(),
Controller: &isController,
BlockOwnerDeletion: &blockOwnerDeletion,
}
}

// FindTransientSubcluster will return a pointer to the transient subcluster if one exists
func (v *VerticaDB) FindTransientSubcluster() *Subcluster {
for i := range v.Spec.Subclusters {
Expand Down Expand Up @@ -125,11 +141,19 @@ func MakeVDBForHTTP(httpServerTLSSecretName string) *VerticaDB {
// vclusterops. This is intended for test purposes.
func MakeVDBForVclusterOps() *VerticaDB {
vdb := MakeVDB()
vdb.Annotations[vmeta.VersionAnnotation] = ScrutinizeDBPasswdInSecretMinVersion
vdb.Annotations[vmeta.VersionAnnotation] = VcluseropsAsDefaultDeploymentMethodMinVersion
vdb.Annotations[vmeta.VClusterOpsAnnotation] = vmeta.VClusterOpsAnnotationTrue
return vdb
}

// MakeVDBForScrutinize is a helper that constructs a VerticaDB struct for
// scrutinize. This is intended for test purposes.
func MakeVDBForScrutinize() *VerticaDB {
vdb := MakeVDBForVclusterOps()
vdb.Annotations[vmeta.VersionAnnotation] = ScrutinizeDBPasswdInSecretMinVersion
return vdb
}

// GenSubclusterMap will organize all of the subclusters into a map for quicker lookup
func (v *VerticaDB) GenSubclusterMap() map[string]*Subcluster {
scMap := map[string]*Subcluster{}
Expand Down Expand Up @@ -368,7 +392,7 @@ func (v *VerticaDB) IsKnownDepotVolumeType() bool {
return false
}

// getFirstPrimarySubcluster returns the first primary subcluster defined in the vdb
// GetFirstPrimarySubcluster returns the first primary subcluster defined in the vdb
func (v *VerticaDB) GetFirstPrimarySubcluster() *Subcluster {
for i := range v.Spec.Subclusters {
sc := &v.Spec.Subclusters[i]
Expand All @@ -380,6 +404,68 @@ func (v *VerticaDB) GetFirstPrimarySubcluster() *Subcluster {
return nil
}

// HasSecondarySubclusters returns true if at least 1 secondary subcluster
// exists in the database.
func (v *VerticaDB) HasSecondarySubclusters() bool {
for i := range v.Spec.Subclusters {
if v.Spec.Subclusters[i].IsSecondary() {
return true
}
}
return false
}

// IsAutoUpgradePolicy returns true
func (v *VerticaDB) IsAutoUpgradePolicy() bool {
return v.Spec.UpgradePolicy == "" || v.Spec.UpgradePolicy == AutoUpgrade
}

// GetUpgradePolicyToUse returns the upgrade policy that the db should use.
// It will take into account the settings in the vdb as well as what is
// supported in the server. This will never return the auto upgrade policy. If
// you need the current value of that field, just refer to it by referencing
// Spec.UpgradePolicy.
func (v *VerticaDB) GetUpgradePolicyToUse() UpgradePolicyType {
if v.Spec.UpgradePolicy == OfflineUpgrade {
return OfflineUpgrade
}

if v.IsAutoUpgradePolicy() && v.IsKSafety0() {
return OfflineUpgrade
}

// If we cannot get the version, always default to offline. We cannot make
// any assumptions about what upgrade policy the server supports.
vinf, ok := v.MakeVersionInfo()
if !ok {
return OfflineUpgrade
}

// The Replicated option can only be chosen explicitly. Although eventually,
// the Auto option will automatically select this method, we first need to
// complete the implementation of this new policy.
if v.Spec.UpgradePolicy == ReplicatedUpgrade {
// Replicated upgrade requires that we scale out the cluster. See if
// there is evidence that we have already scaled past 3 nodes (CE
// license limit), or we have a license defined.
const ceLicenseLimit = 3
if vinf.IsEqualOrNewer(ReplicatedUpgradeVersion) &&
!v.IsKSafety0() &&
(v.getNumberOfNodes() > ceLicenseLimit || v.Spec.LicenseSecret != "") {
return ReplicatedUpgrade
} else if vinf.IsEqualOrNewer(OnlineUpgradeVersion) {
return OnlineUpgrade
}
}

if (v.Spec.UpgradePolicy == OnlineUpgrade || v.IsAutoUpgradePolicy()) &&
vinf.IsEqualOrNewer(OnlineUpgradeVersion) {
return OnlineUpgrade
}

return OfflineUpgrade
}

// GetIgnoreClusterLease will check if the cluster lease should be ignored.
func (v *VerticaDB) GetIgnoreClusterLease() bool {
return vmeta.IgnoreClusterLease(v.Annotations)
Expand Down Expand Up @@ -662,3 +748,36 @@ func (v *VerticaDB) IsHTTPSTLSConfGenerationEnabled() (bool, error) {
}
return !inf.IsEqualOrNewer(AutoGenerateHTTPSCertsForNewDatabasesMinVersion), nil
}

// GetSubclusterSandboxName returns the sandbox the given subcluster belongs to,
// or an empty string if it does not belong to any
func (v *VerticaDB) GetSubclusterSandboxName(scName string) string {
for i := range v.Spec.Sandboxes {
for j := range v.Spec.Sandboxes[i].Subclusters {
if scName == v.Spec.Sandboxes[i].Subclusters[j].Name {
return v.Spec.Sandboxes[i].Name
}
}
}
return MainCluster
}

// getNumberOfNodes returns the number of nodes defined in the database, as per the CR.
func (v *VerticaDB) getNumberOfNodes() int {
count := 0
for i := range v.Spec.Subclusters {
count += int(v.Spec.Subclusters[i].Size)
}
return count
}

// GetSandbox returns the sandbox given by name. A nil pointer is returned if
// not found.
func (v *VerticaDB) GetSandbox(sbName string) *Sandbox {
for i := range v.Spec.Sandboxes {
if v.Spec.Sandboxes[i].Name == sbName {
return &v.Spec.Sandboxes[i]
}
}
return nil
}
10 changes: 10 additions & 0 deletions api/v1/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (
NodesHaveReadOnlyStateVersion = "v11.0.2"
// The minimum version that allows for online upgrade.
OnlineUpgradeVersion = "v11.1.0"
// The minimum version that allows for replicated upgrade.
ReplicatedUpgradeVersion = "v24.3.0"
// The version that added the --force option to reip to handle up nodes
ReIPAllowedWithUpNodesVersion = "v11.1.0"
// The version of the server that doesn't support cgroup v2
Expand All @@ -43,6 +45,8 @@ const (
// The minimum version that we can use the option with create DB to skip the
// package install.
CreateDBSkipPackageInstallVersion = "v12.0.1"
// The version that added sandbox state
NodesHaveSandboxStateVersion = "v12.0.4"
// Starting in v23.4.0, we added some new config parameters for settings
// that were typically done post create using SQL -- setting the default
// subcluster name and preferred k-safety.
Expand All @@ -62,6 +66,8 @@ const (
InDatabaseLogRotateMinVersion = "v24.1.0"
// Starting in v24.2.0, restoring from a restore point in archive is supported.
RestoreSupportedMinVersion = "v24.2.0"
// Starting in v24.3.0, database replication via vclusterops is supported.
ReplicationViaVclusteropsSupportedMinVersion = "v24.3.0"
// The NMA TLS secret can be stored in an external secret store. These are
// the minimum versions of the NMA that we support them.
NMATLSSecretInGSMMinVersion = "v24.1.0"
Expand All @@ -71,6 +77,10 @@ const (
// Starting in v24.2.0, vcluster scrutinize command can read the
// database password from secret(k8s, aws, gsm)
ScrutinizeDBPasswdInSecretMinVersion = "v24.2.0"
// Starting in v24.3.0, sandboxing a subcluster with the operator is supported
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"
)

// GetVerticaVersionStr returns the vertica version, in string form, that is stored
Expand Down
Loading
Loading