Skip to content

Commit 1b32748

Browse files
authored
Remote Resources sync (#180)
1 parent 71162c0 commit 1b32748

37 files changed

+3178
-708
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
uses: golangci/golangci-lint-action@v2
6464
with:
6565
version: v1.48.0
66+
args: --out-format=colored-line-number
6667
code-format-check:
6768
concurrency:
6869
group: lint-autoformat-${{ github.ref }}

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,16 @@ kind-load:
7777
docker tag cr.yandex/yc/ydb-operator:latest kind/ydb-operator:current
7878
kind load docker-image kind/ydb-operator:current --name kind-ydb-operator
7979

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

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

8688
.PHONY: test
87-
test: unit-test test ## Run all tests
89+
test: unit-test e2e-test ## Run all tests
8890

8991
.PHONY: clean
9092
clean:

api/v1alpha1/common_types.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package v1alpha1
22

3-
import corev1 "k8s.io/api/core/v1"
3+
import (
4+
corev1 "k8s.io/api/core/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
7+
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
8+
)
49

510
// NamespacedRef TODO: replace StorageRef
611
type NamespacedRef struct {
@@ -40,3 +45,12 @@ type RemoteSpec struct {
4045
// +required
4146
Cluster string `json:"cluster"`
4247
}
48+
49+
type RemoteResource struct {
50+
Group string `json:"group"`
51+
Version string `json:"version"`
52+
Kind string `json:"kind"`
53+
Name string `json:"name"`
54+
State constants.RemoteResourceState `json:"state"`
55+
Conditions []metav1.Condition `json:"conditions,omitempty"`
56+
}

api/v1alpha1/remotedatabasenodeset_types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package v1alpha1
22

33
import (
44
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
6+
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
57
)
68

79
//+kubebuilder:object:root=true
@@ -18,7 +20,14 @@ type RemoteDatabaseNodeSet struct {
1820
Spec DatabaseNodeSetSpec `json:"spec,omitempty"`
1921
// +optional
2022
// +kubebuilder:default:={state: "Pending"}
21-
Status DatabaseNodeSetStatus `json:"status,omitempty"`
23+
Status RemoteDatabaseNodeSetStatus `json:"status,omitempty"`
24+
}
25+
26+
// DatabaseNodeSetStatus defines the observed state
27+
type RemoteDatabaseNodeSetStatus struct {
28+
State constants.ClusterState `json:"state"`
29+
Conditions []metav1.Condition `json:"conditions,omitempty"`
30+
RemoteResources []RemoteResource `json:"remoteResources,omitempty"`
2231
}
2332

2433
//+kubebuilder:object:root=true

api/v1alpha1/remotestoragenodeset_types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package v1alpha1
22

33
import (
44
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
6+
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
57
)
68

79
//+kubebuilder:object:root=true
@@ -18,7 +20,14 @@ type RemoteStorageNodeSet struct {
1820
Spec StorageNodeSetSpec `json:"spec,omitempty"`
1921
// +optional
2022
// +kubebuilder:default:={state: "Pending"}
21-
Status StorageNodeSetStatus `json:"status,omitempty"`
23+
Status RemoteStorageNodeSetStatus `json:"status,omitempty"`
24+
}
25+
26+
// DatabaseNodeSetStatus defines the observed state
27+
type RemoteStorageNodeSetStatus struct {
28+
State constants.ClusterState `json:"state"`
29+
Conditions []metav1.Condition `json:"conditions,omitempty"`
30+
RemoteResources []RemoteResource `json:"remoteResources,omitempty"`
2231
}
2332

2433
//+kubebuilder:object:root=true

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/ydb-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.4.42
18+
version: 0.5.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "0.4.42"
24+
appVersion: "0.5.0"

deploy/ydb-operator/crds/remotedatabasenodeset.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4636,6 +4636,101 @@ spec:
46364636
- type
46374637
type: object
46384638
type: array
4639+
remoteResources:
4640+
items:
4641+
properties:
4642+
conditions:
4643+
items:
4644+
description: "Condition contains details for one aspect of
4645+
the current state of this API Resource. --- This struct
4646+
is intended for direct use as an array at the field path
4647+
.status.conditions. For example, \n \ttype FooStatus struct{
4648+
\t // Represents the observations of a foo's current
4649+
state. \t // Known .status.conditions.type are: \"Available\",
4650+
\"Progressing\", and \"Degraded\" \t // +patchMergeKey=type
4651+
\t // +patchStrategy=merge \t // +listType=map \t
4652+
\ // +listMapKey=type \t Conditions []metav1.Condition
4653+
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
4654+
protobuf:\"bytes,1,rep,name=conditions\"` \n \t // other
4655+
fields \t}"
4656+
properties:
4657+
lastTransitionTime:
4658+
description: lastTransitionTime is the last time the condition
4659+
transitioned from one status to another. This should
4660+
be when the underlying condition changed. If that is
4661+
not known, then using the time when the API field changed
4662+
is acceptable.
4663+
format: date-time
4664+
type: string
4665+
message:
4666+
description: message is a human readable message indicating
4667+
details about the transition. This may be an empty string.
4668+
maxLength: 32768
4669+
type: string
4670+
observedGeneration:
4671+
description: observedGeneration represents the .metadata.generation
4672+
that the condition was set based upon. For instance,
4673+
if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration
4674+
is 9, the condition is out of date with respect to the
4675+
current state of the instance.
4676+
format: int64
4677+
minimum: 0
4678+
type: integer
4679+
reason:
4680+
description: reason contains a programmatic identifier
4681+
indicating the reason for the condition's last transition.
4682+
Producers of specific condition types may define expected
4683+
values and meanings for this field, and whether the
4684+
values are considered a guaranteed API. The value should
4685+
be a CamelCase string. This field may not be empty.
4686+
maxLength: 1024
4687+
minLength: 1
4688+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
4689+
type: string
4690+
status:
4691+
description: status of the condition, one of True, False,
4692+
Unknown.
4693+
enum:
4694+
- "True"
4695+
- "False"
4696+
- Unknown
4697+
type: string
4698+
type:
4699+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
4700+
--- Many .condition.type values are consistent across
4701+
resources like Available, but because arbitrary conditions
4702+
can be useful (see .node.status.conditions), the ability
4703+
to deconflict is important. The regex it matches is
4704+
(dns1123SubdomainFmt/)?(qualifiedNameFmt)
4705+
maxLength: 316
4706+
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])$
4707+
type: string
4708+
required:
4709+
- lastTransitionTime
4710+
- message
4711+
- reason
4712+
- status
4713+
- type
4714+
type: object
4715+
type: array
4716+
group:
4717+
type: string
4718+
kind:
4719+
type: string
4720+
name:
4721+
type: string
4722+
state:
4723+
type: string
4724+
version:
4725+
type: string
4726+
required:
4727+
- group
4728+
- kind
4729+
- name
4730+
- state
4731+
- version
4732+
type: object
4733+
type: array
46394734
state:
46404735
type: string
46414736
required:

0 commit comments

Comments
 (0)