Commit Graph

1050 Commits

Author SHA1 Message Date
Kubernetes Prow Robot a0994fc794
Merge pull request #473 from ash2k/ash2k/missing-return
Add missing returns
2021-11-05 11:05:10 -07:00
Kubernetes Prow Robot ca846ea62d
Merge pull request #474 from ash2k/ash2k/no-lowercase
No need to lowercase namespaces
2021-11-05 10:37:53 -07:00
Mikhail Mazurskiy 38f7478964
No need to lowercase namespaces
They are lowercase and that's enforced by Kubernetes.
2021-11-05 16:41:24 +11:00
Mikhail Mazurskiy 7b53399fc6
Add missing returns 2021-11-05 16:37:16 +11:00
Mikhail Mazurskiy 200d6ec9c4
Consistently use InfoHelper to get rest client 2021-11-05 14:10:14 +11:00
Karl Isenberg 9607cb5cf1 feat: Add apply/destroy --status-events flag
- Status events disabled by default
- Status events always enabled for table output
2021-11-04 13:14:46 -07:00
Kubernetes Prow Robot 8da7837865
Merge pull request #463 from karlkfi/karl-wait-printer
feat: send WaitEvent for every resource
2021-11-04 13:02:23 -07:00
Karl Isenberg 9426fcbea8 fix: disable dupl linter on some e2e tests
Linter complains that the expected event lists are too similar,
which is deliberate and should not be abstracted away. Explicit
test expectations in the test makes it easier to debug failures.
2021-11-04 10:57:35 -07:00
Karl Isenberg a24aaea775 feat: send WaitEvent for every resource
- WaitEvent can be Pending, Reconciled, Skipped, or Timeout.
  Skipped, Pending, and Reconciled events are sent at task start.
  Reconciled events are sent later as status updates are recieved.
  Timeout events are sent for remaining events on timeout.
- Rewrite WaitTask.Start to use context.WithTimeout and a goroutine to
  handle task completion (replacing setTimer and the token hack).
- Replaced Task.ClearTimeout with Task.Cancel.
- Replaced WaitTask.complete & checkCondition with Task.StatusUpdate.
- Replaced WaitTask.startAndComplete with a check in WaitTask.Start.
- Replaced WaitTask.amendTimeoutError with WaitTask.sendTimeoutEvents
  to send multiple timeout events, instead of one event with a list of
  TimedOutResources.
- Updated all printers to handle WaitEvent.
  Event printer now includes reconcile events.
  JSON printer now includes resourceReconciled eventType.
  Table printer not includes reconcile column.
- Added JSON printer tests for error handling.
- Updated Formatter.FormatActionGroupEvent to collect WaitStats.
- Enable status events by default for kapply with table output

BREAKING CHANGE: WaitEvents now sent for each object
2021-11-04 10:57:35 -07:00
Kubernetes Prow Robot 6112508666
Merge pull request #469 from karlkfi/karl-prune-race
fix: race condition in PruneTask
2021-11-04 10:54:23 -07:00
Karl Isenberg 22ec2ac328 fix: race condition in PruneTask
The Pruner modifies the input object when the deletion prevention
annotation is present. This in turn modifies the object map, which
creates a race condition when reading the object map from the task
runner. To fix the race, a copy of the object is made, but only if
the deletion prevention filter prevents deletion.
2021-11-04 10:20:47 -07:00
Kubernetes Prow Robot 594863b776
Merge pull request #468 from karlkfi/karl-info-race
fix: race condition in BuildInfo
2021-11-03 13:36:32 -07:00
Karl Isenberg b977b5960f fix: race condition in BuildInfo
Historically, the objects in ApplyTask were being modified in the
Start func by BuildInfo to remove the path annotation, but this can
cause a race condition in the task runner if it tried to read the
task objects.

