Skip to content

Commit 2ad7a4e

Browse files
committed
Add SystemReplication Spec
Signed-off-by: ZobayerAbedin <[email protected]>
1 parent 0d22a8e commit 2ad7a4e

File tree

11 files changed

+283
-87
lines changed

11 files changed

+283
-87
lines changed

apis/catalog/v1alpha1/hanadb_version_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"kmodules.xyz/client-go/apiextensions"
2727
)
2828

29-
func (_ HanaDBVersion) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
29+
func (HanaDBVersion) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
3030
return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralHanaDBVersion))
3131
}
3232

apis/kubedb/constants.go

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,79 +2285,3 @@ const (
22852285
// TenantDatabaseName is the name of the KubeDB managed tenant database
22862286
KubeDBTenantDatabaseName = "KUBEDB_HEALTH_CHECK"
22872287
)
2288-
2289-
// =========================== Qdrant Constants ============================
2290-
const (
2291-
QdrantContainerName = "qdrant"
2292-
2293-
QdrantHTTPPortName = "http"
2294-
QdrantHTTPPort = 6333
2295-
QdrantGRPCPortName = "grpc"
2296-
QdrantGRPCPort = 6334
2297-
QdrantP2PPortName = "p2p"
2298-
QdrantP2PPort = 6335
2299-
2300-
QdrantDataVolName = "data"
2301-
QdrantDataDir = "/qdrant/storage"
2302-
QdrantConfigVolName = "qdrant-config"
2303-
QdrantConfigDir = "/qdrant/config"
2304-
2305-
QdrantConfigFileName = "config.yaml"
2306-
2307-
QdrantAPIKey = "api-key"
2308-
QdrantReadOnlyAPIKey = "read-only-api-key"
2309-
)
2310-
2311-
// =========================== HanaDB Constants ============================
2312-
const (
2313-
HanaDBVolumeScripts = "hanadb-scripts"
2314-
2315-
HanaDBVolumeMountScripts = "/scripts"
2316-
2317-
// Container names
2318-
HanaDBContainerName = "hanadb"
2319-
HanaDBCoordinatorContainerName = "hanadb-coordinator"
2320-
2321-
// Mount paths
2322-
HanaDBDataDir = "/hana/mounts"
2323-
HanaDBSecretMountPath = "/etc/hana-secrets"
2324-
2325-
// Volume names
2326-
HanaDBDataVolume = "data"
2327-
HanaDBVolumePasswordSecret = "password-secret"
2328-
2329-
// User and Group IDs
2330-
HanaDBUserID = 12000 // hxeadm UID
2331-
HanaDBGroupID = 79 // hxeadm GID
2332-
2333-
// Health check schema and table
2334-
HanaDBHealthCheckSchemaName = "KUBEDB_SYSTEM"
2335-
HanaDBHealthCheckTableName = "KUBEDB_WRITE_CHECK"
2336-
2337-
// Auth secret
2338-
HanaDBSystemUser = "SYSTEM"
2339-
HanaDBPasswordFileKey = "password.json"
2340-
HanaDBMasterPasswordKey = "master_password"
2341-
2342-
// Main SYSTEMDB SQL connection port, Used by health checks and administrative operations
2343-
HanaDBSystemDBSQLPortName = "systemdb-sql"
2344-
HanaDBSystemDBSQLPort = 39017
2345-
2346-
// Nameserver port for internal communication and system replication
2347-
HanaDBNameServerPortName = "nameserver"
2348-
HanaDBNameServerPort = 39001
2349-
2350-
// SYSTEMDB SQL mapping port - used internally for routing
2351-
HanaDBSystemDBMappingPortName = "systemdb-map"
2352-
HanaDBSystemDBMappingPort = 39013
2353-
2354-
HanaDBPrimaryServicePortName = "primary"
2355-
2356-
HanaDBCoordinatorPort = 2380
2357-
HanaDBCoordinatorClientPort = 2379
2358-
HanaDBCoordinatorPortName = "coordinator"
2359-
HanaDBCoordinatorClientPortName = "coordinator-client"
2360-
2361-
// TenantDatabaseName is the name of the KubeDB managed tenant database
2362-
KubeDBTenantDatabaseName = "KUBEDB_HEALTH_CHECK"
2363-
)

apis/kubedb/v1alpha2/hanadb_helpers.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ import (
3636
coreutil "kmodules.xyz/client-go/core/v1"
3737
metautil "kmodules.xyz/client-go/meta"
3838
"kmodules.xyz/client-go/policy/secomp"
39-
_ "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1"
4039
appcat "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1"
4140
mona "kmodules.xyz/monitoring-agent-api/api/v1"
4241
ofst "kmodules.xyz/offshoot-api/api/v2"
4342
pslister "kubeops.dev/petset/client/listers/apps/v1"
4443
"sigs.k8s.io/controller-runtime/pkg/client"
45-
_ "sigs.k8s.io/controller-runtime/pkg/client"
4644
)
4745

48-
func (_ HanaDB) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
46+
func (HanaDB) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
4947
return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralHanaDB))
5048
}
5149

@@ -274,6 +272,16 @@ func (h *HanaDB) SetDefaults(kc client.Client) {
274272
h.Spec.Replicas = pointer.Int32P(1)
275273
}
276274
}
275+
if h.Spec.Topology != nil && h.Spec.Topology.Mode != nil &&
276+
*h.Spec.Topology.Mode == HanaDBModeSystemReplication &&
277+
h.Spec.Topology.SystemReplication != nil {
278+
if h.Spec.Topology.SystemReplication.ReplicationMode == "" {
279+
h.Spec.Topology.SystemReplication.ReplicationMode = ReplicationModeSync
280+
}
281+
if h.Spec.Topology.SystemReplication.OperationMode == "" {
282+
h.Spec.Topology.SystemReplication.OperationMode = OperationModeLogReplay
283+
}
284+
}
277285

278286
h.setDefaultContainerSecurityContext(&hanadbVersion, h.Spec.PodTemplate)
279287

apis/kubedb/v1alpha2/hanadb_types.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,23 @@ type HanaDBTopology struct {
134134
// Mode specifies the deployment mode.
135135
// +optional
136136
Mode *HanaDBMode `json:"mode,omitempty"`
137+
138+
// SystemReplication defines configuration for SAP HANA system replication.
139+
// +optional
140+
SystemReplication *HanaDBSystemReplicationSpec `json:"systemReplication,omitempty"`
141+
}
142+
143+
// HanaDBSystemReplicationSpec defines system replication configuration.
144+
type HanaDBSystemReplicationSpec struct {
145+
// ReplicationMode controls when transactions are committed relative to log shipping.
146+
// +optional
147+
// +kubebuilder:default=sync
148+
ReplicationMode ReplicationMode `json:"replicationMode,omitempty"`
149+
150+
// OperationMode controls the log shipping/replay strategy on the secondary.
151+
// +optional
152+
// +kubebuilder:default=logreplay
153+
OperationMode OperationMode `json:"operationMode,omitempty"`
137154
}
138155

139156
// HanaDBStatus defines the observed state of HanaDB.

apis/kubedb/v1alpha2/openapi_generated.go

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/kubedb/v1alpha2/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/ops/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/informers/externalversions/factory.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/informers/externalversions/generic.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)