Commit Graph

114 Commits

Author SHA1 Message Date
Sean Sullivan 944b7a7d63 Exports Applier StatusPoller field 2021-11-02 11:53:52 -07:00
Karl Isenberg a5030ffd18 Clean up prune package
- Rename PruneOptions to Pruner (it does the work itself)
- Rename variables and internal methods for clarity/consistency
- Extract deleteObject method to improve readability
- Rename GetObject to getObject (only used internally and by test)
- Modify log messages for readability
- Add log support for prune tests
- Make log messages more consistent
2021-10-20 16:20:00 -07:00
Kubernetes Prow Robot a1b40b59d5
Merge pull request #422 from haiyanmeng/skip
Skip InventoryPolicyApplyFilter for the `AdoptAll` inventory policy to improve the performance
2021-10-08 14:38:24 -07:00
Karl Isenberg 604c9deb8b Add UnstructuredSet to encapsulate set functions
- Refactor usages to []Unstructured to use UnstructuredSet
- Add UnstructuredSet.Equal to handle set equality comparison
- Avoid updating tests to prove reverse compatibility
  (except: Graph.SortObj, which returns a list of sets)
2021-10-08 13:45:46 -07:00
Haiyan Meng 97b02cd107 Skip InventoryPolicyApplyFilter for the `AdoptAll` inventory policy to
improve the performance

Running InventoryPolicyApplyFilter involves getting every object in the
current inventory from the live cluster, which can be expensive if the
inventory includes lots of objects.

If the inventory policy is `AdoptAll`, the current inventory can take
ownership of any objects. Therefore, it is not necessary to run
InventoryPolicyApplyFilter.
2021-10-07 10:02:30 -07:00
Karl Isenberg d964b0397b Merge Collector and ResourceCache
- Make ResourceCache thread-safe
- Make ResourceCache store status and messagei
- Add ResourceCache to baseRunner and TaskContext
- Make Mutator compute resource status for uncached resources
- Share cache between StatusPoller and Mutator
- Move Condition and conditionMet() to its own file
- Simplify WaitTask.checkCondition
- Simplify baseRunner.amendTimeoutError
2021-09-30 12:01:19 -07:00
Karl Isenberg 02c0fb7229 Add apply-time-mutation feature
- Detect `config.kubernetes.io/apply-time-mutation` annotation
- Parse annotation string value as YAML
- Treat source resource as a dependency
- Before applying, apply specified substitutions
- Each mutation may include one or more substitution
- Substitutions may optionally replace a token in the existing
  string value, or replace the whole value (e.g. non-strings)
- Source and target fields are specified with JSONPath expressions
- Using github.com/spyzhov/ajson because it supports mutation, and
  not just retrieval
