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

Revamp FlightRecorder API #72

Merged
merged 11 commits into from
Mar 24, 2020
2 changes: 1 addition & 1 deletion .osdk-scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ scorecard:
cr-manifest:
- "deploy/crds/rhjmc.redhat.com_v1alpha1_containerjfr_cr.yaml"
- "deploy/crds/rhjmc.redhat.com_v1alpha1_flightrecorder_cr.yaml"
csv-path: "deploy/olm-catalog/container-jfr-operator-bundle/0.3.0/container-jfr-operator-bundle.v0.3.0.clusterserviceversion.yaml"
csv-path: "deploy/olm-catalog/container-jfr-operator-bundle/0.4.0/container-jfr-operator-bundle.v0.4.0.clusterserviceversion.yaml"
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IMAGE_STREAM ?= quay.io/rh-jmc-team/container-jfr-operator
IMAGE_VERSION ?= 0.3.0
IMAGE_VERSION ?= 0.4.0
IMAGE_TAG ?= $(IMAGE_STREAM):$(IMAGE_VERSION)

BUNDLE_STREAM ?= $(IMAGE_STREAM)-bundle
Expand Down Expand Up @@ -115,6 +115,7 @@ deploy: undeploy
oc create -f deploy/role.yaml
oc create -f deploy/role_binding.yaml
oc create -f deploy/crds/rhjmc.redhat.com_flightrecorders_crd.yaml
oc create -f deploy/crds/rhjmc.redhat.com_recordings_crd.yaml
oc create -f deploy/crds/rhjmc.redhat.com_containerjfrs_crd.yaml
sed -e 's|REPLACE_IMAGE|$(IMAGE_TAG)|g' deploy/dev_operator.yaml | oc create -f -
oc set env deployment/container-jfr-operator TLS_VERIFY=false
Expand All @@ -134,6 +135,7 @@ undeploy: undeploy_sample_app undeploy_sample_app2
- oc delete rolebinding container-jfr-operator
- oc delete serviceaccount container-jfr-operator
- oc delete crd flightrecorders.rhjmc.redhat.com
- oc delete crd recordings.rhjmc.redhat.com
- oc delete crd containerjfrs.rhjmc.redhat.com
- oc delete -f deploy/olm-catalog/catalog-source.yaml

