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

feat: schema awareness (+fixed root logger) #444

Merged
merged 3 commits into from
Mar 20, 2024
Merged

Conversation

dotansimha
Copy link
Member

@dotansimha dotansimha commented Feb 14, 2024

Closes #437
Closes #436

TODO

  • Generic schema awareness with the ability to process the parsed schema
  • Load from inline
  • Load from file
  • Load from remote (+headers, method)
  • Polling in background (for non-wasm)
  • Better logging and error handling
  • Fed source adjustments
  • also support loading from introspection
  • Validate incoming GraphQL operations when schema awareness is available
  • wasm
  • smoke tests
  • docs/website

@dotansimha dotansimha changed the title ok wip: schema awareness Feb 14, 2024
Copy link

github-actions bot commented Feb 14, 2024

🚨 Rust Panic Audit: 102 Potential Panic Points Detected 🚨

Crate: federation_query_planner

📊 Total Usages: 53

  • 🔢 array_index usages: 10
  • 🚨 panic usages: 3
  • 🎁 unwrap usages: 32
  • 🔎 expect usages: 8

Crate: common

📊 Total Usages: 11

  • 🎁 unwrap usages: 10
  • 🔢 array_index usages: 1

Crate: telemetry

📊 Total Usages: 9

  • 🔢 array_index usages: 5
  • 🎁 unwrap usages: 4

Crate: cloudflare_worker

📊 Total Usages: 8

  • 🚨 panic usages: 1
  • 🔎 expect usages: 2
  • 🎁 unwrap usages: 5

Crate: engine

📊 Total Usages: 7

  • 🎁 unwrap usages: 6
  • 🔎 expect usages: 1

Crate: tracing

📊 Total Usages: 6

  • 🔎 expect usages: 1
  • 🎁 unwrap usages: 5

Crate: conductor

📊 Total Usages: 5

  • 🔎 expect usages: 3
  • 🚨 panic usages: 1
  • 🎁 unwrap usages: 1

Crate: config

📊 Total Usages: 3

  • 🚨 panic usages: 1
  • 🎁 unwrap usages: 2

📌 Expected Annotations

Crate: common

📊 Total Expected Usages: 1

expand details
  1. Reason: "we're parsing a statically defined constant, we know it works ;)"
  • Code: .unwrap()
  • Location: ./libs/common/src/graphql.rs:31

Crate: cloudflare_worker

📊 Total Expected Usages: 4

expand details
  1. Reason: "it panics only if the header name is not valid, and we know it is."
  • Code: .unwrap()
  • Location: ./bin/cloudflare_worker/src/http_tracing.rs:20
  1. Reason: "it panics only if the URL source is not valid, and it's already validated before."
  • Code: let url = req.url().unwrap();
  • Location: ./bin/cloudflare_worker/src/http_tracing.rs:23
  1. Reason: "it only panics if we are not running in a CF context, should be safe."
  • Code: let cf_info = req.cf().unwrap();
  • Location: ./bin/cloudflare_worker/src/http_tracing.rs:27
  1. Reason: "unwraps only in special cases where "data:text" is used."
  • Code: let http_host = url.host().unwrap().to_string();
  • Location: ./bin/cloudflare_worker/src/http_tracing.rs:36

Crate: jwt_auth

📊 Total Expected Usages: 1

expand details
  1. Reason: "if initiating an http client fails, then we have to exit."
  • Code: let client = wasm_polyfills::create_http_client().build().unwrap();
  • Location: ./plugins/jwt_auth/src/jwks_provider.rs:49

Crate: vrl

📊 Total Expected Usages: 2

expand details
  1. Reason: "if the provided VRL code in the config file can't compile, we have to exit."
  • Code: panic!("failed to compile vrl program");
  • Location: ./plugins/vrl/src/plugin.rs:129
  1. Reason: "states is a non-user provided variable"
  • Code: .expect("can't merge states when states is an empty vector!")
  • Location: ./plugins/vrl/src/plugin.rs:146

