Skip to content

Commit d6b1c0a

Browse files
refactor: Remove Pre 5 XDR related code [KO-458] (#416)
* refactor: Remove Pre 5 XDR related code [KO-458] * Update management-lib SHA
1 parent cbe679c commit d6b1c0a

File tree

10 files changed

+23
-162
lines changed

10 files changed

+23
-162
lines changed

api/v1/utils.go

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ const (
5656
ConfKeyPort = "port"
5757

5858
// XDR keys.
59-
confKeyXdr = "xdr"
60-
confKeyXdrDlogPath = "xdr-digestlog-path"
59+
ConfKeyXdr = "xdr"
6160

6261
// Security keys.
6362
ConfKeySecurity = "security"
@@ -333,7 +332,7 @@ func IsAerospikeNamespacePresent(
333332
// IsXdrEnabled indicates if XDR is enabled in aerospikeConfig.
334333
func IsXdrEnabled(aerospikeConfigSpec AerospikeConfigSpec) bool {
335334
aerospikeConfig := aerospikeConfigSpec.Value
336-
xdrConf := aerospikeConfig[confKeyXdr]
335+
xdrConf := aerospikeConfig[ConfKeyXdr]
337336

338337
return xdrConf != nil
339338
}
@@ -367,50 +366,6 @@ func ReadTLSAuthenticateClient(serviceConf map[string]interface{}) (
367366
return nil, fmt.Errorf("invalid configuration")
368367
}
369368

370-
// GetDigestLogFile returns the xdr digest file path if configured.
371-
func GetDigestLogFile(aerospikeConfigSpec AerospikeConfigSpec) (
372-
*string, error,
373-
) {
374-
aerospikeConfig := aerospikeConfigSpec.Value
375-
376-
if xdrConfTmp, ok := aerospikeConfig[confKeyXdr]; ok {
377-
xdrConf, ok := xdrConfTmp.(map[string]interface{})
378-
if !ok {
379-
return nil, fmt.Errorf(
380-
"aerospikeConfig.xdr not a valid map %v",
381-
aerospikeConfig[confKeyXdr],
382-
)
383-
}
384-
385-
dgLog, ok := xdrConf[confKeyXdrDlogPath]
386-
if !ok {
387-
return nil, fmt.Errorf(
388-
"%s is missing in aerospikeConfig.xdr %v", confKeyXdrDlogPath,
389-
xdrConf,
390-
)
391-
}
392-
393-
if _, ok := dgLog.(string); !ok {
394-
return nil, fmt.Errorf(
395-
"%s is not a valid string in aerospikeConfig.xdr %v",
396-
confKeyXdrDlogPath, xdrConf,
397-
)
398-
}
399-
400-
// "/opt/aerospike/xdr/digestlog 100G"
401-
if len(strings.Fields(dgLog.(string))) != 2 {
402-
return nil, fmt.Errorf(
403-
"%s is not in valid format (/opt/aerospike/xdr/digestlog 100G) in aerospikeConfig.xdr %v",
404-
confKeyXdrDlogPath, xdrConf,
405-
)
406-
}
407-
408-
return &strings.Fields(dgLog.(string))[0], nil
409-
}
410-
411-
return nil, fmt.Errorf("xdr not configured")
412-
}
413-
414369
func GetServiceTLSNameAndPort(aeroConf *AerospikeConfigSpec) (tlsName string, port *int32) {
415370
return GetTLSNameAndPort(aeroConf, ConfKeyNetworkService)
416371
}

config/samples/xdr_src_cluster_cr.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ spec:
2929
storageClass: ssd
3030
volumeMode: Filesystem
3131
size: 3Gi
32-
- name: xdr
33-
aerospike:
34-
path: /opt/aerospike/xdr
35-
source:
36-
persistentVolume:
37-
storageClass: ssd
38-
volumeMode: Filesystem
39-
size: 3Gi
4032
- name: aerospike-config-secret
4133
source:
4234
secret:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.11
55
require (
66
github.com/aerospike/aerospike-backup-service/v3 v3.2.0
77
github.com/aerospike/aerospike-client-go/v8 v8.2.2
8-
github.com/aerospike/aerospike-management-lib v1.8.1-0.20250829065008-0363517825bc
8+
github.com/aerospike/aerospike-management-lib v1.8.1-0.20251029081729-d5f8b09e1080
99
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
1010
github.com/deckarep/golang-set/v2 v2.8.0
1111
github.com/evanphx/json-patch v4.12.0+incompatible

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/aerospike/aerospike-backup-service/v3 v3.2.0 h1:vqvT7OE1didb/R4vOTNWI
66
github.com/aerospike/aerospike-backup-service/v3 v3.2.0/go.mod h1:aSD1pSRjyMYQ1UW2Kkg/vinn+ngeobKzDIVj+UZIi2c=
77
github.com/aerospike/aerospike-client-go/v8 v8.2.2 h1:NV1GxB+ATUb1cQtwaIS731A/6EkwuAX4/heh8CpvQOI=
88
github.com/aerospike/aerospike-client-go/v8 v8.2.2/go.mod h1:H6CzKDoHxBj1yY/oQPci1bUIbEx2ATQtJ2GtZ+N64Wg=
9-
github.com/aerospike/aerospike-management-lib v1.8.1-0.20250829065008-0363517825bc h1:/vlU9v4xNL/e0Lpa+OXixHLqZQedvsiK385H7rMWOlk=
10-
github.com/aerospike/aerospike-management-lib v1.8.1-0.20250829065008-0363517825bc/go.mod h1:RNKlkSnppiaBaLEdAiCeBv68M+odPR5JR+ziO0NfaHQ=
9+
github.com/aerospike/aerospike-management-lib v1.8.1-0.20251029081729-d5f8b09e1080 h1:9KqMRrlFJ3hx1BuKqhWWedr3ZMYWxaEX9G1Dq1JxZhE=
10+
github.com/aerospike/aerospike-management-lib v1.8.1-0.20251029081729-d5f8b09e1080/go.mod h1:RNKlkSnppiaBaLEdAiCeBv68M+odPR5JR+ziO0NfaHQ=
1111
github.com/aerospike/backup-go v0.5.1 h1:8ryLV0nOoo3Zn7LRV1kQABFnYgg1V0r9ZJJOL22FBs0=
1212
github.com/aerospike/backup-go v0.5.1/go.mod h1:+RJdOaVCG6jQlhoNIJrzQgZnJ/HEBPfAiPGdv3YYzyg=
1313
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=

internal/controller/cluster/scripts/initialize.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ done
4040
{{- if .WorkDir }}
4141
# Create required directories.
4242
DEFAULT_WORK_DIR="/workdir/filesystem-volumes{{.WorkDir}}"
43-
REQUIRED_DIRS=("smd" "usr/udf/lua" "xdr")
43+
REQUIRED_DIRS=("smd" "usr/udf/lua")
4444

4545
for d in ${REQUIRED_DIRS[*]}; do
4646
TO_CREATE="$DEFAULT_WORK_DIR/$d"

internal/webhook/v1/aerospikecluster_mutating_webhook.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ func updateRacksAerospikeConfigFromGlobal(asLog logr.Logger, cluster *asdbv1.Aer
296296

297297
func setDefaultAerospikeConfigs(asLog logr.Logger,
298298
configSpec asdbv1.AerospikeConfigSpec, rackID *int, cluster *asdbv1.AerospikeCluster) error {
299-
config := configSpec.Value
300-
301299
// namespace conf
302300
if err := setDefaultNsConf(asLog, configSpec, cluster.Spec.RackConfig.Namespaces, rackID); err != nil {
303301
return err
@@ -320,13 +318,6 @@ func setDefaultAerospikeConfigs(asLog logr.Logger,
320318
return err
321319
}
322320

323-
// xdr conf
324-
if _, ok := config["xdr"]; ok {
325-
if err := setDefaultXDRConf(asLog, configSpec); err != nil {
326-
return err
327-
}
328-
}
329-
330321
// escape LDAP configuration
331322
return escapeLDAPConfiguration(configSpec)
332323
}
@@ -713,13 +704,6 @@ func setDefaultLoggingConf(
713704
return nil
714705
}
715706

716-
func setDefaultXDRConf(
717-
_ logr.Logger, _ asdbv1.AerospikeConfigSpec,
718-
) error {
719-
// Nothing to update for now
720-
return nil
721-
}
722-
723707
func setDefaultsInConfigMap(
724708
_ logr.Logger, baseConfigs, defaultConfigs map[string]interface{},
725709
) error {

test/cluster/cluster_test.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,26 +2271,6 @@ func negativeDeployClusterValidationTest(
22712271
Expect(DeployCluster(k8sClient, ctx, aeroCluster)).Should(HaveOccurred())
22722272
},
22732273
)
2274-
2275-
It(
2276-
"InvalidxdrConfig: should fail for invalid xdr config. mountPath for digestlog not present in storage",
2277-
func() {
2278-
aeroCluster := createDummyAerospikeCluster(
2279-
clusterNamespacedName, 1,
2280-
)
2281-
namespaceConfig :=
2282-
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyNamespace].([]interface{})[0].(map[string]interface{})
2283-
2284-
if _, ok := namespaceConfig["storage-engine"].(map[string]interface{})["devices"]; ok {
2285-
aeroCluster.Spec.Storage = asdbv1.AerospikeStorageSpec{}
2286-
aeroCluster.Spec.AerospikeConfig.Value["xdr"] = map[string]interface{}{
2287-
"enable-xdr": false,
2288-
"xdr-digestlog-path": "/opt/aerospike/xdr/digestlog 100G",
2289-
}
2290-
Expect(DeployCluster(k8sClient, ctx, aeroCluster)).Should(HaveOccurred())
2291-
}
2292-
},
2293-
)
22942274
},
22952275
)
22962276
},
@@ -2674,30 +2654,6 @@ func negativeUpdateClusterValidationTest(
26742654
Expect(err).Should(HaveOccurred())
26752655
},
26762656
)
2677-
2678-
It(
2679-
"InvalidxdrConfig: should fail for invalid xdr config. mountPath for digestlog not present in fileStorage",
2680-
func() {
2681-
aeroCluster, err := getCluster(
2682-
k8sClient, ctx,
2683-
clusterNamespacedName,
2684-
)
2685-
Expect(err).ToNot(HaveOccurred())
2686-
2687-
namespaceConfig :=
2688-
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyNamespace].([]interface{})[0].(map[string]interface{})
2689-
if _, ok := namespaceConfig["storage-engine"].(map[string]interface{})["devices"]; ok {
2690-
aeroCluster.Spec.AerospikeConfig.Value["xdr"] = map[string]interface{}{
2691-
"enable-xdr": false,
2692-
"xdr-digestlog-path": "randomPath 100G",
2693-
}
2694-
err = k8sClient.Update(
2695-
ctx, aeroCluster,
2696-
)
2697-
Expect(err).Should(HaveOccurred())
2698-
}
2699-
},
2700-
)
27012657
},
27022658
)
27032659
},

