-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change default trigger consumergroup name and provide override #3033
Merged
knative-prow
merged 9 commits into
knative-extensions:main
from
hadriansecurity:feat/consumergroup-name
Apr 20, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0998f80
Change default consumergroup name to `knative-trigger-{{ .Namespace }…
EndPositive 418226d
Add consumergroup override in trigger/v2
EndPositive 630228a
Fix tests
EndPositive 111c527
Fix triggerv2 tests
EndPositive 45dd23d
Add triggerv2 test for reusing old consumergroup
EndPositive 6268b02
Add copyright notice
EndPositive 9db1b29
Get rid of unused err
EndPositive 0faf645
Update `getKafkaTriggerConsumerGroup` to use new group id annotation
EndPositive e0eed9e
Add kafka feature flag to namespaced trigger
EndPositive File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright 2023 The Knative Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package kafka | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Shopify/sarama" | ||
|
||
kafkatesting "knative.dev/eventing-kafka-broker/control-plane/pkg/kafka/testing" | ||
) | ||
|
||
func TestNewClusterAdminClientFuncIsConsumerGroupPresent(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
clusterAdmin sarama.ClusterAdmin | ||
consumerGroups []string | ||
want bool | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "consumergroup does not exist", | ||
clusterAdmin: &kafkatesting.MockKafkaClusterAdmin{ | ||
ExpectedConsumerGroups: []string{"consumer-group-name-1"}, | ||
ExpectedGroupDescriptionOnDescribeConsumerGroups: []*sarama.GroupDescription{ | ||
{ | ||
GroupId: "consumer-group-name-1", | ||
State: "Dead", | ||
}, | ||
}, | ||
T: t, | ||
}, | ||
consumerGroups: []string{"consumer-group-name-1"}, | ||
want: false, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "consumergroup exists (empty)", | ||
clusterAdmin: &kafkatesting.MockKafkaClusterAdmin{ | ||
ExpectedConsumerGroups: []string{"consumer-group-name-1"}, | ||
ExpectedGroupDescriptionOnDescribeConsumerGroups: []*sarama.GroupDescription{ | ||
{ | ||
GroupId: "consumer-group-name-1", | ||
State: "Empty", | ||
}, | ||
}, | ||
T: t, | ||
}, | ||
consumerGroups: []string{"consumer-group-name-1"}, | ||
want: true, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "consumergroup exists (Stable)", | ||
clusterAdmin: &kafkatesting.MockKafkaClusterAdmin{ | ||
ExpectedConsumerGroups: []string{"consumer-group-name-1"}, | ||
ExpectedGroupDescriptionOnDescribeConsumerGroups: []*sarama.GroupDescription{ | ||
{ | ||
GroupId: "consumer-group-name-1", | ||
State: "Stable", | ||
}, | ||
}, | ||
T: t, | ||
}, | ||
consumerGroups: []string{"consumer-group-name-1"}, | ||
want: true, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := AreConsumerGroupsPresentAndValid(tt.clusterAdmin, tt.consumerGroups...) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("AreConsumerGroupsPresentAndValid() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("AreConsumerGroupsPresentAndValid() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to include the UID as suffix by default?
The reason being that it will allow users replaying events by deleting/recreating, since the trigger is almost fully mutable deleting/recreating wouldn't be necessary for anything other than replaying events while also providing a well known group id prefix for monitoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the comment on the issue:
it's not clear on why the need for recreating the trigger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is just a matter of preference. If somehow our CD would recreate the trigger, we want to keep the original consumergroup. Such a name would be very safe for whenever k8s resources are destroyed.
I think for "complex" use cases like these, we should let the user manually reset offsets, or perhaps create a new trigger with a different name for replay purposes.
But either is fine by me, since we can override the configuration for our preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
Thanks appreciate the additional thought