Skip to content

Commit

Permalink
Remote Resources sync (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobzonega authored Mar 14, 2024
1 parent 71162c0 commit 1b32748
Show file tree
Hide file tree
Showing 37 changed files with 3,178 additions and 708 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
version: v1.48.0
args: --out-format=colored-line-number
code-format-check:
concurrency:
group: lint-autoformat-${{ github.ref }}
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ kind-load:
docker tag cr.yandex/yc/ydb-operator:latest kind/ydb-operator:current
kind load docker-image kind/ydb-operator:current --name kind-ydb-operator

.PHONY: unit-test
unit-test: manifests generate fmt vet envtest ## Run unit tests
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -v -timeout 1800s -p 1 ./internal/controllers/... -ginkgo.vv -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -v -timeout 1800s -p 1 ./internal/controllers/... -ginkgo.v -coverprofile cover.out

e2e-test: docker-build kind-init kind-load ## Run e2e tests
go test -v -timeout 1800s -p 1 ./e2e/... -args -ginkgo.vv
.PHONY: e2e-test
e2e-test: manifests generate fmt vet docker-build kind-init kind-load ## Run e2e tests
go test -v -timeout 1800s -p 1 ./e2e/... -args -ginkgo.v

.PHONY: test
test: unit-test test ## Run all tests
test: unit-test e2e-test ## Run all tests

.PHONY: clean
clean:
Expand Down
16 changes: 15 additions & 1 deletion api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package v1alpha1

import corev1 "k8s.io/api/core/v1"
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
)

// NamespacedRef TODO: replace StorageRef
type NamespacedRef struct {
Expand Down Expand Up @@ -40,3 +45,12 @@ type RemoteSpec struct {
// +required
Cluster string `json:"cluster"`
}

type RemoteResource struct {
Group string `json:"group"`
Version string `json:"version"`
Kind string `json:"kind"`
Name string `json:"name"`
State constants.RemoteResourceState `json:"state"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}
11 changes: 10 additions & 1 deletion api/v1alpha1/remotedatabasenodeset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
)

//+kubebuilder:object:root=true
Expand All @@ -18,7 +20,14 @@ type RemoteDatabaseNodeSet struct {
Spec DatabaseNodeSetSpec `json:"spec,omitempty"`
// +optional
// +kubebuilder:default:={state: "Pending"}
Status DatabaseNodeSetStatus `json:"status,omitempty"`
Status RemoteDatabaseNodeSetStatus `json:"status,omitempty"`
}

// DatabaseNodeSetStatus defines the observed state
type RemoteDatabaseNodeSetStatus struct {
State constants.ClusterState `json:"state"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
RemoteResources []RemoteResource `json:"remoteResources,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
11 changes: 10 additions & 1 deletion api/v1alpha1/remotestoragenodeset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
)

//+kubebuilder:object:root=true
Expand All @@ -18,7 +20,14 @@ type RemoteStorageNodeSet struct {
Spec StorageNodeSetSpec `json:"spec,omitempty"`
// +optional
// +kubebuilder:default:={state: "Pending"}
Status StorageNodeSetStatus `json:"status,omitempty"`
Status RemoteStorageNodeSetStatus `json:"status,omitempty"`
}

// DatabaseNodeSetStatus defines the observed state
type RemoteStorageNodeSetStatus struct {
State constants.ClusterState `json:"state"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
RemoteResources []RemoteResource `json:"remoteResources,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
80 changes: 80 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions deploy/ydb-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.42
version: 0.5.0

# 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.4.42"
appVersion: "0.5.0"
95 changes: 95 additions & 0 deletions deploy/ydb-operator/crds/remotedatabasenodeset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4636,6 +4636,101 @@ spec:
- type
type: object
type: array
remoteResources:
items:
properties:
conditions:
items:
description: "Condition contains details for one aspect of
the current state of this API Resource. --- This struct
is intended for direct use as an array at the field path
.status.conditions. For example, \n \ttype FooStatus struct{
\t // Represents the observations of a foo's current
state. \t // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" \t // +patchMergeKey=type
\t // +patchStrategy=merge \t // +listType=map \t
\ // +listMapKey=type \t Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n \t // other
fields \t}"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should
be when the underlying condition changed. If that is
not known, then using the time when the API field changed
is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance,
if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the
current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier
indicating the reason for the condition's last transition.
Producers of specific condition types may define expected
values and meanings for this field, and whether the
values are considered a guaranteed API. The value should
be a CamelCase string. This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False,
Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across
resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability
to deconflict is important. The regex it matches is
(dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
group:
type: string
kind:
type: string
name:
type: string
state:
type: string
version:
type: string
required:
- group
- kind
- name
- state
- version
type: object
type: array
state:
type: string
required:
Expand Down
Loading

0 comments on commit 1b32748

Please sign in to comment.