test/cluster/dynamic_config_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var _ = Describe(
7777
)
7878
aeroCluster.Spec.AerospikeConfig.Value["namespaces"] = append(
7979
aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{}), getNonSCInMemoryNamespaceConfig("mem"))
80-
aeroCluster.Spec.AerospikeConfig.Value["xdr"] = map[string]interface{}{
80+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr] = map[string]interface{}{
8181
"dcs": []map[string]interface{}{
8282
{
8383
"name": "dc1",
@@ -135,8 +135,8 @@ var _ = Describe(
135135
},
136136
}
137137

138-
aeroCluster.Spec.AerospikeConfig.Value["xdr"].(map[string]interface{})["dcs"] = append(
139-
aeroCluster.Spec.AerospikeConfig.Value["xdr"].(map[string]interface{})["dcs"].([]interface{}), dc)
138+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr].(map[string]interface{})["dcs"] = append(
139+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr].(map[string]interface{})["dcs"].([]interface{}), dc)
140140

141141
err = updateCluster(k8sClient, ctx, aeroCluster)
142142
Expect(err).ToNot(HaveOccurred())
@@ -165,7 +165,7 @@ var _ = Describe(
165165

166166
// Fetch and verify xdr section config
167167
conf, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
168-
"xdr", aeroCluster.Name+"-0-0")
168+
asdbv1.ConfKeyXdr, aeroCluster.Name+"-0-0")
169169
Expect(err).ToNot(HaveOccurred())
170170

