diff --git a/api/v1alpha1/storage_webhook.go b/api/v1alpha1/storage_webhook.go index 3a4119f3..425f6c03 100644 --- a/api/v1alpha1/storage_webhook.go +++ b/api/v1alpha1/storage_webhook.go @@ -63,10 +63,17 @@ func (r *Storage) GetGRPCServiceEndpoint() string { } func (r *Storage) GetHostFromConfigEndpoint() string { - var configuration schema.Configuration - + var rawYamlConfiguration string // skip handle error because we already checked in webhook - configuration, _ = ParseConfiguration(r.Spec.Configuration) + success, dynConfig, _ := ParseDynConfig(r.Spec.Configuration) + if success { + config, _ := yaml.Marshal(dynConfig.Config) + rawYamlConfiguration = string(config) + } else { + rawYamlConfiguration = r.Spec.Configuration + } + + configuration, _ := ParseConfiguration(rawYamlConfiguration) randNum := rand.Intn(len(configuration.Hosts)) // #nosec G404 return fmt.Sprintf("%s:%d", configuration.Hosts[randNum].Host, GRPCPort) } diff --git a/deploy/ydb-operator/Chart.yaml b/deploy/ydb-operator/Chart.yaml index 8c23d714..95ef2f11 100644 --- a/deploy/ydb-operator/Chart.yaml +++ b/deploy/ydb-operator/Chart.yaml @@ -15,10 +15,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.5.26 +version: 0.5.27 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.5.26" +appVersion: "0.5.27" diff --git a/e2e/tests/data/storage-mirror-3-dc-config-nodeSets.yaml b/e2e/tests/data/storage-mirror-3-dc-config-nodeSets.yaml deleted file mode 100644 index 0384fb6b..00000000 --- a/e2e/tests/data/storage-mirror-3-dc-config-nodeSets.yaml +++ /dev/null @@ -1,118 +0,0 @@ -static_erasure: mirror-3-dc -host_configs: - - drive: - - path: SectorMap:1:1 - type: SSD - - path: SectorMap:2:1 - type: SSD - - path: SectorMap:3:1 - type: SSD - host_config_id: 1 -domains_config: - domain: - - name: Root - storage_pool_types: - - kind: ssd - pool_config: - box_id: 1 - erasure_species: mirror-3-dc - kind: ssd - geometry: - realm_level_begin: 10 - realm_level_end: 20 - domain_level_begin: 10 - domain_level_end: 256 - pdisk_filter: - - property: - - type: SSD # device type to match host_configs.drive.type - vdisk_kind: Default - state_storage: - - ring: - node: [1, 2, 3] - nto_select: 3 - ssid: 1 -table_service_config: - sql_version: 1 -actor_system_config: - executor: - - name: System - threads: 1 - type: BASIC - - name: User - threads: 1 - type: BASIC - - name: Batch - threads: 1 - type: BASIC - - name: IO - threads: 1 - time_per_mailbox_micro_secs: 100 - type: IO - - name: IC - spin_threshold: 10 - threads: 4 - time_per_mailbox_micro_secs: 100 - type: BASIC - scheduler: - progress_threshold: 10000 - resolution: 256 - spin_threshold: 0 -blob_storage_config: # configuration of static blobstorage group. - service_set: - groups: - - erasure_species: mirror-3-dc - rings: - - fail_domains: - - vdisk_locations: - - node_id: 1 - pdisk_category: SSD - path: SectorMap:1:1 - - vdisk_locations: - - node_id: 1 - pdisk_category: SSD - path: SectorMap:2:1 - - vdisk_locations: - - node_id: 1 - pdisk_category: SSD - path: SectorMap:3:1 - - fail_domains: - - vdisk_locations: - - node_id: 2 - pdisk_category: SSD - path: SectorMap:1:1 - - vdisk_locations: - - node_id: 2 - pdisk_category: SSD - path: SectorMap:2:1 - - vdisk_locations: - - node_id: 2 - pdisk_category: SSD - path: SectorMap:3:1 - - fail_domains: - - vdisk_locations: - - node_id: 3 - pdisk_category: SSD - path: SectorMap:1:1 - - vdisk_locations: - - node_id: 3 - pdisk_category: SSD - path: SectorMap:2:1 - - vdisk_locations: - - node_id: 3 - pdisk_category: SSD - path: SectorMap:3:1 -channel_profile_config: - profile: - - channel: - - erasure_species: mirror-3-dc - pdisk_category: 0 - storage_pool_kind: ssd - - erasure_species: mirror-3-dc - pdisk_category: 0 - storage_pool_kind: ssd - - erasure_species: mirror-3-dc - pdisk_category: 0 - storage_pool_kind: ssd - profile_id: 0 -grpc_config: - port: 2135 diff --git a/e2e/tests/smoke_test.go b/e2e/tests/smoke_test.go index c0ac3c29..f612a4b2 100644 --- a/e2e/tests/smoke_test.go +++ b/e2e/tests/smoke_test.go @@ -252,6 +252,25 @@ func portForward(ctx context.Context, svcName string, svcNamespace string, port }, Timeout, test.Interval).Should(BeNil()) } +func emptyStorageDefaultFields(storage *v1alpha1.Storage) { + storage.Spec.Image = nil + storage.Spec.Resources = nil + storage.Spec.Service = nil + storage.Spec.Monitoring = nil +} + +func emptyDatabaseDefaultFields(database *v1alpha1.Database) { + database.Spec.StorageClusterRef.Namespace = "" + database.Spec.Image = nil + database.Spec.Service = nil + database.Spec.Domain = "" + database.Spec.Path = "" + database.Spec.Encryption = nil + database.Spec.Datastreams = nil + database.Spec.Monitoring = nil + database.Spec.StorageEndpoint = "" +} + var _ = Describe("Operator smoke test", func() { var ctx context.Context var namespace corev1.Namespace @@ -284,30 +303,38 @@ var _ = Describe("Operator smoke test", func() { }) It("Check webhook defaulter", func() { - storageSample.Spec.Image = nil - storageSample.Spec.Resources = nil - storageSample.Spec.Service = nil - storageSample.Spec.Monitoring = nil + emptyStorageDefaultFields(storageSample) Expect(k8sClient.Create(ctx, storageSample)).Should(Succeed()) defer func() { Expect(k8sClient.Delete(ctx, storageSample)).Should(Succeed()) }() - databaseSample.Spec.StorageClusterRef.Namespace = "" - databaseSample.Spec.Image = nil - databaseSample.Spec.Service = nil - databaseSample.Spec.Domain = "" - databaseSample.Spec.Path = "" - databaseSample.Spec.Encryption = nil - databaseSample.Spec.Datastreams = nil - databaseSample.Spec.Monitoring = nil - databaseSample.Spec.StorageEndpoint = "" + emptyDatabaseDefaultFields(databaseSample) Expect(k8sClient.Create(ctx, databaseSample)).Should(Succeed()) defer func() { Expect(k8sClient.Delete(ctx, databaseSample)).Should(Succeed()) }() }) + It("Check webhook defaulter with dynconfig and nodeSets", func() { + storageSample = testobjects.DefaultStorage(filepath.Join(".", "data", "storage-mirror-3-dc-dynconfig.yaml")) + emptyStorageDefaultFields(storageSample) + storageSample.Spec.NodeSets = []v1alpha1.StorageNodeSetSpecInline{ + { + Name: "storage-nodeset-1", + StorageNodeSpec: v1alpha1.StorageNodeSpec{Nodes: 1}, + }, + { + Name: "storage-nodeset-2", + StorageNodeSpec: v1alpha1.StorageNodeSpec{Nodes: 2}, + }, + } + Expect(k8sClient.Create(ctx, storageSample)).Should(Succeed()) + defer func() { + Expect(k8sClient.Delete(ctx, storageSample)).Should(Succeed()) + }() + }) + It("general smoke pipeline, create storage + database", func() { By("issuing create commands...") Expect(k8sClient.Create(ctx, storageSample)).Should(Succeed()) @@ -494,7 +521,7 @@ var _ = Describe("Operator smoke test", func() { It("create storage and database with nodeSets", func() { By("issuing create commands...") - storageSample = testobjects.DefaultStorage(filepath.Join(".", "data", "storage-mirror-3-dc-config-nodeSets.yaml")) + storageSample = testobjects.DefaultStorage(filepath.Join(".", "data", "storage-mirror-3-dc-config.yaml")) testNodeSetName := "nodeset" for idx := 1; idx <= 3; idx++ { storageSample.Spec.NodeSets = append(storageSample.Spec.NodeSets, v1alpha1.StorageNodeSetSpecInline{