Now a DeepCopy is made in BuildInfo instead. This avoids the race
condition but broke mutation, which executes after BuildInfo on the
original object. So we now extract the object from the into after
BuildInfo and use that instead for mutations, filters, and events.
2021-11-03 13:11:20 -07:00
Kubernetes Prow Robot 10f3156431
Merge pull request #465 from seans3/export-status-poller
Exports Applier/Destroyer StatusPoller field
2021-11-02 15:01:42 -07:00
Sean Sullivan 944b7a7d63 Exports Applier StatusPoller field 2021-11-02 11:53:52 -07:00
Kubernetes Prow Robot 7c3417d3a8
Merge pull request #464 from haiyanmeng/run-make
Run `make all`
2021-11-02 09:56:58 -07:00
Haiyan Meng cb9c7fc15f Run `make all` 2021-11-02 07:05:09 -07:00
Kubernetes Prow Robot 64634f0281
Merge pull request #462 from seans3/remove-unused-preprocess
Removed unused command PreProcess function
2021-11-01 18:38:58 -07:00
Sean Sullivan 1034bbe898 Removed unused command PreProcess function 2021-11-01 18:21:11 -07:00
Kubernetes Prow Robot f4b64aada8
Merge pull request #430 from ash2k/ash2k/crd-check-version
Check versions a CRD defines
2021-11-01 13:35:47 -07:00
Kubernetes Prow Robot 108bc093cd
Merge pull request #459 from haiyanmeng/remove
Avoid printing out all the events
2021-11-01 11:23:47 -07:00
Haiyan Meng 461fae877a Avoid printing out all the events
The printing logic was added by accident in https://github.com/kubernetes-sigs/cli-utils/pull/451/files#diff-dee0be9aff370837ed01dcd5dc8f8a414369adc7b3d846453f800c8639fb8d37R255
2021-11-01 11:06:13 -07:00
Kubernetes Prow Robot 0849d300ff
Merge pull request #451 from haiyanmeng/ignore
Change the behavior of hanlding a WaitTask timeout
2021-10-30 16:55:19 -07:00
Kubernetes Prow Robot b66eaeee95
Merge pull request #457 from seans3/inv-info-wrapper
Removes inventory from manifestloader
2021-10-30 04:25:17 -07:00
Kubernetes Prow Robot ed6845051f
Merge pull request #458 from seans3/printer-pkg-move
Moves printers from cmd to pkg
2021-10-29 16:36:15 -07:00
Haiyan Meng 87877d28d1 Change the behavior of hanlding a WaitTask timeout
Today, when a WaitTask timeout happens, the WaitTask sends the
TimeoutError on the TaskChannel. After receiving the TimeoutError,
`baseRunner.run` terminates immediately by returning the error to its
caller (Applier.Run or Destroyer.Run). The caller then sends the error
onto the EventChannel and terminates.

With this PR, when a WaitTask timeout happens, the WaitTask sends a
WaitType Event including the TimeoutError on the EventChannel, and then
sends an empty TaskResult on the TaskChannel. An empty TaskResult
suggests that the task finished successfully, and therefore
`baseRunner.run` would continue instead of terminate.

The motivation of this change is to make sure that cli-utils only
terminates on fatal errors (such as inventory-related errors, and
ApplyOptions creation errors). A WaitTask timeout may not always mean a
fatal error (it may happen because the StatusPoller has not finished
polling everything, or some but not all the resources have not reached
the desired status), and therefore should not terminate cli-utils.
2021-10-29 16:18:21 -07:00
Sean Sullivan 0419797013 Moves printers from cmd to pkg 2021-10-29 12:22:49 -07:00
Kubernetes Prow Robot 6f5ee6f2ef
Merge pull request #456 from karlkfi/karl-fix-skips
fix: skipped deletes no longer cause waiting
2021-10-29 11:41:10 -07:00
Karl Isenberg eda3554fb1 fix: skipped deletes no longer cause waiting
- Added SkippedApplies and SkippedDeletes to the TaskContext
- Modified tasks to use the new skipped tracking, replacing usage
  of failure tracking, where skipped is more accurate.
- Renamed some TaskContext methods for consistency
- Added ObjMetadataSetFromMap for use by TaskContext
- Added ObjectMetadataSet.Intersection for use by InvSetTask
- Cleaned up InvSetTask to be more readable with comments explaining
  intended behavior, including handling of skips.