Crate: config

📊 Total Expected Usages: 9

expand details
  1. Reason: "👇"
  • Code: let raw_contents = read_to_string(file_path)
  • Location: ./libs/config/src/lib.rs:815
  1. Reason: "👇"
  • Code: panic!("Failed to interpolate config file, please resolve the above errors");
  • Location: ./libs/config/src/lib.rs:847
  1. Reason: "👇"
  • Code: parse_config_from_json(&config_string).expect("Failed to parse JSON config file")
  • Location: ./libs/config/src/lib.rs:854
  1. Reason: "👇"
  • Code: parse_config_from_yaml(&config_string).expect("Failed to parse YAML config file")
  • Location: ./libs/config/src/lib.rs:858
  1. Reason: "👇"
  • Code: _ => panic!("Unsupported config file extension"),
  • Location: ./libs/config/src/lib.rs:875
  1. Reason: "👇"
  • Code: None => panic!("Config file has no extension"),
  • Location: ./libs/config/src/lib.rs:878
  1. Reason: "statically defined regex pattern, we know it works ;)"
  • Code: .unwrap();
  • Location: ./libs/config/src/interpolate.rs:18
  1. Reason: "part of development docgen CLI"
  • Code: .expect("Failed to serialize json schema for config file!");
  • Location: ./libs/config/src/generate-json-schema.rs:50
  1. Reason: "part of development docgen CLI"
  • Code: .expect("Failed to write the json schema to the file system!");
  • Location: ./libs/config/src/generate-json-schema.rs:54

Crate: engine

📊 Total Expected Usages: 2

expand details
  1. Reason: "if we are unable to construct the endpoints and attach them onto the gateway's http server, we have to exit"
  • Code: Err(e) => panic!("failed to construct endpoint: {:?}", e),
  • Location: ./libs/engine/src/gateway.rs:158
  1. Reason: "we can safely index here, it's inside a test with constant defined fixtures."
  • Code: ConductorGateway::execute(request, &gw.routes[0].route_data).await
  • Location: ./libs/engine/src/gateway.rs:190

Crate: conductor

📊 Total Expected Usages: 2

expand details
  1. Reason: "we need to exit the process, if the logger can't be correctly set."
  • Code: let _guard = tracing::subscriber::set_default(subscriber);
  • Location: ./bin/conductor/src/lib.rs:37
  1. Reason: "we need to exit the process, if the provided configuration file is incorrect."
  • Code: panic!("Failed to initialize gateway: {:?}", e);
  • Location: ./bin/conductor/src/lib.rs:76

Crate: napi

📊 Total Expected Usages: 1

expand details
  1. Reason: "we need this"
  • Code: panic!("Exited process!")
  • Location: ./libs/napi/src/lib.rs:18

Copy link

github-actions bot commented Feb 14, 2024

💻 Website Preview

The latest changes are available as preview in: https://4b424e43.conductor-t2.pages.dev

Copy link

github-actions bot commented Feb 14, 2024

🐋 This PR was built and pushed to the following Docker images:

Docker Bake metadata
{
"conductor": {
  "buildx.build.ref": "builder-3b2bc2a9-e0dd-4caf-919d-ffcdde43ee83/builder-3b2bc2a9-e0dd-4caf-919d-ffcdde43ee830/1q38up292nmn3wuudpufkeb59",
  "containerimage.config.digest": "sha256:6f88a2c52713304cf88694b10b1501688d8cb9f76849b8390a40309450d8a462",
  "containerimage.descriptor": {
    "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
    "digest": "sha256:5349f9e92abe392682aa1d0237bf54d1be7917362685613ead2d2fb9e7cdb2ec",
    "size": 902,
    "platform": {
      "architecture": "amd64",
      "os": "linux"
    }
  },
  "containerimage.digest": "sha256:5349f9e92abe392682aa1d0237bf54d1be7917362685613ead2d2fb9e7cdb2ec",
  "image.name": "ghcr.io/the-guild-org/conductor/conductor:d8fb1ac17a20a80418d4d6281c808a6ad05790fa"
}
}

