Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETOBSERV-971 Fix couple of CRD issues on zero-values #319

Merged
merged 2 commits into from Apr 27, 2023

Conversation

jotak
Copy link
Member

@jotak jotak commented Apr 3, 2023

CRD cleanup / sanitizing

Find & fix a bunch of CRD issues where go zero-value was conflicting
with CRD default. The typical workaround is to use pointers or, for
lists and maps, remove "omitempty".

Add a test to help catch these issues

Found issues:

  • portNamings.enable (this was the original issue)
  • portNamings.portNames (could not set empty list)
  • ebpf.interfaces and excludeInterfaces (e.g. could not set empty exclusion
    list)
  • processor.metrics.ignoreTags and disableAlerts (could not set empty
    ignoreTags)
  • processor.enableKubeProbles, dropUnusedFields (could not set false)
  • processor.kafkaConsumerReplicas (could not set 0)
  • loki.maxRetries (could not set 0)
  • loki.staticLabels (could not set empty list)
  • plugin.register (could not set false)
  • plugin.replicas (could not set 0)
  • plugin.quickFilters (could not set empry list)

Copy link
Contributor

@OlivierCazade OlivierCazade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, but I would suggest a different fix.

We have many others bool in the API and removing all of them the omitempty flag would create a lot of unnecessary mandatory fields.

After some test it would also work if we let the omitempty flag but swithc to a bool pointer.

The downside is we would have to check for nil each time which can be done in a sugar function but the good side is that we would keep the field optional in the API.

@jotak jotak changed the title NETOBSERV-971 remove omitempty on portNames.enable NETOBSERV-971 Fix couple of CRD issues on zero-values Apr 4, 2023
@jotak jotak requested a review from OlivierCazade April 4, 2023 10:50
@jotak
Copy link
Member Author

jotak commented Apr 4, 2023

@OlivierCazade I reviewed the whole CRD ... which leads to a bigger pull request

@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Merging #319 (6948a3a) into main (949256f) will increase coverage by 0.44%.
The diff coverage is 54.00%.

@@            Coverage Diff             @@
##             main     #319      +/-   ##
==========================================
+ Coverage   50.90%   51.34%   +0.44%     
==========================================
  Files          43       43              
  Lines        5080     5155      +75     
==========================================
+ Hits         2586     2647      +61     
- Misses       2293     2310      +17     
+ Partials      201      198       -3     
Flag Coverage Δ
unittests 51.34% <54.00%> (+0.44%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
api/v1alpha1/flowcollector_types.go 100.00% <ø> (ø)
api/v1alpha1/zz_generated.conversion.go 0.26% <0.00%> (-0.01%) ⬇️
api/v1beta1/flowcollector_types.go 100.00% <ø> (ø)
...rollers/flowlogspipeline/flp_transfo_reconciler.go 60.58% <0.00%> (ø)
pkg/helper/flowcollector.go 72.58% <70.00%> (-0.50%) ⬇️
api/v1beta1/zz_generated.deepcopy.go 53.41% <100.00%> (+6.75%) ⬆️
controllers/consoleplugin/consoleplugin_objects.go 93.84% <100.00%> (ø)
...trollers/consoleplugin/consoleplugin_reconciler.go 64.73% <100.00%> (+1.77%) ⬆️
controllers/flowlogspipeline/flp_common_objects.go 85.25% <100.00%> (ø)
...ontrollers/flowlogspipeline/flp_transfo_objects.go 93.75% <100.00%> (ø)
... and 1 more

... and 2 files with indirect coverage changes

OlivierCazade
OlivierCazade previously approved these changes Apr 4, 2023
Copy link
Contributor

@OlivierCazade OlivierCazade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and sorry for my previous comment. After discussion, your previous solution would have worked.

Copy link
Contributor

@msherif1234 msherif1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pls consider using "k8s.io/utils/pointer to convert from type to *type
for Example

pointer.IntPtr(0)

@msherif1234
Copy link
Contributor

/lgtm

@jotak
Copy link
Member Author

jotak commented Apr 14, 2023

/approve

@jotak jotak added ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. and removed approved labels Apr 14, 2023
@jotak
Copy link
Member Author

jotak commented Apr 14, 2023

/approve cancel

@github-actions
Copy link

New images:

  • quay.io/netobserv/network-observability-operator:908f029
  • quay.io/netobserv/network-observability-operator-bundle:v0.0.0-908f029
  • quay.io/netobserv/network-observability-operator-catalog:v0.0.0-908f029

They will expire after two weeks.

Catalog source:

apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: netobserv-dev
  namespace: openshift-marketplace
spec:
  sourceType: grpc
  image: quay.io/netobserv/network-observability-operator-catalog:v0.0.0-908f029
  displayName: NetObserv development catalog
  publisher: Me
  updateStrategy:
    registryPoll:
      interval: 1m

@openshift-ci openshift-ci bot removed the lgtm label Apr 19, 2023
@github-actions github-actions bot removed the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Apr 19, 2023
@Amoghrd
Copy link
Contributor

Amoghrd commented Apr 20, 2023

/ok-to-test

@openshift-ci openshift-ci bot added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Apr 20, 2023
@github-actions
Copy link

New images:

  • quay.io/netobserv/network-observability-operator:32a550d
  • quay.io/netobserv/network-observability-operator-bundle:v0.0.0-32a550d
  • quay.io/netobserv/network-observability-operator-catalog:v0.0.0-32a550d

They will expire after two weeks.

Catalog source:

apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: netobserv-dev
  namespace: openshift-marketplace
spec:
  sourceType: grpc
  image: quay.io/netobserv/network-observability-operator-catalog:v0.0.0-32a550d
  displayName: NetObserv development catalog
  publisher: Me
  updateStrategy:
    registryPoll:
      interval: 1m

@Amoghrd
Copy link
Contributor

Amoghrd commented Apr 20, 2023

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved QE has approved this pull request label Apr 20, 2023
OlivierCazade
OlivierCazade previously approved these changes Apr 24, 2023
@openshift-ci openshift-ci bot added the lgtm label Apr 24, 2023
CRD cleanup / sanitizing

Find & fix a bunch of CRD issues where go zero-value was conflicting
with CRD default. The typical workaround is to use pointers or, for
lists and maps, remove "omitempty".

Add a test to help catch these issues

Found issues:
- portNamings.enable (this was the original issue)
- portNamings.portNames (could not set empty list)
- ebpf.interfaces and excludeInterfaces (e.g. could not set empty exclusion
  list)
- processor.metrics.ignoreTags and disableAlerts (could not set empty
  ignoreTags)
- processor.enableKubeProbles, dropUnusedFields (could not set false)
- processor.kafkaConsumerReplicas (could not set 0)
- loki.maxRetries (could not set 0)
- loki.staticLabels (could not set empty list)
- plugin.register (could not set false)
- plugin.replicas (could not set 0)
- plugin.quickFilters (could not set empry list)
@openshift-ci
Copy link

openshift-ci bot commented Apr 27, 2023

New changes are detected. LGTM label has been removed.

@github-actions github-actions bot removed the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Apr 27, 2023
@jpinsonneau
Copy link
Contributor

/approve

@openshift-ci
Copy link

openshift-ci bot commented Apr 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jpinsonneau

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit c2c2961 into netobserv:main Apr 27, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm qe-approved QE has approved this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants