Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Remove gpubsub in sources #1761

Merged
merged 8 commits into from Oct 5, 2020
Merged

Conversation

zhongduo
Copy link
Contributor

@zhongduo zhongduo commented Sep 22, 2020

Fixes #1739

Proposed Changes

Release Note


Docs

@google-cla google-cla bot added the cla: yes (override cla status due to multiple authors bug) label Sep 22, 2020
@zhongduo zhongduo changed the title WIP: Remove gpubsub in topic, mocking server errors is unavailable WIP: Remove gpubsub in sources Sep 24, 2020
@zhongduo
Copy link
Contributor Author

/assign @nachocano

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-google-knative-gcp-wi-tests 2020-09-28 19:49:25.2 +0000 UTC 1/3

Automatically retrying due to test flakiness...
/test pull-google-knative-gcp-wi-tests

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-google-knative-gcp-integration-tests 2020-09-28 19:49:25.2 +0000 UTC 1/3

Automatically retrying due to test flakiness...
/test pull-google-knative-gcp-integration-tests

Comment on lines 91 to 111
// If there is an error, the projectID will be empty. The reconciler will retry
// to get the projectID during reconciliation.
projectID, err := utils.ProjectID(os.Getenv(utils.ProjectIDEnvKey), metadataClient.NewDefaultMetadataClient())
if err != nil {
logging.FromContext(ctx).Error("Failed to get project ID", zap.Error(err))
}
// Attempt to create a pubsub client for all worker threads to use. If this
// fails, pass a nil value to the Reconciler. They will attempt to
// create a client on reconcile.
client, err := pubsub.NewDefaultPubsubClient(ctx, projectID)
if err != nil {
logging.FromContext(ctx).Error("Failed to create controller-wide Pub/Sub client", zap.Error(err))
}

if client != nil {
go func() {
<-ctx.Done()
client.Close()
}()
}

Copy link
Member

Choose a reason for hiding this comment

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

this will not apply to sources as we can specify the project in the CO spec.

Copy link
Member

Choose a reason for hiding this comment

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

the idea of having it in the spec was to support cross-project stuff.

Copy link
Member

Choose a reason for hiding this comment

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

either way, if you are doing this in the broker, if you cannot create a client here, might be better to fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After our conversation yesterday, I actually removed this too. See the latest code.

And yes, you are right about the failing the broker. There are some legacy code, I have discussed this with others and opened an issue to revisit whether we should fail it.

@zhongduo
Copy link
Contributor Author

zhongduo commented Oct 1, 2020

/test pull-google-knative-gcp-unit-tests

@zhongduo zhongduo changed the title WIP: Remove gpubsub in sources Remove gpubsub in sources Oct 1, 2020
Jimmy Lin added 8 commits October 3, 2020 10:49
Topic and PullSubscription reconcilers still use the gpubsub client, making their tests
different from the Broker and Trigger tests which use pstest. With this, error injection
is done by setting server option to the pubsub testing server. The reconcilers will use
google-cloud-go pubsub directly.
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-google-knative-gcp-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/intevents/topic/topic.go 68.4% 69.2% 0.9

@zhongduo
Copy link
Contributor Author

zhongduo commented Oct 5, 2020

/test pull-google-knative-gcp-integration-tests

@zhongduo
Copy link
Contributor Author

zhongduo commented Oct 5, 2020

/assign @capri-xiyue

@zhongduo
Copy link
Contributor Author

zhongduo commented Oct 5, 2020

/assign @Harwayne

@capri-xiyue
Copy link
Contributor

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: capri-xiyue, zhongduo

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [capri-xiyue,zhongduo]

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 merged commit a4cf4ad into google:master Oct 5, 2020
"k8s.io/client-go/tools/record"
)

// CreateFn is a factory function to create a Pub/Sub client. It is copied from gclient/pubsub
Copy link
Contributor

Choose a reason for hiding this comment

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

What is wrong with the dependency? Does it cause a cycle?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Jimmy is trying to remove the usage of gpubsub in source code and UT(which was written by ourselves) and change gpubsub to pubsub and pbtest(written by pubsub team)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved cla: yes (override cla status due to multiple authors bug) lgtm size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch Topic and PullSubscription to use normal pubsub client
7 participants