Commit Graph

2332 Commits

Author SHA1 Message Date
James Shubin
a66cbc3098 engine: resources: Work around race in upstream lib
This is actually fixed in: 7d147928ee
but this is not in a release yet.
2025-09-14 19:36:57 -04:00
James Shubin
9833cb8df3 modules: virtualization: Update to Fedora 42 2025-09-14 00:06:59 -04:00
James Shubin
a73dc19ce9 engine: resources: Fix virt hotplug
At some point, this seems to have rotted, since I assume upstream
started requiring this updated XML spec. Fix it now.
2025-09-13 23:54:46 -04:00
James Shubin
bcf57f8581 engine: resources: Make the qemu guest agent automatic 2025-09-13 23:54:46 -04:00
James Shubin
611cdb3193 engine: resources: Disable buggy restart code
This was really not ever tested properly, and I worry it will deadlock.
It definitely kicks off falls positives that don't even do any harm as
far as we can tell.
2025-09-13 23:54:24 -04:00
James Shubin
1b39a780e1 engine: resources: Clean up virt code
There was and still is a bunch of terrible mess in this code. This does
some initial cleanup, and also fixes an important bug!

If you're provisioning a vmhost from scratch, then the function engine
might do some work to get the libvirt related services running before
the virt resource is used to build a vm. Since we had connection code in
Init() it would fail if it wasn't up already, meaning we'd have to write
fancy mcl code to avoid this, or we could do this refactor and keep
things more logical.
2025-09-13 23:28:33 -04:00
James Shubin
d59ae2e007 engine: graph: We shouldn't complain on context cancellation
These are expected from our engine. We do care about timeout's and so
on. This allows os to return ctx.Err() whenever a <-ctx.Done() happens,
which is more idiomatic for what we really want, but which we weren't
thorough with before.
2025-09-13 23:28:33 -04:00
James Shubin
b9363a3463 go: Update systemd dep to fix race
Hopefully this race is fixed upstream. Let's see.
2025-09-11 23:22:45 -04:00
James Shubin
a5f89d8d7b lang: funcs: dage: Use lazy freshness check
Not sure if this would introduce a glitch or not. Does seem to work
correctly. Without this, examples/lang/datetime2.mcl don't update
properly.
2025-09-11 23:19:45 -04:00
James Shubin
790b7199ca lang: New function engine
This mega patch primarily introduces a new function engine. The main
reasons for this new engine are:

1) Massively improved performance with lock-contended graphs.

Certain large function graphs could have very high lock-contention which
turned out to be much slower than I would have liked. This new algorithm
happens to be basically lock-free, so that's another helpful
improvement.

2) Glitch-free function graphs.

The function graphs could "glitch" (an FRP term) which could be
undesirable in theory. In practice this was never really an issue, and
I've not explicitly guaranteed that the new graphs are provably
glitch-free, but in practice things are a lot more consistent.

3) Simpler graph shape.

The new graphs don't require the private channels. This makes
understanding the graphs a lot easier.

4) Branched graphs only run half.

Previously we would run two pure side of an if statement, and while this
was mostly meant as an early experiment, it stayed in for far too long
and now was the right time to remove this. This also means our graphs
are much smaller and more efficient too.

Note that this changed the function API slightly. Everything has been
ported. It's possible that we introduce a new API in the future, but it
is unexpected to cause removal of the two current APIs.

In addition, we finally split out the "schedule" aspect from
world.schedule(). The "pick me" aspects now happen in a separate
resource, rather than as a yucky side-effect in the function. This also
lets us more precisely choose when we're scheduled, and we can observe
without being chosen too.