- ApplyTimeMutator uses an in-memory ResourceCache to reduce GETs
2021-09-21 11:00:37 -07:00
Sean Sullivan 45cb7e31e0 Moves inventory policy check for apply into filter 2021-08-30 10:21:38 -07:00
Kubernetes Prow Robot f7e13914ee
Merge pull request #396 from seans3/cyclic-dep-error
Expose cyclic dependency error
2021-08-23 12:08:23 -07:00
Sean Sullivan 769f5bd735 Expose cyclic dependency error 2021-08-23 11:24:05 -07:00
Kubernetes Prow Robot 24030c97fa
Merge pull request #395 from seans3/inv-annotation-fix
Move inventory annotation addition
2021-08-23 10:44:01 -07:00
Sean Sullivan aa79285f4b Move inventory annotation addition 2021-08-17 11:09:58 -07:00
Morten Torkildsen 91df668cb8 Prune/Delete should use the specified propagation policy 2021-08-17 09:48:31 -07:00
Mikhail Mazurskiy 4b8dd62c53
Remove strings.TrimSpace()
Names and labels cannot have any whitespace. If they do, it's an error that should be reported and fixed.
2021-08-08 11:29:43 +10:00
Kubernetes Prow Robot 69388f265d
Merge pull request #389 from justinsb/infohelper
Pass the RESTMapper explicitly into infoHelper
2021-07-29 13:51:18 -07:00
Justin SB 669fb3f739 Pass the RESTMapper explicitly into infoHelper
This allows for better control, for example allowing us to invalidate
the discovery cache before proceeding.
2021-07-29 18:39:11 +00:00
Morten Torkildsen dacbf97143 Avoid dryRun as state in inventory client 2021-07-14 17:34:18 -07:00
Morten Torkildsen 136d1efeeb Better validation of resources prior to actuation 2021-07-01 17:02:57 -07:00
Mikhail Mazurskiy c1c7c9ef9c
Remove Provider interface 2021-06-30 15:21:03 +10:00
Sean Sullivan 383c0042fb destroyer calculates emit status events 2021-06-28 16:56:32 -07:00
Mikhail Mazurskiy 4eb7dc1f6f
Remove Initialize() on Destroyer and PruneOptions 2021-06-18 14:58:49 +10:00
Sean Sullivan 4432f51ac3 Refactor prune/delete using ValidationFilter interface 2021-06-16 11:29:37 -07:00
Mikhail Mazurskiy 8dc334f344
Remove Applier.Initialize() 2021-06-16 08:53:30 +10:00
Sean Sullivan b77cc7ea62 Prune refactor to take objects to prune 2021-06-10 16:37:18 -07:00
Sean Sullivan af417c6fab Refactor destroyer to use tasks 2021-06-09 15:40:32 -07:00
Mikhail Mazurskiy d41f250f19
Update dependencies to Kubernetes v1.21.1 2021-05-28 12:53:51 +10:00
Sean Sullivan 42e330d4d8 Move inventory operations into tasks 2021-05-26 17:47:00 -07:00
Morten Torkildsen ae80e561e2 Improve the event hierarchy 2021-05-18 14:58:41 -07:00
Morten Torkildsen 7be21cf94e Add validation of inventory-id for name strategy if inventory object already exists 2021-04-04 15:52:33 -07:00
Sean Sullivan 185aa3d048 Better final inventory calculation during errors 2021-02-04 22:33:54 -08:00
Sean Sullivan 6db68fda8d Fix for final inventory update 2021-01-25 22:30:22 -08:00
Jingfang Liu 5184286403 enable InventoryPolicy in applier 2020-12-08 13:22:08 -08:00
Jingfang Liu bff0ab8ace add inventory policy 2020-11-30 09:47:28 -08:00
Jingfang Liu 3224d5f259 splti the provider interface 2020-11-16 08:30:49 -08:00
Jingfang Liu 7915dc5de7 change the apply API to InventoryInfo 2020-11-11 15:07:46 -08:00
Jingfang Liu 4983152e59 split inventory and resources in the apply interface 2020-11-04 15:00:52 -08:00
Morten Torkildsen 3ac57786f6 Update the ManifestReader interface and implementations to use Unstructured 2020-10-26 12:13:44 -07:00
Kubernetes Prow Robot 43b52152dd
Merge pull request #257 from seans3/server-side-apply
Implements server-side apply
2020-10-26 10:33:02 -07:00
Morten Torkildsen 24b7916df8 Change inventory package to use Unstructured instead of Info 2020-10-24 15:14:30 -07:00
Sean Sullivan 99285377ba Implements server-side apply 2020-10-23 22:55:06 -07:00
Morten Torkildsen 507d11f31e Use Unstructured instead of Info 2020-10-20 15:38:13 -07:00
Morten Torkildsen c0031a934a Remove IOStreams from the Applier 2020-10-15 17:07:11 -07:00
Morten Torkildsen a6c5f50abc Move ApplyOptions into ApplyTask 2020-10-14 17:33:49 -07:00
Morten Torkildsen 034d5c3456 Use the TaskContext for passing UIDs of applied resources to the pruner 2020-09-25 14:25:13 -07:00
Sean Sullivan 2de4d86359 Applies inventory namespace first if necessary 2020-09-11 16:11:50 -07:00
Sean Sullivan 06594c1bca New factory wraps kubectl factory and inventory client 2020-08-31 11:49:18 -07:00
Morten Torkildsen 9135af4218 Improve error handling 2020-08-16 20:10:17 -07:00
Kubernetes Prow Robot 55b73eed69
Merge pull request #206 from mortent/RefactorPrinters
Update status command to leverage inventory and add additional output formats
2020-08-13 13:44:23 -07:00
Sean Sullivan 1dc67ad820 Function to set inventory factory function on inventory client 2020-08-09 23:35:52 -07:00
Kubernetes Prow Robot 92fed4f691
Merge pull request #212 from mortent/AllowMultipleNamespacesWithApply
Allow resources in multiple namespaces
2020-08-06 21:30:19 -07:00