Expand Down
146 changes: 94 additions & 52 deletions deploy/crds/rhjmc.redhat.com_flightrecorders_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,71 +31,112 @@ spec:
spec:
description: FlightRecorderSpec defines the desired state of FlightRecorder
properties:
port:
description: JMX port for target JVM
format: int32
type: integer
recordingRequests:
description: Requests to create new flight recordings
items:
description: RecordingRequest allows the user to specify new recordings
for Container JFR to create
properties:
duration:
description: The requested total duration of the recording
type: string
eventOptions:
description: 'A list of event options to use when creating the
recording. These are used to enable and fine-tune individual
events. Examples: "jdk.ExecutionSample:enabled=true", "jdk.ExecutionSample:period=200ms"'
items:
type: string
type: array
name:
description: Name of the recording to be created
recordingSelector:
description: Recordings that match this selector belong to this FlightRecorder
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that contains
values, a key, and an operator that relates the key and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to a
set of values. Valid operators are In, NotIn, Exists and
DoesNotExist.
type: string
values:
description: values is an array of string values. If the operator
is In or NotIn, the values array must be non-empty. If the
operator is Exists or DoesNotExist, the values array must
be empty. This array is replaced during a strategic merge
patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
required:
- duration
- eventOptions
- name
type: object
type: array
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator is
"In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
required:
- port
- recordingRequests
- recordingSelector
type: object
status:
description: FlightRecorderStatus defines the observed state of FlightRecorder
properties:
recordings:
description: Lists all recordings for the pod/service that may be downloaded
events:
description: Listing of events available in the target JVM
items:
description: RecordingInfo contains the status of recordings that
have already been created by Container JFR
description: EventInfo contains metadata for a JFR event type
properties:
active:
description: Whether the recording is currently running
type: boolean
downloadUrl:
description: A URL to download the JFR file for the recording
type: string
duration:
description: The duration of the recording specified during creation
category:
description: A hierarchical category used to organize related
event types
items:
type: string
type: array
description:
description: A description detailing what this event does
type: string
name:
description: Name of the created recording
description: Human-readable name for this type of event
type: string
startTime:
description: The date/time when the recording started
format: date-time
options:
additionalProperties:
description: OptionDescriptor contains metadata for an option
for a particular event type
properties:
defaultValue:
description: The value implicitly used when this option
isn't specified
type: string
description:
description: A description of what this option does
type: string
name:
description: Human-readable name for this option
type: string
required:
- defaultValue
- description
- name
type: object
description: Options that may be used to tune this event. This
map is indexed by the option IDs.
type: object
typeId:
description: The ID used by JFR to uniquely identify this event
type
type: string
required:
- active
- duration
- category
- description
- name
- startTime
- options
- typeId
type: object
type: array
port:
description: JMX port for target JVM
format: int32
minimum: 0
type: integer
target:
description: Reference to the pod/service that this object controls
JFR for
Expand Down Expand Up @@ -134,12 +175,13 @@ spec:
type: string
type: object
required:
- recordings
- events
- port
- target
type: object
type: object
version: v1alpha1
version: v1alpha2
versions:
- name: v1alpha1
- name: v1alpha2
served: true
storage: true
104 changes: 104 additions & 0 deletions deploy/crds/rhjmc.redhat.com_recordings_crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: recordings.rhjmc.redhat.com
spec:
group: rhjmc.redhat.com
names:
kind: Recording
listKind: RecordingList
plural: recordings
singular: recording
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: Recording is the Schema for the recordings API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: RecordingSpec defines the desired state of Recording
properties:
archive:
description: Whether this recording should be saved to persistent storage.
If true, the JFR file will be retained until this object is deleted.
If false, the JFR file will be deleted when its corresponding JVM
exits.
type: boolean
duration:
description: The requested total duration of the recording, a zero value
will record indefinitely.
type: string
eventOptions:
description: 'A list of event options to use when creating the recording.
These are used to enable and fine-tune individual events. Examples:
"jdk.ExecutionSample:enabled=true", "jdk.ExecutionSample:period=200ms"'
items:
type: string
type: array
flightRecorder:
description: Reference to the FlightRecorder object that corresponds
to this Recording
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
name:
description: Name of the recording to be created.
type: string
state:
description: Desired state of the recording. If omitted, RUNNING will
be assumed.
enum:
- RUNNING
- STOPPED
type: string
required:
- archive
- duration
- eventOptions
- flightRecorder
- name
type: object
status:
description: RecordingStatus defines the observed state of Recording
properties:
downloadURL:
description: A URL to download the JFR file for the recording.
type: string
duration:
description: The duration of the recording specified during creation.
type: string
startTime:
description: The date/time when the recording started.
format: date-time
type: string
state:
description: Current state of the recording.
enum:
- CREATED
- RUNNING
- STOPPING
- STOPPED
type: string
type: object
type: object
version: v1alpha2
versions:
- name: v1alpha2
served: true
storage: true
7 changes: 0 additions & 7 deletions deploy/crds/rhjmc.redhat.com_v1alpha1_flightrecorder_cr.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions deploy/crds/rhjmc.redhat.com_v1alpha2_flightrecorder_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: rhjmc.redhat.com/v1alpha2
kind: FlightRecorder
metadata:
name: example-flightrecorder
spec:
recordingSelector:
matchLabels:
rhjmc.redhat.com/flightrecorder: example-flightrecorder
11 changes: 11 additions & 0 deletions deploy/crds/rhjmc.redhat.com_v1alpha2_recording_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rhjmc.redhat.com/v1alpha2
kind: Recording
metadata:
name: example-recording
spec:
name: example-recording
eventOptions: [ ALL ]
duration: 30s
archive: true
flightRecorder:
name: example-flightrecorder
Loading