Skip to content

Commit

Permalink
chore(discovery): ensure consistent names for discovery options in CRD
Browse files Browse the repository at this point in the history
Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
  • Loading branch information
tthvo committed May 22, 2024
1 parent ad96512 commit b00ef09
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 29 deletions.
4 changes: 2 additions & 2 deletions api/v1beta1/cryostat_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func convertTargetDiscoveryTo(srcOpts *TargetDiscoveryOptions) *operatorv1beta2.
var dstOpts *operatorv1beta2.TargetDiscoveryOptions
if srcOpts != nil {
dstOpts = &operatorv1beta2.TargetDiscoveryOptions{
BuiltInDiscoveryDisabled: srcOpts.BuiltInDiscoveryDisabled,
DisableBuiltInDiscovery: srcOpts.BuiltInDiscoveryDisabled,
DisableBuiltInPortNames: srcOpts.DisableBuiltInPortNames,
DiscoveryPortNames: srcOpts.DiscoveryPortNames,
DisableBuiltInPortNumbers: srcOpts.DisableBuiltInPortNumbers,
Expand Down Expand Up @@ -507,7 +507,7 @@ func convertTargetDiscoveryFrom(srcOpts *operatorv1beta2.TargetDiscoveryOptions)
var dstOpts *TargetDiscoveryOptions
if srcOpts != nil {
dstOpts = &TargetDiscoveryOptions{
BuiltInDiscoveryDisabled: srcOpts.BuiltInDiscoveryDisabled,
BuiltInDiscoveryDisabled: srcOpts.DisableBuiltInDiscovery,
DisableBuiltInPortNames: srcOpts.DisableBuiltInPortNames,
DiscoveryPortNames: srcOpts.DiscoveryPortNames,
DisableBuiltInPortNumbers: srcOpts.DisableBuiltInPortNumbers,
Expand Down
6 changes: 3 additions & 3 deletions api/v1beta2/cryostat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,16 @@ type TargetDiscoveryOptions struct {
// When true, the Cryostat application will disable the built-in discovery mechanisms. Defaults to false
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Disable Built-in Discovery",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
BuiltInDiscoveryDisabled bool `json:"builtInDiscoveryDisabled,omitempty"`
// When true, the Cryostat application will use the default port name jfr-jmx to look for JMX connectable targets.
DisableBuiltInDiscovery bool `json:"disableBuiltInDiscovery,omitempty"`
// When false and discoveryPortNames is empty, the Cryostat application will use the default port name jfr-jmx to look for JMX connectable targets. Defaults to false.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Disable Built-in Port Names",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
DisableBuiltInPortNames bool `json:"disableBuiltInPortNames,omitempty"`
// List of port names that the Cryostat application should look for in order to consider a target as JMX connectable.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:fieldDependency:targetDiscoveryOptions.disableBuiltInPortNames:true"}
DiscoveryPortNames []string `json:"discoveryPortNames,omitempty"`
// When true, the Cryostat application will use the default port number 9091 to look for JMX connectable targets.
// When false and discoveryPortNumbers is empty, the Cryostat application will use the default port number 9091 to look for JMX connectable targets. Defaults to false.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Disable Built-in Port Numbers",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
DisableBuiltInPortNumbers bool `json:"disableBuiltInPortNumbers,omitempty"`
Expand Down
14 changes: 8 additions & 6 deletions bundle/manifests/cryostat-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ metadata:
capabilities: Seamless Upgrades
categories: Monitoring, Developer Tools
containerImage: quay.io/cryostat/cryostat-operator:3.0.0-dev
createdAt: "2024-05-20T05:12:58Z"
createdAt: "2024-05-22T05:20:41Z"
description: JVM monitoring and profiling tool
operatorframework.io/initialization-resource: |-
{
Expand Down Expand Up @@ -842,17 +842,19 @@ spec:
- description: When true, the Cryostat application will disable the built-in
discovery mechanisms. Defaults to false
displayName: Disable Built-in Discovery
path: targetDiscoveryOptions.builtInDiscoveryDisabled
path: targetDiscoveryOptions.disableBuiltInDiscovery
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: When true, the Cryostat application will use the default port
name jfr-jmx to look for JMX connectable targets.
- description: When false and discoveryPortNames is empty, the Cryostat application
will use the default port name jfr-jmx to look for JMX connectable targets.
Defaults to false.
displayName: Disable Built-in Port Names
path: targetDiscoveryOptions.disableBuiltInPortNames
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: When true, the Cryostat application will use the default port
number 9091 to look for JMX connectable targets.
- description: When false and discoveryPortNumbers is empty, the Cryostat application
will use the default port number 9091 to look for JMX connectable targets.
Defaults to false.
displayName: Disable Built-in Port Numbers
path: targetDiscoveryOptions.disableBuiltInPortNumbers
x-descriptors:
Expand Down
12 changes: 7 additions & 5 deletions bundle/manifests/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9711,17 +9711,19 @@ spec:
description: Options to configure the Cryostat application's target
discovery mechanisms.
properties:
builtInDiscoveryDisabled:
disableBuiltInDiscovery:
description: When true, the Cryostat application will disable
the built-in discovery mechanisms. Defaults to false
type: boolean
disableBuiltInPortNames:
description: When true, the Cryostat application will use the
default port name jfr-jmx to look for JMX connectable targets.
description: When false and discoveryPortNames is empty, the Cryostat
application will use the default port name jfr-jmx to look for
JMX connectable targets. Defaults to false.
type: boolean
disableBuiltInPortNumbers:
description: When true, the Cryostat application will use the
default port number 9091 to look for JMX connectable targets.
description: When false and discoveryPortNumbers is empty, the
Cryostat application will use the default port number 9091 to
look for JMX connectable targets. Defaults to false.
type: boolean
discoveryPortNames:
description: List of port names that the Cryostat application
Expand Down
12 changes: 7 additions & 5 deletions config/crd/bases/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9701,17 +9701,19 @@ spec:
description: Options to configure the Cryostat application's target
discovery mechanisms.
properties:
builtInDiscoveryDisabled:
disableBuiltInDiscovery:
description: When true, the Cryostat application will disable
the built-in discovery mechanisms. Defaults to false
type: boolean
disableBuiltInPortNames:
description: When true, the Cryostat application will use the
default port name jfr-jmx to look for JMX connectable targets.
description: When false and discoveryPortNames is empty, the Cryostat
application will use the default port name jfr-jmx to look for
JMX connectable targets. Defaults to false.
type: boolean
disableBuiltInPortNumbers:
description: When true, the Cryostat application will use the
default port number 9091 to look for JMX connectable targets.
description: When false and discoveryPortNumbers is empty, the
Cryostat application will use the default port number 9091 to
look for JMX connectable targets. Defaults to false.
type: boolean
discoveryPortNames:
description: List of port names that the Cryostat application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,19 @@ spec:
- description: When true, the Cryostat application will disable the built-in
discovery mechanisms. Defaults to false
displayName: Disable Built-in Discovery
path: targetDiscoveryOptions.builtInDiscoveryDisabled
path: targetDiscoveryOptions.disableBuiltInDiscovery
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: When true, the Cryostat application will use the default port
name jfr-jmx to look for JMX connectable targets.
- description: When false and discoveryPortNames is empty, the Cryostat application
will use the default port name jfr-jmx to look for JMX connectable targets.
Defaults to false.
displayName: Disable Built-in Port Names
path: targetDiscoveryOptions.disableBuiltInPortNames
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: When true, the Cryostat application will use the default port
number 9091 to look for JMX connectable targets.
- description: When false and discoveryPortNumbers is empty, the Cryostat application
will use the default port number 9091 to look for JMX connectable targets.
Defaults to false.
displayName: Disable Built-in Port Numbers
path: targetDiscoveryOptions.disableBuiltInPortNumbers
x-descriptors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ func NewCoreContainer(cr *model.CryostatInstance, specs *ServiceSpecs, imageTag
k8sDiscoveryPortNames := "jfr-jmx"
k8sDiscoveryPortNumbers := "9091"
if cr.Spec.TargetDiscoveryOptions != nil {
k8sDiscoveryEnabled = !cr.Spec.TargetDiscoveryOptions.BuiltInDiscoveryDisabled
k8sDiscoveryEnabled = !cr.Spec.TargetDiscoveryOptions.DisableBuiltInDiscovery

if len(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNames) > 0 {
k8sDiscoveryPortNames = strings.Join(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNames[:], ",")
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,7 @@ func (t *cryostatTestInput) checkMainPodTemplate(deployment *appsv1.Deployment,
hasPortConfig := cr.Spec.TargetDiscoveryOptions != nil &&
len(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNames) > 0 &&
len(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNumbers) > 0
builtInDiscoveryDisabled := cr.Spec.TargetDiscoveryOptions != nil && cr.Spec.TargetDiscoveryOptions.BuiltInDiscoveryDisabled
builtInDiscoveryDisabled := cr.Spec.TargetDiscoveryOptions != nil && cr.Spec.TargetDiscoveryOptions.DisableBuiltInDiscovery
builtInPortConfigDisabled := cr.Spec.TargetDiscoveryOptions != nil &&
cr.Spec.TargetDiscoveryOptions.DisableBuiltInPortNames &&
cr.Spec.TargetDiscoveryOptions.DisableBuiltInPortNumbers
Expand Down
2 changes: 1 addition & 1 deletion internal/test/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func (r *TestResources) NewCryostatWithLowResourceLimit() *model.CryostatInstanc
func (r *TestResources) NewCryostatWithBuiltInDiscoveryDisabled() *model.CryostatInstance {
cr := r.NewCryostat()
cr.Spec.TargetDiscoveryOptions = &operatorv1beta2.TargetDiscoveryOptions{
BuiltInDiscoveryDisabled: true,
DisableBuiltInDiscovery: true,
}
return cr
}
Expand Down

0 comments on commit b00ef09

Please sign in to comment.