* Take pointer to map in AsOptionalMap for consistency
- Other `As*` functions take pointers.
- It avoids having to initialize the map passed to the function
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
* Remove double pointer
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
* AsOptionalMap -> CollectMapEntriesWithPrefix
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Go 1.17 introduced a new handy API for setting env vars scoped for
a single test so we can avoid the hard to read set and reset env
loops.
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Add a `map-lease-prefix` prefix for config keys for
`config-leader-election` that is a map from a generated lease prefix
to a new prefix:
```yaml
map-lease-prefix.<component>.<package>.<reconciler_type_name>: <new_prefix>
map-lease-prefix.<component-x>.<package-x>.<reconciler_type_name-x>: <new_prefix>
```
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
If you have a lot of refs in a repo, git will eventually start
condensing them into a single file instead of letting them sprawl out in
separate directories on the filesystem. This change lets the changeset
package use the packed-refs file as a fall back in the event that the
ref file is not found.
See https://git-scm.com/docs/git-pack-refs for more details on packed
refs.
* Continual tests logging within test scope
* Make ThreadSafeBuffer unexported
* logBuffer private on BackgroundContext
* log the buffer in Setup phase on success as well
* Use AddCaller and Development for actual (non-test) logging
* Highlight background logs
* Initial newline for background logs
* Remove space before Background log end
* Style
* Pass LogConfig instead of Log
* Introduce new typ Configuration.LogConfig that is accepted by the Execute function. This
type holds the zap logger configuration and a custom build function for producing
the resulting logger.
* The zap Config can be reused to produce the internal logger for background tests. This
way the background logger can share most configuration with the main framework logger.
* Keep the Configuration.Log variable for backwards compatibility reasons. It's used when
no Configuration.LogConfig is defined.
* Modify tests to use a background test logger in Continual/Background tests
so that we can verify those tests are executed correctly.
* Review changes
* Wrapping logs back to testing.T
* Write background logs before AND after Verify phase
* To prevent losing background logs when the Verify phase calls t.Fail
or t.Skip
* Use InMemoryLogger in setup phase as well
* that's where the logger is passed to tests and its background
operations (e.g. prober)
* Verify background logs for skipped test
* Add TestFailAtBackgroundVerification and rename the test file
* the file now includes more tests for the background verification
phase, not just "skip"
* Simplify verifyBackgroundLogs and remove redundant suffix for logs
* Better zap Config default value
* Override output paths if set to default value
* Do not pass zap.Config by reference
* Trigger checks
Co-authored-by: Chris Suszyński <ksuszyns@redhat.com>
When the admission request is for a resource with an empty string as
group, which happens on core resources, the `creator` or `lastModifier`
annotations are invalid since they become `/creator` or
`/lastModifier`.
This patch removes the `/` when group = `""`.
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
storage-version-migration-serving crashes if ksvc deleted during
migration.
Please refer to the following error especially
`services.serving.knative.dev \"receiver261\" not found` message.
```
{"severity":"INFO","timestamp":"2022-01-25T14:17:19.840090884Z","caller":"logging/config.go:116","message":"Successfully created the logger."}
{"severity":"INFO","timestamp":"2022-01-25T14:17:19.840350704Z","caller":"logging/config.go:117","message":"Logging level set to: info"}
{"severity":"INFO","timestamp":"2022-01-25T14:17:19.840399959Z","caller":"logging/config.go:79","message":"Fetch GitHub commit ID from kodata failed","error":"\"KO_DATA_PATH\" does not exist or is empty"}
{"severity":"INFO","timestamp":"2022-01-25T14:17:19.854296148Z","logger":"storage-migrator","caller":"migrate/main.go:60","message":"Migrating 4 group resources"}
{"severity":"INFO","timestamp":"2022-01-25T14:17:19.85439718Z","logger":"storage-migrator","caller":"migrate/main.go:63","message":"Migrating group resource services.serving.knative.dev"}
{"severity":"EMERGENCY","timestamp":"2022-01-25T14:17:47.601002153Z","logger":"storage-migrator","caller":"migrate/main.go:65","message":"Failed to migrate: unable to patch resource kc-broker-newsubs-kn-0/receiver261 (gvr: serving.knative.dev/v1, Resource=services) - services.serving.knative.dev \"receiver261\" not found","stacktrace":"main.main\n\t/opt/app-root/src/go/src/knative.dev/serving/vendor/knative.dev/pkg/apiextensions/storageversion/cmd/migrate/main.go:65\nruntime.main\n\t/usr/lib/golang/src/runtime/proc.go:255"}
```
It could be a rare case but it happens when an user delete their
resource during storage-version-migration-serving is running.
This patch fixes the issue by ignoring the NotFound error during
patching resources.
Errors from the tracker or the addressable resolver factory
are discarded which isn't helpful for debugging since the
error is generic `kafkachannels "Lister" not found`.
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
* Add support for callback defaults
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Put unstr object in ctx and set user info
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Move get callback at the top
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Panic when using delete verb
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Split tests and add callback ctx tests
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Set user info annotations
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Register Webhook Rules from callbacks
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Adapt unstructured objects to apis.HasSpec
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
* Change json tag name to match struct field name
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
bumping knative.dev/hack f08cb0d...59b0cf1:
> 59b0cf1 Proper search for tags in Go files only (# 135)
Signed-off-by: Knative Automation <automation@knative.team>