- Added apply and prune tests for skipped, failure, and abandoned
2021-10-29 10:28:06 -07:00
Sean Sullivan 0ac281cdd4 Removes inventory from manifestloader 2021-10-29 08:55:31 -07:00
Kubernetes Prow Robot 84a79b880f
Merge pull request #453 from seans3/ignore-lint-error
Ignore receiver name lint error
2021-10-28 16:14:50 -07:00
Sean Sullivan 7fde7fba3b Ignore receiver name lint error 2021-10-28 11:20:58 -07:00
Kubernetes Prow Robot 89b6f0b5b1
Merge pull request #445 from karlkfi/karl-pruner
Clean up prune package
2021-10-20 17:04:09 -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 d62b5c6200
Merge pull request #435 from mortent/UpdateVersionOfK8sLibsAndKyaml
Update to latest version of kyaml and k8s libs
2021-10-19 23:49:57 -07:00
Morten Torkildsen 73dca2b0dc Update to latest version of kyaml and k8s libs 2021-10-19 17:41:57 -07:00
Kubernetes Prow Robot d97a96b4a2
Merge pull request #439 from karlkfi/karl-cmd-timeout
Add timeout option & error on timeout/cancel
2021-10-19 11:40:24 -07:00
Karl Isenberg ee6c5a7fe4 Return error & send error event on cancel/timeout 2021-10-19 11:07:14 -07:00
Karl Isenberg 066fd77de9 Add timeout flag to apply, destroy, & status cmds 2021-10-15 17:42:05 -07:00
Mikhail Mazurskiy 7e47e6bd0e
Check exact version when determining scope 2021-10-15 12:36:25 +11:00
Mikhail Mazurskiy 9f6552d595
Check versions a CRD defines 2021-10-15 12:36:23 +11:00
Kubernetes Prow Robot 16eff57a75
Merge pull request #427 from ash2k/ash2k/drop-apiextensions-dep
Drop k8s.io/apiextensions-apiserver dependency
2021-10-14 11:21:36 -07:00
Kubernetes Prow Robot b76a0bc4ca
Merge pull request #431 from ash2k/ash2k/remove-unused-task
Remove unused ResetRESTMapperTask task
2021-10-14 09:27:27 -07:00
Kubernetes Prow Robot a299abd292
Merge pull request #423 from karlkfi/karl-global-timeout
Add global destroyer timeouts
2021-10-14 09:27:21 -07:00
Kubernetes Prow Robot 02d8b21213
Merge pull request #424 from haiyanmeng/delete-prevention
Handle deletion prevention correctly
2021-10-13 18:39:28 -07:00
Haiyan Meng 7c27474df5 Handle deletion prevention correctly
If an object with the deletion prevention annotation is removed from the
inventory, the config.k8s.io/owning-inventory annotation should be
removed from the object, and the object should be removed from the
inventory.
2021-10-13 10:15:32 -07:00
Karl Isenberg 31679a650f Add global destroyer timeout
- Destroyer context added, with cancel test.
- Fix Applier cancel test not using specified timeouts.
- Added a few logs to help with debugging test failures
2021-10-12 17:41:57 -07:00
Kubernetes Prow Robot 8b12ecd594
Merge pull request #425 from mortent/UpdateOwners
Update owners file to only include active contributors
2021-10-12 12:38:34 -07:00
Kubernetes Prow Robot c4e5b01aa1
Merge pull request #429 from karlkfi/karl-applier-tests
Applier unit test cleanup
2021-10-12 11:54:33 -07:00
Karl Isenberg 714a3b27d4 Applier unit test cleanup
- Add test for applier.Run context cancel/timeout
- Add AssertEqual & AssertNotEqual to wrap testutil.Equal matcher
- Move common test utils to common_test.go
- Use yaml artifacts, instead of Unstructured
- Use apply.Options as test input
- Use UnstructuredSet as test input
- Extract Applier construction with fake inputs to newTestApplier
- Extract nil inventory to its own test to simplify test inputs
  to TestReadAndPrepareObjects
2021-10-12 11:33:21 -07:00