* internal/host/plugin: ensure UpdateCatalog triggers updates for sets
This ensures that attribute updates to a host catalog triggers an update
to any of its downstream host sets. This ensures that updates to
elements that affect a host set, such as the region a host catalog is
configured for, take effect immediately instead of requiring a wait of
long as 10m after an update.
* Add WithNextRunIn to test sync job
This is to ensure it doesn't run right away when added. This ensures
that we can accurately test *when* the job is set to run immediately.
* Update internal/host/plugin/repository_host_catalog.go
Co-authored-by: Todd <T.Alan.Knight@gmail.com>
* Change TestRepository_UpdateCatalog_SyncSets to check next run time, not wait for run
* Remove explicit version increment and instead rely on implicit increment
* Fix lanuage for rows updated check when flagging host sets for sync
* remove errant non-zero check when looping over the thing we're checking
* remove scheduler start line from TestRepository_UpdateCatalog_SyncSets
Co-authored-by: Todd <T.Alan.Knight@gmail.com>
Adds tests to `SetupControllerPublicClusterAddress` and
`SetupWorkerPublicAddress` ahead of changes in these functions to
ensure functionality is preserved.
Internally attributes are not allowed to be the null value. However, as
currently implemented, this then breaks our normal model of sending an
explicit `null` in the JSON to reset/clear a field. This is a problem
because the CLI doesn't have a way to say "set this but to empty"
without a lot of hoops, and causes some issues for API users and TF as
well.
This changes PatchBytes and PatchStruct to return an empty value (or
marshaled empty value in the case of PatchBytes) if the source is null
or empty. In the host catalog update function we then always set this
value if it's in the db mask (removing the nil check). Together this
means a null value ends up coming out as an empty value (and thus valid
for the DB) from PatchStruct/PatchBytes, and our API translation
function already returns nothing for attributes if the length of the
fields are zero.
The previous PR only initialized plugins if they were required, which
meant that there may not actually be a plugin manager running because a
second node would not actually create the dev database, which is where
the plugin was being added. The assumption that a plugin manager is
running is still a fine one at the moment, but we just need to make sure
it's running in _all_ cases.
The embed package always uses Unix-style forward slashes. filepath.Join
utilization looking for files would cause the slashes to be the wrong
direction on Windows and result in the files not being found.
This updates the API generation code to allow the same option names to
be used in subtype-scoped options. This means if we have attribute
structs with the same fields, they won't overwrite each other, but will
instead create attribute-specific options.
Currently host does not use a version, which means it's not protected
against race conditions of either itself or its value objects. This adds
and plumbs through version to ensure that if a host or its value objects
change that they are not going to be affected by a race condition.
* Update sync interval seconds field.
* If the sync interval was updated, schedule the next sync job wakeup immediately.
* Calculate the next sync time for the scheduler should wake up if we only updated the sync interval.
* Reference PreferredEndpoints by top level struct name instead of embedded proto GetPreferredEndpoint method.
Reorganize the sql files a little.
* Make PreferredEndpoints replayable. Test refactoring to remove variables that persist across test calls. DeleteItems instead of trying to use WithWhere.
This adds a parameter to host sets allowing the sync interval to be
user-specified on a per-host-set basis. A value of -1 disables syncing;
a value of null uses the current default.
* internal/host/plugin: add UpdateSet
This adds the UpdateSet repository function.
UpdateSet runs the OnUpdateSet plugin call within the transaction as per
the changes in #1683.
The plugin call returns the updated set, the hosts in the set, the rows
updated, and any error.
* Ensure that attributes can be cleared by supplying a full null
* move version increment to the end and track perferred endpoint update separately
* move plugin call to end of transaction
* only clone returned set once, and move host fetch call out of transaction
* Request a sync when attributes are updated
* Add test to assert that old preferred endpoints are being removed correctly