Conversation
1ac2a36 to
ce69503
Compare
ce69503 to
ef74fd9
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #216 +/- ##
==========================================
- Coverage 75.76% 74.41% -1.36%
==========================================
Files 58 63 +5
Lines 3326 3709 +383
Branches 167 181 +14
==========================================
+ Hits 2520 2760 +240
- Misses 701 844 +143
Partials 105 105 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
600906a to
6fa11a8
Compare
6fa11a8 to
fda5c3b
Compare
fda5c3b to
f93d1d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Links
Description and Rationale
SKEL - The SimKube Expression Language
This is the first PR in a series that enables support for modifying trace files using a domain-specific language called SKEL. This PR just enables support for the
removeoperation, which allows removing fields from resources in a trace file. Future PRs will supportapply,insert, and other operations. SKEL files are interpreted and applied to traces via a newskctlsubcommand calledtransform, e.g.,The second commit in this stack contains the initial documentation for SKEL which will show up on the SimKube website.
Initial metrics support
We now include the metrics crate for emitting metrics from various parts of the codebase; initially I want this so I could track some telemetry from
skctl transform, but I expect/hope that its usage will expand. (The previous pattern that we used here in, say,skctl validatewas to use an "annotated" trace that tracks all of the changes locally, but that is an enormous bear and very convoluted code; tracking these things with a global metrics recorder is much nicer).Minor QOL improvements to the CLI
I wanted a way to show a progress bar and spinner and such for
skctl transform, since for larger traces it will probably take a bit of time to run, so I cribbed from skimmer and set up kdam.How
SKEL
We use pest to define the grammar for our DSL. Pest takes in the grammar definition file (
skel/skel.pest) and converts it to a set of Rules as a Rust enum. The skel code then matches over these rules to create an AST (honestly, it's not really a "tree" per se, there's currently no infix operators or precedence rules to worry about, to it's more of an abstract syntax... path, I guess?). This code is inskel/ast.rsOnce the SKEL file is interpreted into a set of commands, the
transformcommand iterates through every event in the trace, determines whether the command should be applied, and then takes the action. This code is all contained inskel/engine.rs.The reasoning for this is that in our previous solution to this (aka
skctl validate check --fix) we made a change for each validation rule, iterated over the entire trace to apply it, and then moved on to the next rule. This is extremely unperformant for large traces. This model is O(n) in the length of the trace, which should be much more efficient at the expense of limiting "some types" of operations. So far I haven't run into anything that seems impossible to do with SKEL so far.Docs
In addition to the documentation, there is now a sample SKEL file in
examples/sanitize.skelthat users can reference. This implements 80% of the sanitizations performed byskctl val check --fix; we still need a way to clean up volumes and volumemounts in pods, which will require a slight extension to the SKEL language.Metrics
We implemented a local (in-memory) metrics recorder which we can access later on to get the results of the various counters/gauges. I can see this in the future expanding or becoming a separate library, but it works well enough for now.
Test Steps
wwwinstance, made sure they look OKSuccessful transformation:
Also confirmed using
skctl xraythat the output trace file is well-formed and contains the modifications we expect.Parse error
If there's a syntax error in the user's SKEL file, the output looks like this:
Not the most intuitive output, but it at least points to the right line and gives some sort of useful feedback. I think we can clean this up/improve it in the future.
Other Notes
This will require a number of follow-on PRs to get this fully usable, but (hopefully) now that the structure is in place those are smaller
Once we support the volume/volumemount modifications in SKEL, I want to rip out and significantly simplify the logic in
skctl validateI also want to start using these metrics in
skctl validateI certify that this PR does not contain any code that has been generated with GitHub Copilot or any other AI-based code generation tool, in accordance with this project's policies.