Skip to content
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

Support discoveryProperties in Configuration #619

Merged

Conversation

johnsonshih
Copy link
Contributor

@johnsonshih johnsonshih commented Jun 14, 2023

What this PR does / why we need it:

Discovery handlers need credential data for authenticated discovery. This PR allows users to specify credential data through discoveryProperties, Agent read the properties and pass them to discovery handlers.

This PR implements the proposal: project-akri/akri-docs#61
Special notes for your reviewer:

If applicable:

  • this PR has an associated PR with documentation in akri-docs
  • this PR contains unit tests
  • added code adheres to standard Rust formatting (cargo fmt)
  • code builds properly (cargo build)
  • code is free of common mistakes (cargo clippy)
  • all Akri tests succeed (cargo test)
  • inline documentation builds (cargo doc)
  • all commits pass the DCO bot check by being signed off -- see the failing DCO check for instructions on how to retroactively sign commits

@johnsonshih johnsonshih changed the title User/jshih/agent secret for dh pr new Support discoveryProperties in Configuration Jun 14, 2023
Copy link
Contributor

@diconico07 diconico07 left a comment

Choose a reason for hiding this comment

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

That's a nice feature here, the missing part is the validating webhook thing.

I also noticed you do the parameters gathering per discoveryEndpoints, it might be more efficient to do it only once at discoveryOperator's creation ?

@johnsonshih
Copy link
Contributor Author

I also noticed you do the parameters gathering per discoveryEndpoints, it might be more efficient to do it only once at discoveryOperator's creation ?

I thought about that but later changed to ready the secret information at the time establishing the endpoint connection. Reason:

  1. provide as much as up-to-date secret data, in case the secret data changed, this gives agent a chance to refresh the secret data.
  2. DiscoveryOperator is a long run entity, don't want to keep the secret data in memory for a long time.

@johnsonshih johnsonshih requested a review from diconico07 July 12, 2023 19:16
let discovery_properties = r#"
"discoveryProperties": [
{
"name": ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

curious, why this would be success case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't restrict empty name, as long as it's not None, we accept it (although it probably won't be used when DH query the secret data).

Copy link
Collaborator

Choose a reason for hiding this comment

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

seems strange to me to allow an empty name

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think an empty name should be an error, but won't block the PR based on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we treat empty name as error, should we treat name with all spaces as error, too? IMO, from syntax perspective, an empty string is a valid string and is valid as a key in key-value pair. We can allow it.
BTW, a null string for name is for sure not allowed, it's specified in the schema

Copy link
Collaborator

Choose a reason for hiding this comment

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

i dont think an empty string and a string with spaces are the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be in favor of specifying name in the same way it is defined in core EnvVar, that is as a C_IDENTIFIER (i.e a string conforming to this regex: [A-Za-z_][A-Za-z0-9_]* thus disallowing empty names and ensuring these discovery properties can be passed as environment variable if need arise.

I don't know if there is a way to translate that in the CRD or if we can only rely on the webhook to reject configurations that are in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, we can put pattern in the crd and not relies on webhook to validate the content. I'll investigate if we really want to make that hard restriction to the key name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filed Issue for the investigation effort.
#634

@johnsonshih johnsonshih requested a review from bfjelds July 20, 2023 19:43
@johnsonshih johnsonshih requested a review from bfjelds July 21, 2023 00:17
Copy link
Contributor

@diconico07 diconico07 left a comment

Choose a reason for hiding this comment

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

I won't block the PR for not triggering errors on empty names, but please create an issue for doing that later if you don't do it in this PR.

@johnsonshih johnsonshih merged commit cc14ba6 into project-akri:main Jul 22, 2023
@johnsonshih johnsonshih deleted the user/jshih/agent-secret-for-dh-pr-new branch July 22, 2023 03:57
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.

3 participants