From d193d6ea272ac10d0563218ad2cd4ad5211d1d0d Mon Sep 17 00:00:00 2001 From: Jason Goodsell Date: Tue, 3 Sep 2019 14:28:43 +1000 Subject: [PATCH 1/6] Increase minimum partition count to 2. --- api/v1/eventhub_types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1/eventhub_types.go b/api/v1/eventhub_types.go index 38ee415adb2..b7f1f46680f 100644 --- a/api/v1/eventhub_types.go +++ b/api/v1/eventhub_types.go @@ -108,8 +108,8 @@ type EventhubProperties struct { // MessageRetentionInDays - Number of days to retain the events for this Event Hub, value should be 1 to 7 days MessageRetentionInDays int32 `json:"messageRetentionInDays,omitempty"` // +kubebuilder:validation:Maximum=32 - // +kubebuilder:validation:Minimum=1 - // PartitionCount - Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. + // +kubebuilder:validation:Minimum=2 + // PartitionCount - Number of partitions created for the Event Hub, allowed values are from 2 to 32 partitions. PartitionCount int32 `json:"partitionCount,omitempty"` // CaptureDescription - Details specifying EventHub capture to persistent storage CaptureDescription CaptureDescription `json:"captureDescription,omitempty"` From 2ff935530e970e431042710307173abd559f4c65 Mon Sep 17 00:00:00 2001 From: Jason Goodsell Date: Tue, 3 Sep 2019 14:28:55 +1000 Subject: [PATCH 2/6] Updated the CRD. --- .../bases/azure.microsoft.com_eventhubs.yaml | 4 +- config/rbac/role.yaml | 94 +++++++++---------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/config/crd/bases/azure.microsoft.com_eventhubs.yaml b/config/crd/bases/azure.microsoft.com_eventhubs.yaml index d0e81392815..56d21d89700 100644 --- a/config/crd/bases/azure.microsoft.com_eventhubs.yaml +++ b/config/crd/bases/azure.microsoft.com_eventhubs.yaml @@ -491,10 +491,10 @@ spec: type: integer partitionCount: description: PartitionCount - Number of partitions created for the - Event Hub, allowed values are from 1 to 32 partitions. + Event Hub, allowed values are from 2 to 32 partitions. format: int32 maximum: 32 - minimum: 1 + minimum: 2 type: integer type: object resourceGroup: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 3ce5e03273b..81dbe7a73ba 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -6,10 +6,18 @@ metadata: creationTimestamp: null name: manager-role rules: +- apiGroups: + - apps + resources: + - deployments/status + verbs: + - get + - patch + - update - apiGroups: - azure.microsoft.com resources: - - cosmosdbs + - resourcegroups verbs: - create - delete @@ -21,7 +29,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - eventhubnamespaces/status + - storages/status verbs: - get - patch @@ -36,19 +44,22 @@ rules: - apiGroups: - azure.microsoft.com resources: - - consumergroups + - resourcegroups/status verbs: - - create - - delete - get - - list - patch - update +- apiGroups: + - "" + resources: + - events + verbs: + - create - watch - apiGroups: - azure.microsoft.com resources: - - consumergroups/status + - eventhubs/status verbs: - get - patch @@ -56,7 +67,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - resourcegroups + - eventhubnamespaces verbs: - create - delete @@ -68,19 +79,15 @@ rules: - apiGroups: - azure.microsoft.com resources: - - storages + - eventhubnamespaces/status verbs: - - create - - delete - get - - list - patch - update - - watch - apiGroups: - - "" + - azure.microsoft.com resources: - - secrets + - keyvaults verbs: - create - delete @@ -90,17 +97,21 @@ rules: - update - watch - apiGroups: - - azure.microsoft.com + - "" resources: - - eventhubs/status + - secrets verbs: + - create + - delete - get + - list - patch - update + - watch - apiGroups: - - azure.microsoft.com + - apps resources: - - eventhubnamespaces + - deployments verbs: - create - delete @@ -112,7 +123,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - keyvaults + - consumergroups verbs: - create - delete @@ -124,30 +135,31 @@ rules: - apiGroups: - azure.microsoft.com resources: - - rediscaches/status + - cosmosdbs verbs: + - create + - delete - get + - list - patch - update -- apiGroups: - - "" - resources: - - events - verbs: - - create - watch - apiGroups: - azure.microsoft.com resources: - - cosmosdbs/status + - eventhubs verbs: + - create + - delete - get + - list - patch - update + - watch - apiGroups: - azure.microsoft.com resources: - - eventhubs + - rediscaches verbs: - create - delete @@ -159,7 +171,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - keyvaults/status + - rediscaches/status verbs: - get - patch @@ -167,7 +179,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - rediscaches + - storages verbs: - create - delete @@ -179,7 +191,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - resourcegroups/status + - consumergroups/status verbs: - get - patch @@ -187,27 +199,15 @@ rules: - apiGroups: - azure.microsoft.com resources: - - storages/status - verbs: - - get - - patch - - update -- apiGroups: - - apps - resources: - - deployments + - cosmosdbs/status verbs: - - create - - delete - get - - list - patch - update - - watch - apiGroups: - - apps + - azure.microsoft.com resources: - - deployments/status + - keyvaults/status verbs: - get - patch From 9cb063b540663d0afa3f878d57a6ed8efbbd209b Mon Sep 17 00:00:00 2001 From: Jason Goodsell Date: Tue, 3 Sep 2019 14:29:08 +1000 Subject: [PATCH 3/6] Updated eventhub example. --- config/samples/azure_v1_eventhub.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/samples/azure_v1_eventhub.yaml b/config/samples/azure_v1_eventhub.yaml index 1ee879a9318..024a12c121e 100644 --- a/config/samples/azure_v1_eventhub.yaml +++ b/config/samples/azure_v1_eventhub.yaml @@ -8,7 +8,7 @@ spec: namespace: "eventhubnamespace-sample-6" properties: messageRetentionInDays: 7 - partitionCount: 1 + partitionCount: 2 authorizationRule: name : "RootManageSharedAccessKey" rights: From cd6e25ff7f32316e60393aa46360061bf34ab4e8 Mon Sep 17 00:00:00 2001 From: Jason Goodsell Date: Tue, 3 Sep 2019 14:29:20 +1000 Subject: [PATCH 4/6] Changed resource group example. --- config/samples/azure_v1_resourcegroup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/samples/azure_v1_resourcegroup.yaml b/config/samples/azure_v1_resourcegroup.yaml index 1f2009eaec1..fe67d8499f0 100644 --- a/config/samples/azure_v1_resourcegroup.yaml +++ b/config/samples/azure_v1_resourcegroup.yaml @@ -1,6 +1,6 @@ apiVersion: azure.microsoft.com/v1 kind: ResourceGroup metadata: - name: resourcegroup-sample-1908 + name: resourcegroup-sample-1907 spec: location: "westus" From 6df998eb1d8a2efdf26a3c1b353e3dfcfebf0a30 Mon Sep 17 00:00:00 2001 From: Jason Goodsell Date: Tue, 3 Sep 2019 14:37:24 +1000 Subject: [PATCH 5/6] Increased test partition count to 2. --- api/v1/eventhub_types_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/eventhub_types_test.go b/api/v1/eventhub_types_test.go index 950ef45ac26..09db200b33b 100644 --- a/api/v1/eventhub_types_test.go +++ b/api/v1/eventhub_types_test.go @@ -53,7 +53,7 @@ var _ = Describe("Eventhub", func() { ResourceGroup: "foo-resource-group", Properties: EventhubProperties{ MessageRetentionInDays: 7, - PartitionCount: 1, + PartitionCount: 2, CaptureDescription: captureDescription, }, }, From 795941a9356dc9f8130c2a0eb70ef5b55277466e Mon Sep 17 00:00:00 2001 From: Jason Goodsell Date: Tue, 3 Sep 2019 14:50:10 +1000 Subject: [PATCH 6/6] Updated tests. --- config/rbac/role.yaml | 104 +++++++++--------- config/samples/azure_v1_eventhub_capture.yaml | 2 +- controllers/eventhub_controller_test.go | 8 +- .../eventhubs/consumergroup_test.go | 2 +- pkg/resourcemanager/eventhubs/hub.go | 4 +- pkg/resourcemanager/eventhubs/hub_test.go | 2 +- 6 files changed, 61 insertions(+), 61 deletions(-) diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 81dbe7a73ba..1eb76d14de5 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -6,18 +6,10 @@ metadata: creationTimestamp: null name: manager-role rules: -- apiGroups: - - apps - resources: - - deployments/status - verbs: - - get - - patch - - update - apiGroups: - azure.microsoft.com resources: - - resourcegroups + - storages verbs: - create - delete @@ -26,14 +18,6 @@ rules: - patch - update - watch -- apiGroups: - - azure.microsoft.com - resources: - - storages/status - verbs: - - get - - patch - - update - apiGroups: - azure.microsoft.com resources: @@ -44,30 +28,43 @@ rules: - apiGroups: - azure.microsoft.com resources: - - resourcegroups/status + - cosmosdbs verbs: + - create + - delete - get + - list - patch - update + - watch - apiGroups: - - "" + - azure.microsoft.com resources: - - events + - eventhubs verbs: - create + - delete + - get + - list + - patch + - update - watch - apiGroups: - azure.microsoft.com resources: - - eventhubs/status + - eventhubnamespaces verbs: + - create + - delete - get + - list - patch - update + - watch - apiGroups: - azure.microsoft.com resources: - - eventhubnamespaces + - rediscaches verbs: - create - delete @@ -79,7 +76,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - eventhubnamespaces/status + - rediscaches/status verbs: - get - patch @@ -87,7 +84,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - keyvaults + - resourcegroups verbs: - create - delete @@ -99,55 +96,54 @@ rules: - apiGroups: - "" resources: - - secrets + - events verbs: - create - - delete + - watch +- apiGroups: + - apps + resources: + - deployments/status + verbs: - get - - list - patch - update - - watch - apiGroups: - - apps + - azure.microsoft.com resources: - - deployments + - consumergroups/status verbs: - - create - - delete - get - - list - patch - update - - watch - apiGroups: - azure.microsoft.com resources: - - consumergroups + - cosmosdbs/status verbs: - - create - - delete - get - - list - patch - update - - watch - apiGroups: - azure.microsoft.com resources: - - cosmosdbs + - eventhubs/status verbs: - - create - - delete - get - - list - patch - update - - watch - apiGroups: - azure.microsoft.com resources: - - eventhubs + - eventhubnamespaces/status + verbs: + - get + - patch + - update +- apiGroups: + - "" + resources: + - secrets verbs: - create - delete @@ -157,9 +153,9 @@ rules: - update - watch - apiGroups: - - azure.microsoft.com + - apps resources: - - rediscaches + - deployments verbs: - create - delete @@ -171,15 +167,19 @@ rules: - apiGroups: - azure.microsoft.com resources: - - rediscaches/status + - consumergroups verbs: + - create + - delete - get + - list - patch - update + - watch - apiGroups: - azure.microsoft.com resources: - - storages + - keyvaults verbs: - create - delete @@ -191,7 +191,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - consumergroups/status + - keyvaults/status verbs: - get - patch @@ -199,7 +199,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - cosmosdbs/status + - resourcegroups/status verbs: - get - patch @@ -207,7 +207,7 @@ rules: - apiGroups: - azure.microsoft.com resources: - - keyvaults/status + - storages/status verbs: - get - patch diff --git a/config/samples/azure_v1_eventhub_capture.yaml b/config/samples/azure_v1_eventhub_capture.yaml index ee38ccb4613..a074c643e2e 100644 --- a/config/samples/azure_v1_eventhub_capture.yaml +++ b/config/samples/azure_v1_eventhub_capture.yaml @@ -8,7 +8,7 @@ spec: namespace: "eventhubnamespace-sample-6" properties: messageRetentionInDays: 7 - partitionCount: 1 + partitionCount: 2 captureDescription: # Note that the storage account and blob container below must already exist destination: diff --git a/controllers/eventhub_controller_test.go b/controllers/eventhub_controller_test.go index 9e9d69970c5..23c6015f09d 100644 --- a/controllers/eventhub_controller_test.go +++ b/controllers/eventhub_controller_test.go @@ -77,7 +77,7 @@ var _ = Describe("EventHub Controller", func() { ResourceGroup: "t-rg-dev-eh-" + helpers.RandomString(10), Properties: azurev1.EventhubProperties{ MessageRetentionInDays: 7, - PartitionCount: 1, + PartitionCount: 2, }, }, } @@ -111,7 +111,7 @@ var _ = Describe("EventHub Controller", func() { ResourceGroup: rgName, Properties: azurev1.EventhubProperties{ MessageRetentionInDays: 7, - PartitionCount: 1, + PartitionCount: 2, }, AuthorizationRule: azurev1.EventhubAuthorizationRule{ Name: "RootManageSharedAccessKey", @@ -198,7 +198,7 @@ var _ = Describe("EventHub Controller", func() { ResourceGroup: rgName, Properties: azurev1.EventhubProperties{ MessageRetentionInDays: 7, - PartitionCount: 1, + PartitionCount: 2, }, AuthorizationRule: azurev1.EventhubAuthorizationRule{ Name: "RootManageSharedAccessKey", @@ -290,7 +290,7 @@ var _ = Describe("EventHub Controller", func() { ResourceGroup: rgName, Properties: azurev1.EventhubProperties{ MessageRetentionInDays: 7, - PartitionCount: 1, + PartitionCount: 2, CaptureDescription: azurev1.CaptureDescription{ Destination: azurev1.Destination{ ArchiveNameFormat: "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", diff --git a/pkg/resourcemanager/eventhubs/consumergroup_test.go b/pkg/resourcemanager/eventhubs/consumergroup_test.go index 4845daf895b..273ec290433 100644 --- a/pkg/resourcemanager/eventhubs/consumergroup_test.go +++ b/pkg/resourcemanager/eventhubs/consumergroup_test.go @@ -42,7 +42,7 @@ var _ = Describe("ConsumerGroup", func() { namespaceLocation = resourcegroupLocation eventhubName = "t-eh-dev-ehs-" + helpers.RandomString(10) messageRetentionInDays = int32(7) - partitionCount = int32(1) + partitionCount = int32(2) _, _ = CreateNamespaceAndWait(context.Background(), rgName, eventhubNamespaceName, namespaceLocation) _, _ = CreateHub(context.Background(), rgName, eventhubNamespaceName, eventhubName, messageRetentionInDays, partitionCount, nil) diff --git a/pkg/resourcemanager/eventhubs/hub.go b/pkg/resourcemanager/eventhubs/hub.go index 7306ee180a9..721ec15c910 100644 --- a/pkg/resourcemanager/eventhubs/hub.go +++ b/pkg/resourcemanager/eventhubs/hub.go @@ -46,8 +46,8 @@ func CreateHub(ctx context.Context, resourceGroupName string, namespaceName stri return eventhub.Model{}, fmt.Errorf("MessageRetentionInDays is invalid") } - // PartitionCount - Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - if PartitionCount < 1 || PartitionCount > 32 { + // PartitionCount - Number of partitions created for the Event Hub, allowed values are from 2 to 32 partitions. + if PartitionCount < 2 || PartitionCount > 32 { return eventhub.Model{}, fmt.Errorf("PartitionCount is invalid") } diff --git a/pkg/resourcemanager/eventhubs/hub_test.go b/pkg/resourcemanager/eventhubs/hub_test.go index 2acae8cb23a..0edbd8df805 100644 --- a/pkg/resourcemanager/eventhubs/hub_test.go +++ b/pkg/resourcemanager/eventhubs/hub_test.go @@ -57,7 +57,7 @@ var _ = Describe("Eventhub", func() { eventhubName := "t-eh-" + helpers.RandomString(10) messageRetentionInDays := int32(7) - partitionCount := int32(1) + partitionCount := int32(2) var err error