Copy link

github-actions bot commented Feb 14, 2024

✅ Benchmark Results

     data_received..................: 13 MB   221 kB/s
     data_sent......................: 22 MB   363 kB/s
     http_req_blocked...............: min=1.12µs   avg=3.05µs   med=2.27µs   max=1.44ms  p(95)=3.41µs   p(99)=8.62µs  
     http_req_connecting............: min=0s       avg=378ns    med=0s       max=1.41ms  p(95)=0s       p(99)=0s      
     http_req_duration..............: min=320.83µs avg=432.59µs med=394.69µs max=38.4ms  p(95)=507.8µs  p(99)=641.89µs
       { expected_response:true }...: min=320.83µs avg=432.59µs med=394.69µs max=38.4ms  p(95)=507.8µs  p(99)=641.89µs
     ✓ { scenario:rps_1000 }........: min=320.83µs avg=432.59µs med=394.69µs max=38.4ms  p(95)=507.8µs  p(99)=641.89µs
     http_req_failed................: 0.00%   ✓ 0          ✗ 60001
     ✓ { scenario:rps_1000 }........: 0.00%   ✓ 0          ✗ 60001
     http_req_receiving.............: min=10.52µs  avg=27.5µs   med=26.45µs  max=1.75ms  p(95)=36.95µs  p(99)=49.3µs  
     http_req_sending...............: min=6.95µs   avg=15.65µs  med=14.34µs  max=1.63ms  p(95)=23.78µs  p(99)=35.05µs 
     http_req_tls_handshaking.......: min=0s       avg=0s       med=0s       max=0s      p(95)=0s       p(99)=0s      
     http_req_waiting...............: min=280.2µs  avg=389.43µs med=352.76µs max=38.32ms p(95)=460.04µs p(99)=585.85µs
     http_reqs......................: 60001   999.992221/s
     ✓ { scenario:rps_1000 }........: 60001   999.992221/s
     iteration_duration.............: min=399.29µs avg=528.24µs med=488.18µs max=38.69ms p(95)=616.08µs p(99)=813.36µs
     iterations.....................: 60001   999.992221/s
     ✓ { scenario:rps_1000 }........: 60001   999.992221/s
     valid_graphql_response.........: 100.00% ✓ 60001      ✗ 0    
     ✓ { scenario:rps_1000 }........: 100.00% ✓ 60001      ✗ 0    
     valid_http_code................: 100.00% ✓ 60001      ✗ 0    
     ✓ { scenario:rps_1000 }........: 100.00% ✓ 60001      ✗ 0    
     vus............................: 0       min=0        max=2  
     vus_max........................: 200     min=200      max=200

@dotansimha dotansimha force-pushed the schema_awareness branch 4 times, most recently from 79c3b72 to 4fe7d9b Compare February 14, 2024 12:52
@dotansimha dotansimha force-pushed the schema_awareness branch 4 times, most recently from 20a3cb3 to 2b3436a Compare March 5, 2024 12:31
ok

getting there

ok

fix

ok polling works

cleanup

ok introspection is supported now

fixes

wip

wip

move source runtime to common
standalone plugin mgr on source

add source runtime to plugin flows

validation as a plugin

fixes

fix startup missing logs

fix

fix

wasm fixes

wip docs
@dotansimha dotansimha changed the title wip: schema awareness schema awareness Mar 20, 2024
@dotansimha dotansimha marked this pull request as ready for review March 20, 2024 15:51
@dotansimha dotansimha changed the title schema awareness feat: schema awareness (+fixed root logger) Mar 20, 2024
@dotansimha dotansimha merged commit 598d3d5 into master Mar 20, 2024
17 checks passed
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.

Schema Awareness Support overwriting endpoint GraphQL schema
1 participant