Skip to content

Commit

Permalink
refactor: rename embeddedSqlite to embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Apr 2, 2024
1 parent fb37450 commit ecd6961
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 37 deletions.
4 changes: 2 additions & 2 deletions chart/templates/_backingstore.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
{{- if .Values.controlPlane.backingStore.etcd.deploy.enabled -}}
{{- $backingStores = add1 $backingStores -}}
{{- end -}}
{{- if .Values.controlPlane.backingStore.database.embeddedSqlite.enabled -}}
{{- if .Values.controlPlane.backingStore.database.embedded.enabled -}}
{{- $backingStores = add1 $backingStores -}}
{{- end -}}
{{- if .Values.controlPlane.backingStore.database.external.enabled -}}
{{- $backingStores = add1 $backingStores -}}
{{- end -}}
{{- if gt $backingStores 1 -}}
{{- fail "you can only enable one backingStore at the same time" -}}
{{- else if or (eq $backingStores 0) .Values.controlPlane.backingStore.database.embeddedSqlite.enabled -}}
{{- else if or (eq $backingStores 0) .Values.controlPlane.backingStore.database.embedded.enabled -}}
{{- true -}}
{{- end -}}
{{- end -}}
Expand Down
2 changes: 1 addition & 1 deletion chart/tests/headless-service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ tests:
controlPlane:
backingStore:
database:
embeddedSqlite:
embedded:
enabled: true
asserts:
- hasDocuments:
Expand Down
2 changes: 1 addition & 1 deletion chart/tests/statefulset_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ tests:
enabled: true
backingStore:
database:
embeddedSqlite:
embedded:
enabled: true
asserts:
- equal:
Expand Down
2 changes: 1 addition & 1 deletion chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@
},
"Database": {
"properties": {
"embeddedSqlite": {
"embedded": {
"$ref": "#/$defs/DatabaseKine",
"description": "Embedded defines that an embedded database (sqlite) should be used as the backend for the virtual cluster"
},
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ controlPlane:

backingStore:
database:
embeddedSqlite:
embedded:
enabled: false
# Optional sqlite dataSource
# dataSource: ""
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ type BackingStore struct {

type Database struct {
// Embedded defines that an embedded database (sqlite) should be used as the backend for the virtual cluster
Embedded DatabaseKine `json:"embeddedSqlite,omitempty"`
Embedded DatabaseKine `json:"embedded,omitempty"`

// External defines that an external database should be used as the backend for the virtual cluster
External DatabaseKine `json:"external,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion config/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ controlPlane:

backingStore:
database:
embeddedSqlite:
embedded:
enabled: false
# Optional sqlite dataSource
# dataSource: ""
Expand Down
4 changes: 2 additions & 2 deletions pkg/k0s/k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ spec:
type: kine
kine:
dataSource: {{ .Values.controlPlane.backingStore.database.external.dataSource }}
{{- else if .Values.controlPlane.backingStore.database.embeddedSqlite.dataSource }}
{{- else if .Values.controlPlane.backingStore.database.embedded.dataSource }}
storage:
type: kine
kine:
dataSource: {{ .Values.controlPlane.backingStore.database.embeddedSqlite.dataSource }}
dataSource: {{ .Values.controlPlane.backingStore.database.embedded.dataSource }}
{{- end }}`

func StartK0S(ctx context.Context, cancel context.CancelFunc, vConfig *config.VirtualClusterConfig) error {
Expand Down
65 changes: 39 additions & 26 deletions test/e2e/k8sdefaultendpoint/k8sdefaultendpoint.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package k8sdefaultendpoint

import (
"context"
"fmt"
"reflect"
"time"

"github.com/loft-sh/vcluster/test/framework"
"github.com/onsi/ginkgo/v2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
)

var _ = ginkgo.Describe("map default/kubernetes endpoint to physical vcluster endpoint", func() {
Expand All @@ -21,40 +25,49 @@ var _ = ginkgo.Describe("map default/kubernetes endpoint to physical vcluster en
ginkgo.It("Test default/kubernetes endpoints matches with vcluster service endpoint", func() {
ctx := f.Context

hostClusterEndpoint, err := f.HostClient.CoreV1().Endpoints(f.VclusterNamespace).Get(ctx, "vcluster", v1.GetOptions{})
framework.ExpectNoError(err)
waitErr := wait.PollUntilContextTimeout(ctx, time.Millisecond*500, framework.PollTimeout*2, true, func(ctx context.Context) (done bool, err error) {
hostClusterEndpoint, err := f.HostClient.CoreV1().Endpoints(f.VclusterNamespace).Get(ctx, "vcluster", v1.GetOptions{})
if err != nil {
return false, err
}

vclusterEndpoint, err := f.VclusterClient.CoreV1().Endpoints("default").Get(ctx, "kubernetes", v1.GetOptions{})
framework.ExpectNoError(err)
vclusterEndpoint, err := f.VclusterClient.CoreV1().Endpoints("default").Get(ctx, "kubernetes", v1.GetOptions{})
if err != nil {
return false, err
}

hostClusterIps := make([]string, 0)
hostClusterPorts := make([]int32, 0)
vClusterIps := make([]string, 0)
vClusterPorts := make([]int32, 0)
hostClusterIps := make([]string, 0)
hostClusterPorts := make([]int32, 0)
vClusterIps := make([]string, 0)
vClusterPorts := make([]int32, 0)

for _, address := range hostClusterEndpoint.Subsets[0].Addresses {
hostClusterIps = append(hostClusterIps, address.IP)
}
for _, address := range hostClusterEndpoint.Subsets[0].Addresses {
hostClusterIps = append(hostClusterIps, address.IP)
}

for _, port := range hostClusterEndpoint.Subsets[0].Ports {
if port.Name == "kubelet" {
continue
for _, port := range hostClusterEndpoint.Subsets[0].Ports {
if port.Name == "kubelet" {
continue
}
hostClusterPorts = append(hostClusterPorts, port.Port)
}
hostClusterPorts = append(hostClusterPorts, port.Port)
}

for _, address := range vclusterEndpoint.Subsets[0].Addresses {
vClusterIps = append(vClusterIps, address.IP)
}
for _, address := range vclusterEndpoint.Subsets[0].Addresses {
vClusterIps = append(vClusterIps, address.IP)
}

for _, port := range vclusterEndpoint.Subsets[0].Ports {
vClusterPorts = append(vClusterPorts, port.Port)
}
for _, port := range vclusterEndpoint.Subsets[0].Ports {
vClusterPorts = append(vClusterPorts, port.Port)
}

ok := reflect.DeepEqual(hostClusterIps, vClusterIps)
framework.ExpectEqual(ok, true)
ok = reflect.DeepEqual(hostClusterPorts, vClusterPorts)
framework.ExpectEqual(ok, true)
if !reflect.DeepEqual(hostClusterIps, vClusterIps) || !reflect.DeepEqual(hostClusterPorts, vClusterPorts) {
fmt.Println("IPs", hostClusterIps, vClusterIps)
fmt.Println("Ports", hostClusterPorts, vClusterPorts)
return false, nil
}

return true, nil
})
framework.ExpectNoError(waitErr, "error after waiting")
})
})
4 changes: 3 additions & 1 deletion test/e2e/manifests/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package manifests

import (
"context"
"fmt"
"time"

"github.com/loft-sh/vcluster/pkg/controllers/deploy"
Expand Down Expand Up @@ -36,7 +37,7 @@ var _ = ginkgo.Describe("Helm charts (regular and OCI) are synced and applied as
)

ginkgo.It("Test if configmap for both charts gets applied", func() {
err := wait.PollUntilContextTimeout(f.Context, time.Millisecond*500, framework.PollTimeout, true, func(ctx context.Context) (bool, error) {
err := wait.PollUntilContextTimeout(f.Context, time.Millisecond*500, framework.PollTimeout*2, true, func(ctx context.Context) (bool, error) {
cm, err := f.VclusterClient.CoreV1().ConfigMaps(deploy.VClusterDeployConfigMapNamespace).
Get(ctx, deploy.VClusterDeployConfigMap, metav1.GetOptions{})
if err != nil {
Expand All @@ -50,6 +51,7 @@ var _ = ginkgo.Describe("Helm charts (regular and OCI) are synced and applied as
status := deploy.ParseStatus(cm)
for _, chart := range status.Charts {
if chart.Phase != string(deploy.StatusSuccess) {
fmt.Println(chart.Name, chart.Phase, chart.Reason, chart.Message)
return false, nil
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/servicesync/servicesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ func checkEndpointsSync(ctx context.Context, fromClient kubernetes.Interface, fr

_, err = fromClient.AppsV1().Deployments(fromNamespace).Update(ctx, deployment, metav1.UpdateOptions{})
if err != nil {
if kerrors.IsConflict(err) {
return false, nil
}

return false, err
}

Expand Down

0 comments on commit ecd6961

Please sign in to comment.