As usual many thanks to Sam for helping through some of the algorithmic
graph shape issues!
2025-09-11 23:19:45 -04:00
James Shubin
1e2db5b8c5 gapi: New API
Clear out lots of cruft and mistakes in this old API. The language GAPI
isn't updated with this commit, and as a result, this won't build, but
the fixes for it are coming shortly. We could have merged the two
commits, but it's easier to show them separately for clarity.
2025-09-09 02:21:59 -04:00
James Shubin
6041c5dc22 puppet: langpuppet: Nuke due to porting difficulties
Porting of the GAPI will cause challenging refactoring for me, so I'm
removing this for now, but happy to have it back if someone wants to
port it.
2025-09-09 02:21:59 -04:00
James Shubin
a668cd847e util: New buffered infinite chan primitive
I'm sure there are better implementations, but this feels clean enough
for now. Let's see if this is useful or not.
2025-09-09 02:21:59 -04:00
James Shubin
474df66ca0 lang: types: Add nil type for placeholder
The nil type is being added, but only slightly. It is not meant for real
use in the language. It will not work in all situations, and it isn't
implemented for many methods.

It is being added only for being a "dummy" placeholder value in the
engine when we have an unused value being propagated along an edge.
2025-09-09 02:21:59 -04:00
James Shubin
2022a31820 make: Leave race detector on by default
Maybe this will help us shake out some bugs.
2025-09-09 02:21:59 -04:00
James Shubin
71756df815 mod: Update fsnotify
This should fix a race condition in that library.

Likely fixed in: https://github.com/fsnotify/fsnotify/pull/678
2025-09-09 02:21:59 -04:00
James Shubin
f808c1ea0c converger: Wrap atomic lookup
Avoid this race. Maybe this code should be revisited with a mutex.
2025-09-09 02:21:59 -04:00
James Shubin
6c206b8010 util: Prevent unlikely race on easy exit
Race detector hit this up once, and I can see how it would be possible.
2025-09-09 02:21:59 -04:00
James Shubin
fb8958f192 engine: graph: Add err mutex
Here's a race that pops up. This is suboptimal locking, but it's not
important for now.
2025-09-09 02:21:59 -04:00
James Shubin
a070722937 etcd: Lock around read to prevent race 2025-09-09 02:21:59 -04:00
James Shubin
b02363ad0d etcd: scheduler: Use atomic to prevent race
This code should be rewritten, but in the meantime, at least avoid the
race detector issues.
2025-09-09 00:04:22 -04:00
James Shubin
bed7e6be79 etcd: Pass through the namespace
This is a bit tricky, and we should nuke and redo some of this API. The
sneaky bit has to do with whether we've already added the namespace
magic into our etcd client or not.
2025-09-09 00:04:22 -04:00
James Shubin
0031acbcbc lang: funcs: structs: Map indexes use half the integers
We want the pattern to be key:0, val:0, key:1, val:1, and so on... This
was previously using 0,1,2,3...