171171
Expect(conf["dcs"]).To(HaveLen(2))
@@ -182,8 +182,8 @@ var _ = Describe(
182182
delete(aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyService].(map[string]interface{}), "proto-fd-max")
183183
delete(aeroCluster.Spec.AerospikeConfig.Value["security"].(map[string]interface{}), "log")
184184

185-
aeroCluster.Spec.AerospikeConfig.Value["xdr"].(map[string]interface{})["dcs"] =
186-
aeroCluster.Spec.AerospikeConfig.Value["xdr"].(map[string]interface{})["dcs"].([]interface{})[:1]
185+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr].(map[string]interface{})["dcs"] =
186+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr].(map[string]interface{})["dcs"].([]interface{})[:1]
187187

188188
err = updateCluster(k8sClient, ctx, aeroCluster)
189189
Expect(err).ToNot(HaveOccurred())
@@ -209,7 +209,7 @@ var _ = Describe(
209209

210210
// Fetch and verify xdr section config
211211
conf, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
212-
"xdr", aeroCluster.Name+"-0-0")
212+
asdbv1.ConfKeyXdr, aeroCluster.Name+"-0-0")
213213
Expect(err).ToNot(HaveOccurred())
214214

215215
Expect(conf["dcs"]).To(HaveLen(1))
@@ -334,7 +334,7 @@ var _ = Describe(
334334
aeroCluster := createDummyAerospikeCluster(
335335
clusterNamespacedName, 2,
336336
)
337-
aeroCluster.Spec.AerospikeConfig.Value["xdr"] = map[string]interface{}{
337+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr] = map[string]interface{}{
338338
"dcs": []map[string]interface{}{
339339
{
340340
"name": "dc1",
@@ -423,8 +423,8 @@ var _ = Describe(
423423
},
424424
}
425425

426-
aeroCluster.Spec.AerospikeConfig.Value["xdr"].(map[string]interface{})["dcs"] = append(
427-
aeroCluster.Spec.AerospikeConfig.Value["xdr"].(map[string]interface{})["dcs"].([]interface{}), dc)
426+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr].(map[string]interface{})["dcs"] = append(
427+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr].(map[string]interface{})["dcs"].([]interface{}), dc)
428428

429429
err = updateClusterWithTO(k8sClient, ctx, aeroCluster, time.Minute*1)
430430
Expect(err).To(HaveOccurred())
@@ -476,7 +476,7 @@ var _ = Describe(
476476
},
477477
},
478478
)
479-
aeroCluster.Spec.AerospikeConfig.Value["xdr"] = map[string]interface{}{
479+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr] = map[string]interface{}{
480480
"dcs": []map[string]interface{}{
481481
{
482482
"name": "dc1",
@@ -973,7 +973,7 @@ func validateXDRContextDynamically(clusterNamespacedName types.NamespacedName,
973973
dcFields := make(asconfig.Conf)
974974

975975
for confKey, val := range *flatServer {
976-
if asconfig.ContextKey(confKey) != "xdr" {
976+
if asconfig.ContextKey(confKey) != asdbv1.ConfKeyXdr {
977977
continue
978978
}
979979

@@ -1030,7 +1030,7 @@ func validateXDRNSFieldsDynamically(ctx goctx.Context, flatServer, flatSpec *asc
10301030
newConf := asconfig.New(logger, &newSpec)
10311031
newMap := *newConf.ToMap()
10321032

1033-
aeroCluster.Spec.AerospikeConfig.Value["xdr"] = lib.DeepCopy(newMap["xdr"])
1033+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr] = lib.DeepCopy(newMap[asdbv1.ConfKeyXdr])
10341034

10351035
return updateCluster(k8sClient, ctx, aeroCluster)
10361036
}
@@ -1057,11 +1057,11 @@ func validateXDRDCFieldsDynamically(ctx goctx.Context, flatServer, flatSpec *asc
10571057
newConf := asconfig.New(logger, &newSpec)
10581058
newMap := *newConf.ToMap()
10591059

1060-
aeroCluster.Spec.AerospikeConfig.Value["xdr"] = lib.DeepCopy(newMap["xdr"])
1061-
dcs := aeroCluster.Spec.AerospikeConfig.Value["xdr"].(lib.Stats)["dcs"].([]lib.Stats)
1060+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr] = lib.DeepCopy(newMap[asdbv1.ConfKeyXdr])
1061+
dcs := aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr].(lib.Stats)["dcs"].([]lib.Stats)
10621062
delete(dcs[0], "namespaces")
10631063
delete(dcs[0], "node-address-ports")
1064-
aeroCluster.Spec.AerospikeConfig.Value["xdr"].(lib.Stats)["dcs"] = dcs
1064+
aeroCluster.Spec.AerospikeConfig.Value[asdbv1.ConfKeyXdr].(lib.Stats)["dcs"] = dcs
10651065

10661066
return updateCluster(k8sClient, ctx, aeroCluster)
10671067
}

test/cluster/rack_management_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -589,32 +589,6 @@ var _ = Describe(
589589
)
590590
},
591591
)
592-
593-
It(
594-
"should fail for invalid xdr config. mountPath for digestlog not present in fileStorage",
595-
func() {
596-
aeroCluster := createDummyRackAwareAerospikeCluster(
597-
clusterNamespacedName, 2,
598-
)
599-
namespaceConfig :=
600-
aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0].(map[string]interface{})
601-
if _, ok :=
602-
namespaceConfig["storage-engine"].(map[string]interface{})["devices"]; ok {
603-
aeroCluster.Spec.Storage = asdbv1.AerospikeStorageSpec{}
604-
aeroConfig := asdbv1.AerospikeConfigSpec{
605-
Value: map[string]interface{}{
606-
"xdr": map[string]interface{}{
607-
"enable-xdr": false,
608-
"xdr-digestlog-path": "/opt/aerospike/xdr/digestlog 100G",
609-
},
610-
},
611-
}
612-
aeroCluster.Spec.RackConfig.Racks[0].InputAerospikeConfig = &aeroConfig
613-
Expect(DeployCluster(k8sClient, ctx, aeroCluster)).Should(HaveOccurred())
614-
}
615-
},
616-
)
617-
// Replication-factor can not be updated
618592
},
619593
)
620594

test/cluster/sample_files_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func deployClusterUsingFile(ctx context.Context, filePath string) (*asdbv1.Aeros
182182
return aeroCluster, err
183183
}
184184

185-
if !strings.Contains(filePath, "xdr") {
185+
if !strings.Contains(filePath, asdbv1.ConfKeyXdr) {
186186
baseName := strings.TrimSuffix(filepath.Base(filePath), "_cr.yaml")
187187
aeroCluster.Name = strings.ReplaceAll(baseName, "_", "-")
188188
}

0 commit comments

Comments
 (0)