Skip to content

Commit fe4ff0f

Browse files
New DerivedServices Architecture + Source-Cluster label (#179)
* Added managed by label - issue 110 * derived services + unit tests + label * revisions and delete svc bug * annotation readded. kind & janitor test changes. * fix expected test result. cluster-id -> cluster * rm derived services
1 parent 5c6b00d commit fe4ff0f

26 files changed

+539
-148
lines changed

config/crd/bases/multicluster.x-k8s.io_serviceimports.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ spec:
4141
is ClusterSetIP.
4242
items:
4343
type: string
44-
maxItems: 1
4544
type: array
4645
ports:
4746
items:

integration/janitor/api.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/cloudmap"
77
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/common"
8-
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/test"
98
"github.com/aws/aws-sdk-go-v2/aws"
109
sd "github.com/aws/aws-sdk-go-v2/service/servicediscovery"
1110
)
@@ -21,9 +20,9 @@ type serviceDiscoveryJanitorApi struct {
2120
janitorFacade SdkJanitorFacade
2221
}
2322

24-
func NewServiceDiscoveryJanitorApiFromConfig(cfg *aws.Config) ServiceDiscoveryJanitorApi {
23+
func NewServiceDiscoveryJanitorApiFromConfig(cfg *aws.Config, clusterUtils common.ClusterUtils) ServiceDiscoveryJanitorApi {
2524
return &serviceDiscoveryJanitorApi{
26-
ServiceDiscoveryApi: cloudmap.NewServiceDiscoveryApiFromConfig(cfg, common.NewClusterUtilsForTest(test.ClusterId, test.ClusterSetId)),
25+
ServiceDiscoveryApi: cloudmap.NewServiceDiscoveryApiFromConfig(cfg, clusterUtils),
2726
janitorFacade: NewSdkJanitorFacadeFromConfig(cfg),
2827
}
2928
}

integration/janitor/api_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
janitorMock "github.com/aws/aws-cloud-map-mcs-controller-for-k8s/mocks/integration/janitor"
8+
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/common"
89
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/test"
910
"github.com/aws/aws-sdk-go-v2/aws"
1011
sd "github.com/aws/aws-sdk-go-v2/service/servicediscovery"
@@ -13,7 +14,7 @@ import (
1314
)
1415

1516
func TestNewServiceDiscoveryJanitorApiFromConfig(t *testing.T) {
16-
assert.NotNil(t, NewServiceDiscoveryJanitorApiFromConfig(&aws.Config{}))
17+
assert.NotNil(t, NewServiceDiscoveryJanitorApiFromConfig(&aws.Config{}, common.ClusterUtils{}))
1718
}
1819

1920
func TestServiceDiscoveryJanitorApi_DeleteNamespace_HappyCase(t *testing.T) {

integration/janitor/janitor.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77

88
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/cloudmap"
9+
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/common"
910
"github.com/aws/aws-sdk-go-v2/aws"
1011
"github.com/aws/aws-sdk-go-v2/config"
1112
)
@@ -22,7 +23,7 @@ type cloudMapJanitor struct {
2223
}
2324

2425
// NewDefaultJanitor returns a new janitor object.
25-
func NewDefaultJanitor() CloudMapJanitor {
26+
func NewDefaultJanitor(clusterId string, clusterSetId string) CloudMapJanitor {
2627
awsCfg, err := config.LoadDefaultConfig(context.TODO())
2728

2829
if err != nil {
@@ -31,7 +32,7 @@ func NewDefaultJanitor() CloudMapJanitor {
3132
}
3233

3334
return &cloudMapJanitor{
34-
sdApi: NewServiceDiscoveryJanitorApiFromConfig(&awsCfg),
35+
sdApi: NewServiceDiscoveryJanitorApiFromConfig(&awsCfg, common.NewClusterUtilsForTest(clusterId, clusterSetId)),
3536
fail: func() { os.Exit(1) },
3637
}
3738
}

integration/janitor/janitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type testJanitor struct {
2121
}
2222

2323
func TestNewDefaultJanitor(t *testing.T) {
24-
assert.NotNil(t, NewDefaultJanitor())
24+
assert.NotNil(t, NewDefaultJanitor(test.ClusterId1, test.ClusterSetId1))
2525
}
2626

2727
func TestCleanupHappyCase(t *testing.T) {

integration/janitor/runner/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import (
99
)
1010

1111
func main() {
12-
if len(os.Args) != 2 {
13-
fmt.Println("Expected single namespace name argument")
12+
if len(os.Args) != 4 {
13+
fmt.Println("Expected namespace name, clusterId, clusterSetId arguments")
1414
os.Exit(1)
1515
}
1616

17-
j := janitor.NewDefaultJanitor()
1817
nsName := os.Args[1]
18+
clusterId := os.Args[2]
19+
clusterSetId := os.Args[3]
20+
21+
j := janitor.NewDefaultJanitor(clusterId, clusterSetId)
1922
j.Cleanup(context.TODO(), nsName)
2023
}

integration/kind-test/configs/e2e-clusterId.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

integration/kind-test/configs/e2e-clusterSetId.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: about.k8s.io/v1alpha1
2+
kind: ClusterProperty
3+
metadata:
4+
name: id.k8s.io
5+
spec:
6+
value: kind-e2e-clusterid-1
7+
---
8+
apiVersion: about.k8s.io/v1alpha1
9+
kind: ClusterProperty
10+
metadata:
11+
name: clusterset.k8s.io
12+
spec:
13+
value: kind-e2e-clustersetid-1

integration/kind-test/scripts/common.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export ENDPT_PORT=80
1111
export SERVICE_PORT=8080
1212
export KIND_SHORT='cloud-map-e2e'
1313
export CLUSTER='kind-cloud-map-e2e'
14+
export CLUSTERID1='kind-e2e-clusterid-1'
15+
export CLUSTERSETID1='kind-e2e-clustersetid-1'
1416
export IMAGE='kindest/node:v1.20.15@sha256:a6ce604504db064c5e25921c6c0fffea64507109a1f2a512b1b562ac37d652f3'
1517
export EXPECTED_ENDPOINT_COUNT=5
1618
export UPDATED_ENDPOINT_COUNT=6

0 commit comments

Comments
 (0)