When we use Call directly, we need to fix this. Previously this was dead
code which is why the bug wasn't caught.
2025-09-09 00:04:22 -04:00
James Shubin
4e523231d6 engine: graph: Avoid race on fast pause variable
This code is basically unused, but let's keep it in for now in case we
eventually replace it with some contextual ctx code instead.
2025-09-09 00:04:22 -04:00
James Shubin
05d72b339d converger: Combine two signal channels into one
There's no reason we need to remake these two channels, when we can just
use one. We should probably rewrite this code entirely, but at least we
get rid of this race for now.
2025-09-09 00:04:21 -04:00
James Shubin
d2cda4ca78 etcd: Disable the dynamic chooser
We're not using dynamic etcd right now, so disable this code and prevent
the race detector complaining.
2025-09-09 00:04:21 -04:00
James Shubin
2f860be5fe engine: graph: Lock around frequent read races
These are all "safe" in terms of not ever conflicting, but the golang
memory model weirdness requires an actual lock to avoid race detector
errors.
2025-09-09 00:04:21 -04:00
James Shubin
5692837175 lang: Add a simple test of a non-tree dag 2025-09-09 00:04:21 -04:00
James Shubin
04ff2a8c5c lang: ast: Turn this speculation flag into a const
Makes it easier to find when debugging.
2025-09-09 00:04:21 -04:00
James Shubin
166b463fa9 lang: funcs: structs: Update the graph shape docs 2025-09-09 00:04:21 -04:00
James Shubin
2e858ff447 test: Improve colon test comment
I use these patterns when early hacking, and it's good to have a test to
catch them all before I merge.
2025-09-09 00:04:21 -04:00
James Shubin
6fac46da7c misc: Improved stack filtering
Although this needs more debugging, I'm not sure how the format changed.
I guess this is part of the "API" that golang is allowed to break ;)
2025-09-09 00:04:21 -04:00
James Shubin
2b820da311 lang: ast: structs, funcs: structs: Exprif without a channel
This adds an improved "expr if" which only adds the active branch to the
graph and removes the "secret" channel.
2025-08-04 17:45:06 -04:00
James Shubin
86c6ee8dee lang: ast, funcs: Remove the secret channel from call
This removes the secret channel from the call function. Having it made
it more complicated to write new function engines, and it's not clear
why it was even needed in the first place. It seems that even the
current generation of function engines work just fine without it.

Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
2025-08-04 17:04:01 -04:00
James Shubin
0a76910902 lang: core: Skip broken test
I expect this will be deprecated soon, let's see.
2025-08-04 17:04:01 -04:00
James Shubin
138ff8a895 lang: funcs: structs: Fix typos 2025-07-17 01:47:55 -04:00
James Shubin
8edb8e2a7b lang: interfaces: Add new helpers for dealing with args 2025-07-17 01:47:55 -04:00
James Shubin
bdf5209f68 util: errwrap: Add unwrapping for context removal
It's common in many concurrent engines to have a situation where we
collect errors on shutdown. Errors can either because a context closed,
or because some engine error happened. The latter, can also cause the
former, leading to a list of returned errors. In these scenarios, we
want to filter out all the secondary context errors, unless that's all
that's there. This provides a helper function to do so.
2025-07-16 23:48:37 -04:00
James Shubin
299b49bb17 util: errwrap: Add a function for joining
This is like the Append function but for a list.
2025-07-16 23:48:37 -04:00
James Shubin
71e4282d3f lang: interfaces: Add args to struct helper
We should consider if it's possible to avoid all of this transforming
entirely, but at least for now, do it all in one place by having an
available helper.
2025-07-13 03:18:23 -04:00
James Shubin
984aa0f5fc lang: Rename the vertex names
Make it a bit more obvious what the generated nodes are for.
2025-07-13 03:18:23 -04:00
James Shubin
737d1c9004 lang: interfaces: Table can be a standalone type
We'd like to have some useful helpers defined on it, like Copy.
2025-07-13 03:18:23 -04:00
James Shubin
d113fcb6d7 lang: ast, interfaces, interpret: Table should be a well-known type
We use this in enough places, that it's nice to have it as a well-known
alias.
2025-07-13 03:18:23 -04:00
James Shubin
73e641120f pgraph: Improve time complexity of IncomingGraphVertices
This goes from O(n^2) to O(n) when map lookup is O(1). I never really
focused on much optimizing, but I noticed this one in passing.
2025-07-13 03:18:22 -04:00
James Shubin
f7e446ef6f lang: core: example: nested: We don't use the func suffix anymore
There are only functions, no need to add suffixes to file names.
2025-07-13 03:18:22 -04:00
James Shubin
21917864db lang: core, funcs: Remove facts API
This started because it was possible, not because it was very useful.
The overhead of using the full function API, is lessened by the function
API helpers, and the upcoming improvements in the function API.

It's much easier to have one fewer API's to manage and so on.

It's also a stark reminder of how weak tools like "puppet" are which
only really have data collection systems that don't take arguments.
2025-07-13 03:15:53 -04:00
James Shubin
c49d469dcd engine: resources: Work around trailing slash issue in home dir
If the user is logged in, and we try to change from /home/james to
/home/james/ we'll get the error:

usermod: user james is currently used by process ????

and furthermore, it makes no sense to try and make this change since the
usermod function won't do anything if you run:

usermod --gid james --groups wheel --home /home/james/ james

when /etc/passwd has /home/james as the string.
2025-06-25 06:05:28 -04:00
James Shubin
0a79daf277 pgraph: Print cycles on error
I'm a terrible algorithmist, so who knows if this is correct, but it
seems to work in my cursory testing.
2025-06-25 06:05:28 -04:00
James Shubin
a4ed647d02 modules: purpleidea: Add more packages 2025-06-25 06:05:28 -04:00
James Shubin
79c199975d modules: purpleidea: Add another useful helper package 2025-06-25 06:05:11 -04:00