-
Notifications
You must be signed in to change notification settings - Fork 25
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-1182 added cluster name to flp configuration #386
NETOBSERV-1182 added cluster name to flp configuration #386
Conversation
Codecov Report
@@ Coverage Diff @@
## main #386 +/- ##
==========================================
+ Coverage 53.67% 56.02% +2.34%
==========================================
Files 44 45 +1
Lines 5559 5865 +306
==========================================
+ Hits 2984 3286 +302
- Misses 2359 2362 +3
- Partials 216 217 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
api/v1beta1/flowcollector_types.go
Outdated
//+kubebuilder:default:="defaultCluster" | ||
// +optional | ||
// `clusterName` is the name of the cluster. | ||
ClusterName string `json:"clusterName,omitempty"` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Openshift we can automatically retreive ClusterID
from api
https://pkg.go.dev/github.com/openshift/api@v0.0.0-20230707160225-81d582da354b/config/v1#ClusterID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//+kubebuilder:default:="defaultCluster" | |
// +optional | |
// `clusterName` is the name of the cluster. | |
ClusterName string `json:"clusterName,omitempty"` | |
//+kubebuilder:default:="" | |
// +optional | |
// `clusterName` is the name of the cluster. | |
ClusterName string `json:"clusterName,omitempty"` | |
I would suggest to set default as empty to avoid FLP extra stage for single cluster usage. WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we automatically retrieve clusterID from openshift when clusterName is blank, we really cannot distinguish between single cluster vs multi-cluster. To distinguish between them, we would have to add an explicit parameter to the flowcollector config file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default set to empty.
@@ -45,6 +45,7 @@ const ( | |||
conntrackTerminatingTimeout = 5 * time.Second | |||
conntrackEndTimeout = 10 * time.Second | |||
conntrackHeartbeatInterval = 30 * time.Second | |||
clusterNameDefault = "defaultCluster" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clusterNameDefault = "defaultCluster" |
following previous comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed default to blank, but in that case we take the clusterName from Openshift.
@@ -310,15 +311,29 @@ func (b *builder) addTransformStages(stage *config.PipelineBuilderStage) (*corev | |||
lastStage := *stage | |||
indexFields := constants.LokiIndexFields | |||
|
|||
clusterName := clusterNameDefault |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clusterName := clusterNameDefault | |
clusterName := "" |
following previous comment
@@ -351,7 +351,7 @@ metadata: | |||
capabilities: Seamless Upgrades | |||
categories: Monitoring | |||
console.openshift.io/plugins: '["netobserv-plugin"]' | |||
containerImage: quay.io/netobserv/network-observability-operator:1.0.3 | |||
containerImage: quay.io/meth/network-observability-operator:main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can run make update-bundle
to avoid this 😸
network-observability-operator/Makefile
Lines 325 to 327 in 84c7fe8
.PHONY: update-bundle | |
update-bundle: IMG=$(IMAGE_TAG_BASE):$(OPERATOR_VERSION) | |
update-bundle: bundle ## Prepare a clean bundle to be commited |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
//take clustername from openshift | ||
clusterName = string(constants.DefaultClusterID) | ||
} | ||
transformFilterRules := []api.TransformFilterRule{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClusterName can be empty (e.g. if not setup in CR and not running on openshift) => in that case, I think we should not create this rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
api/v1beta1/flowcollector_types.go
Outdated
@@ -436,6 +436,11 @@ type FlowCollectorFLP struct { | |||
// `conversationTerminatingTimeout` is the time to wait from detected FIN flag to end a conversation. Only relevant for TCP flows. | |||
ConversationTerminatingTimeout *metav1.Duration `json:"conversationTerminatingTimeout,omitempty"` | |||
|
|||
//+kubebuilder:default:="" | |||
// +optional | |||
// `clusterName` is the name of the cluster. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a user-facing doc, it deserves some explanation, example:
// `clusterName` is the name of the cluster. | |
// `clusterName` is the name of the cluster to appear in the flows data. This is useful in a multi-cluster context. When using OpenShift, leave empty to make it automatically determined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
cversion := &configv1.ClusterVersion{} | ||
key := client.ObjectKey{Name: "version"} | ||
if err := r.Client.Get(ctx, key, cversion); err != nil { | ||
log.Error(err, "unable to obtain cluster ID") | ||
} else { | ||
constants.DefaultClusterID = cversion.Spec.ClusterID | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block should be run only once, and only for openshift. To do so you can wrap it in a block if r.permissions.Vendor(ctx) == discover.VendorOpenShift && constants.DefaultClusterID == "" {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it is unexpected to update a "constant". I would move DefaultClusterID
somewhere else. For instance, it could be part of the FlowCollectorReconciler
struct, and passed down to reconcilers via newCommonInfo
; or if you prefer to keep a global access, maybe create a new file globals.go
in package reconcilers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to pass down the clusterName through the series of function calls it would have required many changes and would have made the code ugly. I therefore made it into a global, as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's ok
The "CommonInfo" is already done in that purpose, to be passed to the reconcilers, so you wouldn't have to change all the function signatures, just adding it to a struct that is already spread across reconcilers.
But that's ok with the global approach - as long as not everything ends up like that, which would denote a lack of modularity and makes sometimes testing more difficult
} | ||
transformFilterRules := []api.TransformFilterRule{ | ||
{ | ||
Input: "clusterName", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the same pattern as the other fields, ie:
Input: "clusterName", | |
Input: "K8S_ClusterName", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
New images:
They will expire after two weeks. To deploy this build: # Direct deployment, from operator repo
IMAGE=quay.io/netobserv/network-observability-operator:30c2fdc make deploy
# Or using operator-sdk
operator-sdk run bundle quay.io/netobserv/network-observability-operator-bundle:v0.0.0-30c2fdc Or as a 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-30c2fdc
displayName: NetObserv development catalog
publisher: Me
updateStrategy:
registryPoll:
interval: 1m |
/lgtm PS : looks like the linter is unhappy due to high cyclomatic ... |
2dbc9af
to
1179cc9
Compare
I refactored a bit to make the linter happy. |
Thanks ! |
@KalmanMeth @jotak Can we re-add ok-to-test? |
New images:
They will expire after two weeks. To deploy this build: # Direct deployment, from operator repo
IMAGE=quay.io/netobserv/network-observability-operator:d93080e make deploy
# Or using operator-sdk
operator-sdk run bundle quay.io/netobserv/network-observability-operator-bundle:v0.0.0-d93080e Or as a 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-d93080e
displayName: NetObserv development catalog
publisher: Me
updateStrategy:
registryPoll:
interval: 1m |
1179cc9
to
6b70f0e
Compare
performed rebase |
New images:
They will expire after two weeks. To deploy this build: # Direct deployment, from operator repo
IMAGE=quay.io/netobserv/network-observability-operator:1a0da20 make deploy
# Or using operator-sdk
operator-sdk run bundle quay.io/netobserv/network-observability-operator-bundle:v0.0.0-1a0da20 Or as a 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-1a0da20
displayName: NetObserv development catalog
publisher: Me
updateStrategy:
registryPoll:
interval: 1m |
/lgtm |
/label qe-approved Basic testing looks good, can continue QE post-merge |
/approve |
[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 |
Added transform_filter to flp pipeline to add a clusterName field to flow logs.
clusterName is taken from config file. If blank, take clusterID from clusterVersion struct.