James Shubin
c4a9560d53
engine: local: Fix benign race
...
Use the mutex in a safer manner to eliminate the benign data race.
2024-01-05 15:50:43 -05:00
James Shubin
bc63b7608e
engine: graph: Use an atomic bool instead of a mutex
...
The isStateOK variable can be accessed concurrently as these are
supposed to be "benign" races. As such, they need to be labelled as such
so that we don't hit some undefined compiler behaviour.
Here are five good references relating to "benign" data races in golang.
1) https://web.archive.org/web/20181022150257/https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
2) https://go.dev/ref/mem - "Informal Overview" section.
3) https://docs.oracle.com/cd/E19205-01/820-0619/gecqt/index.html
4) https://www.usenix.org/legacy/event/hotpar11/tech/final_files/Boehm.pdf
5) https://go.dev/doc/articles/race_detector
TL;DR: wrap your benign races with sync/atomic or eliminate them.
2024-01-05 15:50:42 -05:00
James Shubin
c2f508e261
engine: graph: Use an rwmutex around read/write of vertex state
...
This fixes two small races we had while simultaneously reading from and
writing to the vertex timestamp, and simultaneously writing to the
vertex isStateOK (dirty) flag.
They were actually "safe" races, in that it doesn't matter if the
read/write race got the old or new value, or that the double write
happened. The time sequencing was correct (I believe) in both cases, but
this triggers the race detector now that we have tests for it.
2024-01-02 18:18:34 -05:00
James Shubin
18e1f08156
engine: graph: Allow send/recv to work with autogrouped resources
...
We've previously not received a value from within an autogrouped
resource. It turns out this would be quite useful, and so this patch
implements the additional plumbing and testing so that this works!
Testing that an autogrouped resource can still send values has not been
done at this time.
2023-12-08 18:18:17 -05:00
James Shubin
271a94e0c7
engine: resources: Improve logging on resource errors
...
When a subcommand errors, it's helpful to see what it was.
2023-12-03 21:21:55 -05:00
James Shubin
b7d8a769db
lang: funcs: core: Add value functions
...
This adds a new series of "get*" functions which can read values from
the associated "value" resources. The key name of the function must
match the name value of the resource for things to work.
Type unification isn't yet perfect in these scenarios, so you should use
casually and with caution.
2023-12-03 18:24:20 -05:00
James Shubin
c05af3b9b3
lib, lang, engine: local: Add Value mechanisms to local API
...
This expands the Local API with the first (and in theory, only ever) API
for reading and writing simple values. This is a coordination point for
resources and functions to share things directly.
2023-12-03 18:24:20 -05:00
James Shubin
9d47b6843f
engine, gapi, lang, lib: Plumb through new local API
...
This is a new API that is similar in spirit and plumbing to the World
API, but it intended for all local machine operations and will likely
only ever have one implementation.
2023-12-03 18:24:20 -05:00
James Shubin
7991b4ab25
engine, lang, lib: Re-order for consistency
...
Some small cleanups to make room for future patches.
2023-12-03 18:02:00 -05:00
James Shubin
984fb702e5
engine: resources: Make test resource easier for debugging
...
Let some fields not get printed if we request it.
2023-12-03 18:02:00 -05:00
James Shubin
b8d391024a
engine: resources: Add a DoneCmd feature for exec resource
...
This makes a common pattern of `$cmd && echo done > /tmp/donefile` much
clearer and easier.
2023-11-28 15:24:22 -05:00
James Shubin
598bec0eab
engine: resources: Clean up var naming and misc in exec
2023-11-28 15:24:11 -05:00
James Shubin
709bf7b246
engine: resources: Add missing WatchCmd UID
...
Not sure if this is even used anywhere, but might as well add it for
now.
2023-11-28 15:24:11 -05:00
James Shubin
2cbce963b7
engine: resources, lang: funcs, parser: Add panic magic
...
It's valuable to check your runtime values and to shut down the entire
engine in case something doesn't match. This patch adds some magic
plumbing to support a "panic" mechanism.
A new "panic" statement gets transparently converted into a panic
function and panic resource. The former errors if the input is not
empty. The latter must be present to consume the value, but doesn't
actually do anything.
2023-11-28 13:49:31 -05:00
James Shubin
dad3458ece
mod: Try and update things
...
No idea why things break. go.mod sucks.
2023-11-27 21:00:03 -05:00
James Shubin
0e2c73a36d
engine: resources: Reduce logging for file resource
2023-11-27 19:57:54 -05:00
James Shubin
ee88161808
engine: graph, resources: Reduce and clean up logging
...
Make the output more usable.
2023-11-22 22:37:35 -05:00
James Shubin
04d54e8d82
engine: resources: Mask normal closing error
...
This could possibly be fixed upstream, but we'll workaround it for now.
2023-11-22 22:11:50 -05:00
James Shubin
f4d70068b1
engine: resources: Add a default NBP option to dhcp:server
...
This let's us do some overrides and is a good alternative since
send/recv+autogrouping doesn't work yet.
2023-11-22 20:22:50 -05:00
James Shubin
3fe5a8d0d6
mod: Update tftp libraries
2023-11-22 20:21:40 -05:00
James Shubin
6670407c9c
engine: resources: Make net resource reversible
...
This allows the net resource to be reversible if we want it to be. It
only flips the network state from up to down or vice-versa.
2023-11-22 20:21:40 -05:00
James Shubin
641b6067cd
engine: resources: Remove net config file on down
...
This cleans up the file we would have created when building the resource.
2023-11-22 20:21:40 -05:00
James Shubin
b1d61fa90b
engine: resources: Ignore cleanup errors that don't matter
...
If the file is already gone, ignore it.
2023-11-22 20:21:40 -05:00
James Shubin
0c93cf2600
engine: resources: Add constants for state up and down
...
Safer and cleaner code.
2023-11-22 20:21:40 -05:00
James Shubin
53753c0932
engine: resources: Improve net error messages
...
This is a common case of parse failures for not using CIDR. Make it
cleaner for the user.
2023-11-22 20:21:40 -05:00
James Shubin
029cfaf1f8
engine, lib: Misc log and comment changes
...
Just misc polishing.
2023-11-22 20:21:40 -05:00
James Shubin
66edc39ccb
engine: resources: Improve exec docs
...
So that I don't hit this too often.
2023-11-22 20:21:40 -05:00
James Shubin
3f42f785ac
engine: resources: Handle recurse field more appropriately
...
This smoothes out some edge cases. We should add comprehensive tests in
the future.
2023-11-22 20:21:40 -05:00
James Shubin
fd4d32351b
engine: resources: Refactor file mode code
...
Small cleanup in old code.
2023-11-22 20:21:40 -05:00
James Shubin
75d3895e84
engine: Improve logging for resources and exec
...
This makes things a bit clearer and fixes some silly formatting bugs.
2023-11-22 20:21:40 -05:00
James Shubin
d022d7f09e
engine: resources: Rename the value field in value resource
...
Having a different name makes it more obvious, and also leaves us open
to add a string or bool field for more explicit typing.
2023-11-18 15:15:33 -05:00
James Shubin
88b414b9a3
engine: resources: Add new value resource
...
This is a strange resource which is probably most useful for passing
values between scopes. It supports a variant resource field, and should
only be used as a last resort and if you know exactly what you're doing.
2023-11-18 14:23:31 -05:00
James Shubin
7105e38544
engine: util: Remove the ValueOf hack
...
We've got something in the core utility function now.
2023-11-18 13:45:46 -05:00
James Shubin
4b0cdf9123
lang: types, engine: graph: Support pointer interfaces
...
If we have rare, but special *interface{} values in resource structs, we
should be able to handle them normally. It's really not recommended that
you use these unless you know exactly why they are useful.
2023-11-18 13:35:52 -05:00
James Shubin
1c9fdc79c0
engine: util: Add a workaround for printing special resources
...
This let's our tests compare strings of interface fields!
2023-11-18 13:35:52 -05:00
James Shubin
90d04990ca
engine, lang: Add an AST test that looks at fields too
...
This gives us more options for testing when we need those kinds of more
extensive resource examination features.
2023-11-18 13:35:52 -05:00
James Shubin
aa001ed2dc
engine: graph: Improve error message for rare case
...
Not sure if we ever hit this, but we should fix it up since I noticed
it.
2023-11-18 13:35:52 -05:00
James Shubin
3a3bc568b3
engine: Allow more send/recv cases
...
This allows the other part of this. This still needs to be improved, but
it unblocks some use-cases.
2023-11-12 17:50:07 -05:00
James Shubin
b048b2684b
engine, lang: Allow resources with a field of type interface
...
This lets us add a resource that has an implementation with a field
whose type is determined at compile time. This let's us write more
flexible resources.
What's missing is additional type checking so that we guarantee that a
specific resource doesn't change types during run-time.
2023-11-12 17:25:03 -05:00
James Shubin
9a1a81925e
engine: Improve error messages for ambiguity
...
This appears twice, make each one unique.
2023-11-12 17:09:50 -05:00
James Shubin
4fb356b19b
engine: graph: Refactor the send/recv code to inline it
...
This is useful subsequently.
2023-11-12 16:13:04 -05:00
James Shubin
cb6b8a9670
engine: util: Refactor code for future changes
...
This makes things a bit cleaner and easier to follow and accepts future
patches easier.
2023-11-12 15:26:44 -05:00
James Shubin
cb999af653
engine: Improve debugging for invalid send/recv res
...
If we don't implement send/recv properly, at least give the user more
information as to where.
2023-11-12 15:21:08 -05:00
James Shubin
8d7d2fb1f1
engine: resources: Add missing struct tags for password res
...
Just noticed these.
2023-11-04 16:59:09 -04:00
James Shubin
e37876afec
engine: resources: Small formatting cleanups
2023-10-07 11:44:47 -04:00
James Shubin
738485a655
etcd: Add world API changes for watching member status
...
This adds some useful functionality so that anyone with access to the
world API, can learn information about the changing etcd cluster it's
using.
2023-09-29 20:46:36 -04:00
James Shubin
089267837d
engine: graph: Add a lock around metas access
...
We forgot about the concurrent writes. This should fix that.
2023-09-19 13:46:20 -04:00
James Shubin
c851322826
engine: resources: Fix up test resource
...
Woops...
2023-09-19 09:12:59 -04:00
James Shubin
6c0775ba59
engine: resources: Consider passing in funcs if possible
...
Let this sit in the test resource for now.
2023-09-04 16:33:05 -04:00
James Shubin
0d381e4c91
engine: graph: Handle the back poke differently
...
A back poke is the deferral or delay of a Process/CheckApply. This is
because we notice that we're not truly ready to CheckApply due to some
timestamp issue. When Process errors, we should accept that, but not
treat it as a success.
2023-09-04 15:22:14 -04:00