Skip to content

[BEAM-454] Validate Pubsub Topic exists when reading and writing#2989

Closed
hepeknet wants to merge 1 commit intoapache:masterfrom
hepeknet:BEAM-454
Closed

[BEAM-454] Validate Pubsub Topic exists when reading and writing#2989
hepeknet wants to merge 1 commit intoapache:masterfrom
hepeknet:BEAM-454

Conversation

@hepeknet
Copy link

@hepeknet hepeknet commented May 9, 2017

Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

  • Make sure the PR title is formatted like:
    [BEAM-454>] Description of pull request
  • Make sure tests pass via mvn clean verify.
  • Replace <Jira issue #> in the title with the actual Jira issue
    number, if there is one.
  • If this contribution is large, please file an Apache
    Individual Contributor License Agreement.

@francesperry does this look ok? Let me know

@lukecwik
Copy link
Member

R: @francesperry

@francesperry
Copy link
Member

R: @tgroh
I think this may interact badly with the ValueProviders -- we can't validate before we have the final value. Thomas, I think you are more familiar with this process. Can you take a look?

Copy link
Member

@tgroh tgroh left a comment

Choose a reason for hiding this comment

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

For a non-template Pipeline, the ValueProvider should have the option associated with it at the time validate is called (I don't believe it currently does, but should). For a templated Pipeline, there may not be an accessible value, which means that we may also wish to gate the validation calls on isAccessible as well. I think we'll properly fail at validation time for more pipelines if that's done, even if we still let some through that end up failing at runtime.

I have a few additional changes in the meantime.

} catch (IOException ie) {
throw new RuntimeException("Was not able to validate options: ", ie);
} finally {
pubsubClient.close();
Copy link
Member

Choose a reason for hiding this comment

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

Closing the client here seems improper.

+ " execution. If the %1$s is created by an earlier stage of the pipeline, this"
+ " validation can be disabled using #withoutValidation.";

static void validateTopicExists(PubsubClient pubsubClient, String projectId, String topicName)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is a hugely useful wrapper, given that we can just call the underlying method and have a precise (based on call location) message

if (topicName == null) {
throw new IllegalArgumentException("topicName must not be null");
}
boolean topicExists = listTopics(projectPathFromId(projectId))
Copy link
Member

Choose a reason for hiding this comment

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

This may be expensive; I believe it would be better to use the getTopic API exposed by the PubSub publisher interface (ref. https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#google.pubsub.v1.Publisher.GetTopic)

@davorbonaci
Copy link
Member

Any updates on this PR perhaps?

@jkff jkff closed this Dec 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants