Skip to content

CLOUDP-297918: Move to New Atlas SDK #2304

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

Merged
merged 39 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5dc4ff8
mass update sdk
roothorp Apr 17, 2025
8f189eb
update cluster var names
roothorp Apr 17, 2025
7c8f3a2
more var name updates
roothorp Apr 25, 2025
78089ef
update other sdk versions
roothorp Apr 28, 2025
ce0e002
cleanup delete calls
roothorp Apr 28, 2025
15a90a8
fix alert config changes
roothorp Apr 28, 2025
99e48cf
fix search index
roothorp Apr 28, 2025
7780c93
fix teams
roothorp Apr 28, 2025
0376cfd
fix network container
roothorp Apr 28, 2025
5d724e1
fix datafederation
roothorp Apr 28, 2025
e72725a
update direct sdk client references
roothorp Apr 28, 2025
7dafe70
fix stream
roothorp Apr 28, 2025
4b550c3
fix cloud provider integrations
roothorp Apr 28, 2025
a215a81
fix private endpoint
roothorp Apr 28, 2025
590d81a
fix x509
roothorp Apr 28, 2025
e07cea9
fix e2e helper
roothorp Apr 28, 2025
405372f
fix network peering
roothorp Apr 28, 2025
899c5ca
fix API error
roothorp Apr 28, 2025
0c240a0
clean up e2e tests
roothorp Apr 28, 2025
83e8059
Add warnings for removed process args
roothorp May 21, 2025
47fb638
duplicate replication specs per num shards
roothorp Jun 5, 2025
0136559
cleanup missed delete call
roothorp Jun 12, 2025
40b2ac2
handle new diskSizeGB location
roothorp Jun 12, 2025
dac0d9c
fix tests
roothorp Jun 12, 2025
a920452
remove old sdk from test helper
roothorp Jun 16, 2025
b83f4cc
update licenses
roothorp Jun 16, 2025
207c2e9
fix tools/clean
roothorp Jun 16, 2025
87d0921
appease linter
roothorp Jun 16, 2025
5d15c6d
fix off by one
roothorp Jun 19, 2025
25f25a0
fix missed changes from merge
roothorp Jun 19, 2025
35d72fa
fixes for review
roothorp Jun 27, 2025
a4ea2e9
fix database user ToAtlas
s-urbaniak Jun 27, 2025
0fd2985
ignore default read concern and failindexkeytoolong
s-urbaniak Jun 28, 2025
2dd62e2
use zoneIDs for copy settings
s-urbaniak Jun 29, 2025
3e995f5
fix assertions
s-urbaniak Jun 29, 2025
e06cf92
fix unit test
s-urbaniak Jun 29, 2025
421d697
Fix deployment comparison and search node timeout
roothorp Jun 30, 2025
ed1ad59
fix e2e test for changed api contract in search nodes
s-urbaniak Jul 2, 2025
e3c3eb2
appease linter
roothorp Jul 2, 2025
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
2 changes: 1 addition & 1 deletion .licenses-gomod.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
100644 1e3a470d5dd0b4422abf666dce72d7b6d425dc54 go.mod
100644 f6972c85355d6523fb323533ab44f0e23d4dd9aa go.mod
29 changes: 14 additions & 15 deletions api/v1/alert_configurations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strconv"
"strings"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
"go.uber.org/zap"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
Expand Down Expand Up @@ -61,14 +61,14 @@ func (in *AlertConfiguration) ToAtlas() (*admin.GroupAlertsConfig, error) {
result.SetEnabled(in.Enabled)
result.SetEventTypeName(in.EventTypeName)

matchers := make([]map[string]interface{}, 0, len(in.Matchers))
matchers := make([]admin.StreamsMatcher, 0, len(in.Matchers))
for _, m := range in.Matchers {
matchers = append(
matchers,
map[string]interface{}{
"fieldName": m.FieldName,
"operator": m.Operator,
"value": m.Value,
admin.StreamsMatcher{
FieldName: m.FieldName,
Operator: m.Operator,
Value: m.Value,
},
)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func (in Threshold) Key() string {
return in.Operator + "|" + in.Units + "|" + in.Threshold
}

func (in *Threshold) IsEqual(threshold *admin.GreaterThanRawThreshold) bool {
func (in *Threshold) IsEqual(threshold *admin.StreamProcessorMetricThreshold) bool {
logger := zap.NewExample().Sugar()
if in == nil {
return threshold == nil
Expand All @@ -161,21 +161,20 @@ func (in *Threshold) IsEqual(threshold *admin.GreaterThanRawThreshold) bool {
return true
}

func (in *Threshold) ToAtlas() (*admin.GreaterThanRawThreshold, error) {
func (in *Threshold) ToAtlas() (*admin.StreamProcessorMetricThreshold, error) {
if in == nil {
return nil, nil
}

tr64, err := strconv.ParseInt(in.Threshold, 10, 64)
tr64, err := strconv.ParseFloat(in.Threshold, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse threshold value: %w. should be float", err)
}

tr := int(tr64)
result := &admin.GreaterThanRawThreshold{
result := &admin.StreamProcessorMetricThreshold{
Operator: &in.Operator,
Units: &in.Units,
Threshold: &tr,
Threshold: &tr64,
}

return result, nil
Expand Down Expand Up @@ -367,7 +366,7 @@ func (in MetricThreshold) Key() string {
in.Mode
}

func (in *MetricThreshold) IsEqual(threshold *admin.ServerlessMetricThreshold) bool {
func (in *MetricThreshold) IsEqual(threshold *admin.FlexClusterMetricThreshold) bool {
if in == nil {
return threshold == nil
}
Expand All @@ -388,7 +387,7 @@ func (in *MetricThreshold) IsEqual(threshold *admin.ServerlessMetricThreshold) b
in.Mode == threshold.GetMode()
}

func (in *MetricThreshold) ToAtlas() (*admin.ServerlessMetricThreshold, error) {
func (in *MetricThreshold) ToAtlas() (*admin.FlexClusterMetricThreshold, error) {
if in == nil {
return nil, nil
}
Expand All @@ -398,7 +397,7 @@ func (in *MetricThreshold) ToAtlas() (*admin.ServerlessMetricThreshold, error) {
return nil, fmt.Errorf("failed to parse threshold value: %w. should be float", err)
}

result := &admin.ServerlessMetricThreshold{
result := &admin.FlexClusterMetricThreshold{
MetricName: in.MetricName,
Operator: &in.Operator,
Threshold: &tr,
Expand Down
14 changes: 7 additions & 7 deletions api/v1/alert_configurations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
)
Expand All @@ -27,12 +27,12 @@ func TestServerlessMetricThreshold(t *testing.T) {
tests := []struct {
name string
akoData *MetricThreshold
atlasData *admin.ServerlessMetricThreshold
atlasData *admin.FlexClusterMetricThreshold
equal bool
}{
{
name: "Should be able to parse float Theshold",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand All @@ -50,7 +50,7 @@ func TestServerlessMetricThreshold(t *testing.T) {
},
{
name: "Should be able to parse int Theshold",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand All @@ -68,7 +68,7 @@ func TestServerlessMetricThreshold(t *testing.T) {
},
{
name: "Should be false if Theshold is not a number",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestServerlessMetricThreshold(t *testing.T) {
},
{
name: "Should be false if operator mismatched",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand All @@ -116,7 +116,7 @@ func TestServerlessMetricThreshold(t *testing.T) {
},
{
name: "Should fail if Threshold mismatched",
atlasData: &admin.ServerlessMetricThreshold{
atlasData: &admin.FlexClusterMetricThreshold{
MetricName: "test",
Mode: pointer.MakePtr("test"),
Operator: pointer.MakePtr("IN"),
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasbackupcompliancepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package v1
import (
"strings"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasbackupcompliancepolicy_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
Expand Down
56 changes: 30 additions & 26 deletions api/v1/atlasbackupschedule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ package v1
import (
"strings"

"go.mongodb.org/atlas/mongodbatlas"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/status"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
)

// AtlasBackupScheduleSpec defines the desired state of AtlasBackupSchedule
Expand Down Expand Up @@ -108,47 +109,50 @@ type AtlasBackupSchedule struct {
Status status.BackupScheduleStatus `json:"status,omitempty"`
}

func (in *AtlasBackupSchedule) ToAtlas(clusterID, clusterName, replicaSetID string, policy *AtlasBackupPolicy) *mongodbatlas.CloudProviderSnapshotBackupPolicy {
atlasPolicy := mongodbatlas.Policy{}
func (in *AtlasBackupSchedule) ToAtlas(clusterID, clusterName, zoneID string, policy *AtlasBackupPolicy) *admin.DiskBackupSnapshotSchedule20240805 {
atlasPolicy := admin.AdvancedDiskBackupSnapshotSchedulePolicy{}

items := make([]admin.DiskBackupApiPolicyItem, 0, len(policy.Spec.Items))
for _, bpItem := range policy.Spec.Items {
atlasPolicy.PolicyItems = append(atlasPolicy.PolicyItems, mongodbatlas.PolicyItem{
items = append(items, admin.DiskBackupApiPolicyItem{
FrequencyInterval: bpItem.FrequencyInterval,
FrequencyType: strings.ToLower(bpItem.FrequencyType),
RetentionValue: bpItem.RetentionValue,
RetentionUnit: strings.ToLower(bpItem.RetentionUnit),
RetentionValue: bpItem.RetentionValue,
})
}

result := &mongodbatlas.CloudProviderSnapshotBackupPolicy{
ClusterName: clusterName,
ClusterID: clusterID,
ReferenceHourOfDay: &in.Spec.ReferenceHourOfDay,
ReferenceMinuteOfHour: &in.Spec.ReferenceMinuteOfHour,
RestoreWindowDays: &in.Spec.RestoreWindowDays,
UpdateSnapshots: &in.Spec.UpdateSnapshots,
Policies: []mongodbatlas.Policy{atlasPolicy},
AutoExportEnabled: &in.Spec.AutoExportEnabled,
UseOrgAndGroupNamesInExportPrefix: &in.Spec.UseOrgAndGroupNamesInExportPrefix,
CopySettings: make([]mongodbatlas.CopySetting, 0, len(in.Spec.CopySettings)),
atlasPolicy.PolicyItems = &items

result := &admin.DiskBackupSnapshotSchedule20240805{
ClusterName: pointer.MakePtrOrNil(clusterName),
ClusterId: pointer.MakePtrOrNil(clusterID),
ReferenceHourOfDay: pointer.MakePtr(int(in.Spec.ReferenceHourOfDay)),
ReferenceMinuteOfHour: pointer.MakePtr(int(in.Spec.ReferenceMinuteOfHour)),
RestoreWindowDays: pointer.MakePtr(int(in.Spec.RestoreWindowDays)),
UpdateSnapshots: pointer.MakePtr(in.Spec.UpdateSnapshots),
Policies: &[]admin.AdvancedDiskBackupSnapshotSchedulePolicy{atlasPolicy},
AutoExportEnabled: pointer.MakePtr(in.Spec.AutoExportEnabled),
UseOrgAndGroupNamesInExportPrefix: pointer.MakePtr(in.Spec.UseOrgAndGroupNamesInExportPrefix),
}

if in.Spec.Export != nil {
result.Export = &mongodbatlas.Export{
ExportBucketID: in.Spec.Export.ExportBucketID,
FrequencyType: in.Spec.Export.FrequencyType,
result.Export = &admin.AutoExportPolicy{
ExportBucketId: pointer.MakePtr(in.Spec.Export.ExportBucketID),
FrequencyType: pointer.MakePtr(in.Spec.Export.FrequencyType),
}
}

copySettings := make([]admin.DiskBackupCopySetting20240805, 0, len(in.Spec.CopySettings))
for _, copySetting := range in.Spec.CopySettings {
result.CopySettings = append(result.CopySettings, mongodbatlas.CopySetting{
CloudProvider: copySetting.CloudProvider,
RegionName: copySetting.RegionName,
ReplicationSpecID: &replicaSetID,
ShouldCopyOplogs: copySetting.ShouldCopyOplogs,
Frequencies: copySetting.Frequencies,
copySettings = append(copySettings, admin.DiskBackupCopySetting20240805{
CloudProvider: copySetting.CloudProvider,
RegionName: copySetting.RegionName,
ZoneId: zoneID,
ShouldCopyOplogs: copySetting.ShouldCopyOplogs,
Frequencies: &copySetting.Frequencies,
})
}
result.CopySettings = &copySettings

return result
}
Expand Down
24 changes: 11 additions & 13 deletions api/v1/atlasbackupschedule_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"

"github.com/go-test/deep"
"go.mongodb.org/atlas/mongodbatlas"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
)
Expand Down Expand Up @@ -49,21 +49,19 @@ func Test_BackupScheduleToAtlas(t *testing.T) {
}
clusterName := "testCluster"
replicaSetID := "test-cluster-replica-set-id"
output := &mongodbatlas.CloudProviderSnapshotBackupPolicy{
ClusterID: "test-id",
ClusterName: "testCluster",
output := &admin.DiskBackupSnapshotSchedule20240805{
ClusterId: pointer.MakePtr("test-id"),
ClusterName: pointer.MakePtr("testCluster"),
AutoExportEnabled: pointer.MakePtr(true),
ReferenceHourOfDay: pointer.MakePtr[int64](10),
ReferenceMinuteOfHour: pointer.MakePtr[int64](10),
RestoreWindowDays: pointer.MakePtr[int64](7),
ReferenceHourOfDay: pointer.MakePtr(10),
ReferenceMinuteOfHour: pointer.MakePtr(10),
RestoreWindowDays: pointer.MakePtr(7),
UpdateSnapshots: pointer.MakePtr(false),
UseOrgAndGroupNamesInExportPrefix: pointer.MakePtr(false),
Policies: []mongodbatlas.Policy{
Policies: &[]admin.AdvancedDiskBackupSnapshotSchedulePolicy{
{
ID: "",
PolicyItems: []mongodbatlas.PolicyItem{
PolicyItems: &[]admin.DiskBackupApiPolicyItem{
{
ID: "",
FrequencyType: "hourly",
FrequencyInterval: 10,
RetentionUnit: "weeks",
Expand All @@ -72,10 +70,10 @@ func Test_BackupScheduleToAtlas(t *testing.T) {
},
},
},
CopySettings: []mongodbatlas.CopySetting{},
CopySettings: &[]admin.DiskBackupCopySetting20240805{},
}

result := inSchedule.ToAtlas(output.ClusterID, clusterName, replicaSetID, inPolicy)
result := inSchedule.ToAtlas(output.GetClusterId(), clusterName, replicaSetID, inPolicy)
if diff := deep.Equal(result, output); diff != nil {
t.Error(diff)
}
Expand Down
6 changes: 5 additions & 1 deletion api/v1/atlasdatabaseuser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"fmt"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -28,6 +28,7 @@ import (
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/status"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/compat"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/kube"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
)

// Important:
Expand Down Expand Up @@ -240,6 +241,9 @@ func (p AtlasDatabaseUser) ToAtlasSDK(ctx context.Context, kubeClient client.Cli
}

result.Password = &password
if result.Description == nil {
result.Description = pointer.MakePtr("")
}

return result, nil
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package v1
import (
"errors"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
"go.mongodb.org/atlas/mongodbatlas"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasfederatedauth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"errors"
"fmt"

"go.mongodb.org/atlas-sdk/v20241113001/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasfederatedauth_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/go-test/deep"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"go.mongodb.org/atlas-sdk/v20241113001/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasproject_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"time"

"github.com/google/go-cmp/cmp"
"go.mongodb.org/atlas-sdk/v20231115004/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
"sigs.k8s.io/yaml"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/atlasteam_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1

import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/networkpeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1

import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/provider"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/compat"
Expand Down
Loading
Loading