Skip to content

Commit

Permalink
revert Domain to ClusterSpec for statefulset args
Browse files Browse the repository at this point in the history
  • Loading branch information
kobzonega committed Jan 22, 2024
1 parent fc0067d commit 720e1a1
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 48 deletions.
38 changes: 19 additions & 19 deletions api/v1alpha1/database_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,6 @@ import (

// DatabaseSpec defines the desired state of Database
type DatabaseSpec struct {
// (Optional) Name of the root storage domain
// Default: Root
// +kubebuilder:validation:Pattern:=[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:default:="root"
// +optional
Domain string `json:"domain"`

// (Optional) Custom database path in schemeshard
// Default: /<spec.domain>/<metadata.name>
// +kubebuilder:validation:Pattern:=/[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?/[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?(/[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?)*
// +kubebuilder:validation:MaxLength:=255
// +optional
Path string `json:"path,omitempty"`

// (Optional) If specified, created database will be "serverless".
// +optional
ServerlessResources *ServerlessDatabaseResources `json:"serverlessResources,omitempty"`

DatabaseClusterSpec `json:",inline"`

DatabaseNodeSpec `json:",inline"`
Expand All @@ -46,6 +27,25 @@ type DatabaseClusterSpec struct {
// +optional
StorageEndpoint string `json:"storageEndpoint"`

// (Optional) Name of the root storage domain
// Default: Root
// +kubebuilder:validation:Pattern:=[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:default:="Root"
// +optional
Domain string `json:"domain"`

// (Optional) Custom database path in schemeshard
// Default: /<spec.domain>/<metadata.name>
// +kubebuilder:validation:Pattern:=/[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?/[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?(/[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?)*
// +kubebuilder:validation:MaxLength:=255
// +optional
Path string `json:"path,omitempty"`

// (Optional) If specified, created database will be "serverless".
// +optional
ServerlessResources *ServerlessDatabaseResources `json:"serverlessResources,omitempty"`

// Encryption configuration
// +optional
Encryption *EncryptionConfig `json:"encryption,omitempty"`
Expand Down
26 changes: 13 additions & 13 deletions api/v1alpha1/storage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ import (

// StorageSpec defines the desired state of Storage
type StorageSpec struct {
// (Optional) Name of the root storage domain
// Default: root
// +kubebuilder:validation:Pattern:=[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:default:="Root"
// +optional
Domain string `json:"domain"`

// (Optional) Operator connection settings
// Default: (not specified)
// +optional
OperatorConnection *ConnectionOptions `json:"operatorConnection,omitempty"`

StorageClusterSpec `json:",inline"`

StorageNodeSpec `json:",inline"`
Expand Down Expand Up @@ -132,6 +119,19 @@ type StorageNodeSpec struct {
}

type StorageClusterSpec struct {
// (Optional) Name of the root storage domain
// Default: root
// +kubebuilder:validation:Pattern:=[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:default:="Root"
// +optional
Domain string `json:"domain"`

// (Optional) Operator connection settings
// Default: (not specified)
// +optional
OperatorConnection *ConnectionOptions `json:"operatorConnection,omitempty"`

// Data storage topology mode
// For details, see https://ydb.tech/docs/en/cluster/topology
// FIXME mirror-3-dc is only supported with external configuration
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/storage_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *StorageDefaulter) Default(ctx context.Context, obj runtime.Object) erro
}

if storage.Spec.Domain == "" {
storage.Spec.Domain = "root" // FIXME
storage.Spec.Domain = "Root" // FIXME
}

return nil
Expand Down
20 changes: 10 additions & 10 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion deploy/ydb-operator/crds/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ spec:
- enabled
type: object
domain:
default: root
default: Root
description: '(Optional) Name of the root storage domain Default:
Root'
maxLength: 63
Expand Down
34 changes: 34 additions & 0 deletions deploy/ydb-operator/crds/databasenodeset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,13 @@ spec:
required:
- enabled
type: object
domain:
default: Root
description: '(Optional) Name of the root storage domain Default:
Root'
maxLength: 63
pattern: '[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?'
type: string
encryption:
description: Encryption configuration
properties:
Expand Down Expand Up @@ -2285,6 +2292,12 @@ spec:
running, operator reacts to specification change of this Database
resource.
type: boolean
path:
description: '(Optional) Custom database path in schemeshard Default:
/<spec.domain>/<metadata.name>'
maxLength: 255
pattern: /[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?/[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?(/[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?)*
type: string
pause:
default: false
description: The state of the Database processes. `true` means all
Expand Down Expand Up @@ -2380,6 +2393,27 @@ spec:
type: string
type: object
type: array
serverlessResources:
description: (Optional) If specified, created database will be "serverless".
properties:
sharedDatabaseRef:
description: Reference to YDB Database with configured shared
resources
properties:
name:
maxLength: 63
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?'
type: string
namespace:
maxLength: 63
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?'
type: string
required:
- name
type: object
required:
- sharedDatabaseRef
type: object
service:
description: '(Optional) Storage services parameter overrides Default:
(not specified)'
Expand Down
66 changes: 66 additions & 0 deletions deploy/ydb-operator/crds/storagenodeset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,13 @@ spec:
type: string
type: object
type: array
domain:
default: Root
description: '(Optional) Name of the root storage domain Default:
root'
maxLength: 63
pattern: '[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?'
type: string
erasure:
default: block-4-2
description: Data storage topology mode For details, see https://ydb.tech/docs/en/cluster/topology
Expand Down Expand Up @@ -2426,6 +2433,65 @@ spec:
description: Number of nodes (pods)
format: int32
type: integer
operatorConnection:
description: '(Optional) Operator connection settings Default: (not
specified)'
properties:
accessToken:
properties:
secretKeyRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
required:
- secretKeyRef
type: object
staticCredentials:
properties:
password:
properties:
secretKeyRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
required:
- secretKeyRef
type: object
username:
type: string
required:
- username
type: object
type: object
operatorSync:
default: true
description: Enables or disables operator's reconcile loop. `false`
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ var _ = Describe("Operator smoke test", func() {
Eventually(func(g Gomega) bool {
database := v1alpha1.Database{}
g.Expect(k8sClient.Get(ctx, types.NamespacedName{
Name: database.Name,
Name: databaseSample.Name,
Namespace: testobjects.YdbNamespace,
}, &database)).Should(Succeed())

Expand All @@ -458,7 +458,7 @@ var _ = Describe("Operator smoke test", func() {
Eventually(func(g Gomega) bool {
database := v1alpha1.Database{}
g.Expect(k8sClient.Get(ctx, types.NamespacedName{
Name: database.Name,
Name: databaseSample.Name,
Namespace: testobjects.YdbNamespace,
}, &database)).Should(Succeed())

Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/test-objects/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func DefaultStorage(storageYamlConfigPath string) *v1alpha1.Storage {
Namespace: YdbNamespace,
},
Spec: v1alpha1.StorageSpec{
Domain: DefaultDomain,
StorageClusterSpec: v1alpha1.StorageClusterSpec{
Domain: DefaultDomain,
OperatorSync: true,
Erasure: "block-4-2",
Image: &v1alpha1.PodImage{
Expand Down Expand Up @@ -106,8 +106,8 @@ func DefaultDatabase() *v1alpha1.Database {
Namespace: YdbNamespace,
},
Spec: v1alpha1.DatabaseSpec{
Domain: DefaultDomain,
DatabaseClusterSpec: v1alpha1.DatabaseClusterSpec{
Domain: DefaultDomain,
OperatorSync: true,
StorageClusterRef: v1alpha1.NamespacedRef{
Name: StorageName,
Expand Down

0 comments on commit 720e1a1

Please sign in to comment.