Skip to content

Generate unique, stable pubsub topic and subscription IDs#458

Closed
scothis wants to merge 1 commit into
knative:masterfrom
scothis:pubsub-names
Closed

Generate unique, stable pubsub topic and subscription IDs#458
scothis wants to merge 1 commit into
knative:masterfrom
scothis:pubsub-names

Conversation

@scothis
Copy link
Copy Markdown
Contributor

@scothis scothis commented Sep 21, 2018

With the gcppubsub bus it was possible to create conflicting topics and
subscription if two (or more) clusters used the same Bus, Channel and
Subscription names. This would result in the misdelivery of messages
between the clusters.

Now the UID of the Bus/ClusterBus that owns the topic/subscription is a
factor in the identifier. The Bus UID will be stable durring The
lifetime of the Bus, but unique between individual resources.

Fixes #253

Release Note

NONE

With the gcppubsub bus it was possible to create conflicting topics and
subscription if two (or more) clusters used the same Bus, Channel and
Subscription names. This would result in the misdelivery of messages
between the clusters.

Now the UID of the Bus/ClusterBus that owns the topic/subscription is a
factor in the identifier. The Bus UID will be stable durring The
lifetime of the Bus, but unique between individual resources.

Fixes knative#253
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: scothis

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 21, 2018
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 21, 2018
}

bus := &CloudPubSubBus{
ref: ref,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is ref in this context? It looks like it is being passed in but I would assume a ref to a bus would point to the object that is being created with &CloudPubSubBus{...}


func (b *CloudPubSubBus) topicID(channel buses.ChannelReference) string {
return fmt.Sprintf("channel-%s-%s-%s", b.ref.Name, channel.Namespace, channel.Name)
return fmt.Sprintf("channel-%s-%s-%s", channel.Namespace, channel.Name, b.id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it intended to flip the order of this? it use to be general bus to specific channel.

os.Getenv("BUS_NAME"),
os.Getenv("BUS_NAMESPACE"),
)
busUID := os.Getenv("BUS_UID")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if there is no BUS_UID?


// busId generates a short unique identifier for a bus from the Bus's UID.
// This value is used as a component of the topic and subscription IDs
func busId(uid string) string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no test added for this method. Please add a test to make sure this does not make the same busID for similar UIDs


// busId generates a short unique identifier for a bus from the Bus's UID.
// This value is used as a component of the topic and subscription IDs
func busId(uid string) string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In go style, busId should be busID


bus := &CloudPubSubBus{
ref: ref,
id: busId(busUID),
Copy link
Copy Markdown
Contributor

@n3wscott n3wscott Sep 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than storing the id like this I wonder if it might be cleaner to set a topic prefix field that is generated from the id and our special strings (like channel- and then topicID becomes

func (b *CloudPubSubBus) topicID(channel buses.ChannelReference) string {
	return fmt.Sprintf("%s-%s-%s", b.topicPrefix, channel.Namespace, channel.Name)
}

And then we are free to change how we generate that prefix, and the code does not have to change each time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we should store the generated UID in the status so we can recover it in the future.

Additionally, storing the topic ID means that we don't get thrown off later if we change the busID function.

Since this is the old Bus code, it's probably not worth updating the status to support this, but we should probably include a runtime.RawExtension in the status of the new Channel to support recording controller choices like this.

@matzew
Copy link
Copy Markdown
Member

matzew commented Nov 7, 2018

@scothis I think this should be closed; all files that are touched in this PR got nuked 🔥

@matzew
Copy link
Copy Markdown
Member

matzew commented Nov 19, 2018

/close

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@matzew: Closing this PR.

Details

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

matzew added a commit to matzew/eventing that referenced this pull request Mar 2, 2020
Leo6Leo pushed a commit to Leo6Leo/eventing that referenced this pull request Jan 17, 2024
…knative#458)

* Fix reporting index of the failed step

The warning had a wrong index:
{"level":"info","ts":"2023-11-13T14:00:03.816770975Z","caller":"sender/services.go:207","msg":"Sending
step event #16691 to
\"http://sut-kn-channel.eventing-e2e0.svc.cluster.local\""}
{"level":"warn","ts":"2023-11-13T14:00:03.821102525Z","caller":"sender/services.go:102","msg":"Could
not send step event 16690, retrying (1): Post
\"http://sut-kn-channel.eventing-e2e0.svc.cluster.local\": dial tcp
172.30.99.91:80: connect: connection refused"}

* Upgrade tests account for last event being interrupted

Co-authored-by: Martin Gencur <mgencur@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants