-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: add REST /metadata path to display KSQL server information (replaces /info) #3313
Conversation
d221d97
to
4a4a6ac
Compare
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.
Thanks @spena
LGTM, with a few nits...
It would be good to add something to RestApiTest
to test this new end point end-to-end
Also, a SecureIntegerationTest
to ensure you don't need to authenticate to access it, maybe?
Finally, can you create a Github issue to remove the old /info
URL, mark it for milestone 6.0, i.e. our next breaking change, and then include the PR number in your description please?
@@ -189,10 +196,25 @@ public static String getCommandsStreamName() { | |||
requireNonNull(rocksDBConfigSetterHandler, "rocksDBConfigSetterHandler"); | |||
} | |||
|
|||
private static KsqlRestConfig injectRestConfigDefaults(final KsqlRestConfig restConfig) { |
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.
nit: private to the bottom of the file
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.
done
); | ||
|
||
// REST paths that are public and do not require authentication | ||
restConfigs.put(RestConfig.AUTHENTICATION_SKIP_PATHS, |
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.
could this not potentially be overwriting a config a user has set?
Should we not be adding to the existing setting, rather than overwriting?
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.
done
restConfigs.put(RestConfig.AUTHENTICATION_SKIP_PATHS, | ||
Joiner.on(",").join(authenticationSkipPaths)); | ||
|
||
return new KsqlRestConfig(restConfigs); |
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.
Rather than adjusting the supplied KsqlConfig
, is there some reason you can't add the RestConfig.AUTHENTICATION_SKIP_PATHS
when building the original KsqlConfig
in KsqlRestApplication.buildApplication
?
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 could, but the KsqlConfig
is built from the below line that does not include the RestConfig
properties:
final KsqlConfig ksqlConfig = new KsqlConfig(restConfig.getKsqlConfigProperties());
And the KsqlRestApplication
constructor passes the KsqlRestConfig
to the parent class, no the KsqlConfig
. So I had to overwrite the KsqlRestConfig
instead. I'm not sure why we have two different configurations, btw. Do you think we should join KsqlConfig
and KsqlRetsConfig
into one?
@@ -52,4 +63,8 @@ public void filter(final ContainerRequestContext requestContext) { | |||
requestContext.abortWith(Errors.accessDenied(t.getMessage())); | |||
} | |||
} | |||
|
|||
private boolean requiresAuthorization(final String path) { | |||
return !UNAUTHORIZED_ENDPOINTS.contains(path); |
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.
Are we case sensitive on paths? Not sure. if not, then this should also not be case sensitive.
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.
Yes, we are case sensitive.
@@ -32,6 +34,11 @@ | |||
public class KsqlAuthorizationFilter implements ContainerRequestFilter { | |||
private static final Logger log = LoggerFactory.getLogger(KsqlAuthorizationFilter.class); | |||
|
|||
private static final Set<String> UNAUTHORIZED_ENDPOINTS = ImmutableSet.of( | |||
"/metadata", |
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 be good to pick these up from constants in ServerMetadataResource
...
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.
done
private static final String KAFKA_CLUSTER = "kafka-cluster"; | ||
private static final String KSQL_CLUSTER = "ksql-cluster"; | ||
|
||
@JsonProperty("id") |
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.
nit: unnecessary, given there is a getId
method
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.
done
@JsonProperty("id") | ||
private final String id; | ||
|
||
@JsonProperty("scope") |
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.
Why is there no getter for this field?
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.
Added one
@JsonProperty("version") final String version, | ||
@JsonProperty("clusterId") final ServerClusterId clusterId | ||
) { | ||
this.version = version; |
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.
nit: null checks.
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.
done
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class ServerMetadataTest { |
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.
need same test for ServerClusterId
.
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.
done
// Given: | ||
final ServerMetadata expected = new ServerMetadata( | ||
"1.0.0", | ||
ServerClusterId.of("kafka1", "ksql1") |
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.
Use a mock for ServerClusterId
in this test means this test is not dependant on ServerClusterId
impl. This test would then only be testing this class, which is a good thing.
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.
done
4a4a6ac
to
010b122
Compare
010b122
to
385e1fe
Compare
Thanks @big-andy-coates for the review. |
Description
This new path (
/metadata
) will replace the/info
path in the next KSQL major release. It is added to have a standard API between Confluent components that show information about the current cluster.For now, this path displays the following:
Follow-up PRs:
/metadata
instead of/info
from the KSQL CLI/info
path in KSQL 6.x (pending Issue)Testing done
Reviewer checklist