Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
65d209c
Phase 1: CRD and Initial Structure
Apr 29, 2025
e9b798a
Phase 1: update chart and config examples
Apr 29, 2025
f343dcc
Phase 2: StatefulSet Implementation
Apr 29, 2025
9bff8c2
Update documentation with statefulset
Apr 29, 2025
f000a8e
Phase 3: Testing
Apr 29, 2025
4f3ebf2
Fix formatting in lightrun-secret.yaml by adding a newline at the end…
Apr 29, 2025
0ee5505
Add newline at the end of statefulset-lightrunjavaagent.yaml for cons…
Apr 29, 2025
2cf6070
Remove redundant memory option from JAVA_TOOL_OPTIONS in statefulset.…
Apr 29, 2025
585ac87
Remove trailing whitespace in statefulset-lightrunjavaagent.yaml
Apr 29, 2025
dc55550
Revert WorkloadStatus field to DeploymentStatus to keep backward comp…
Apr 30, 2025
de2ba95
removing TODO comment regarding DeploymentStatus field
May 4, 2025
1d5c1f2
Update CRD and example files to replace 'WorkloadStatus' with 'Deploy…
May 4, 2025
191419b
Refactor config map data hash calculation in lightrunjavaagent_contro…
May 4, 2025
9115f02
Add WorkloadType and WorkloadName support in lightrunjavaagent_types.…
May 13, 2025
124b19f
Update instance status field from DeploymentStatus to WorkloadStatus …
May 13, 2025
21978cb
Refactor LightrunJavaAgent reconciliation logic to support new Worklo…
May 13, 2025
a104886
Update LightrunJavaAgent controller tests to reflect changes in workl…
May 14, 2025
4a18f67
Update .gitignore to include macOS .DS_Store files and remove depreca…
May 14, 2025
b8d4a04
Update CRDs and example files to replace Deployment and StatefulSet r…
May 14, 2025
2df1dbc
Enhance documentation in lightrunjavaagent_types.go by clarifying the…
May 14, 2025
56e5f55
Clarify workloadName field description in CRDs and example files to s…
May 14, 2025
05c6fb9
Update LightrunJavaAgent configuration files to replace deploymentNam…
May 14, 2025
44ed3c3
Deprecate DeploymentName field in LightrunJavaAgentSpec, updating doc…
May 14, 2025
924923b
Deprecate deploymentName field in LightrunJavaAgent configuration fil…
May 14, 2025
8c1ad6e
Fix formatting in custom_resource.md by adding a newline at the end o…
May 14, 2025
bb8334d
keep deploymetStatus for bc
May 20, 2025
a712847
simplify determineWorkloadType function per PR's feedback
May 20, 2025
5e1b54d
add checks for missing workloadName in reconcileDeployment and reconc…
May 20, 2025
b948101
update crds
May 20, 2025
52c042c
Improve error messages in reconcileDeployment and reconcileStatefulSe…
May 21, 2025
d462f06
Remove deprecated printcolumn for deploymentName in LightrunJavaAgent…
May 21, 2025
1af59a3
Remove deprecated deploymentName print column from LightrunJavaAgent …
May 21, 2025
33831b3
Update error message in LightrunJavaAgent controller tests to reflect…
May 21, 2025
22505e3
Refactor determineWorkloadType function to improve configuration vali…
May 21, 2025
2a68b3b
Refactor determineWorkloadType function to streamline workload type d…
May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/v1beta/lightrunjavaagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ type LightrunJavaAgentStatus struct {
LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
WorkloadStatus string `json:"workloadStatus,omitempty"`
DeploymentStatus string `json:"deploymentStatus,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=lrja
//+kubebuilder:printcolumn:priority=0,name=Deployment,type=string,JSONPath=".spec.deploymentName",description="Deployment name",format=""
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove this column 😬 and see if we can fill the "Workload" column with deploymenName if using it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As agreed we will remove this column completely

//+kubebuilder:printcolumn:priority=0,name=Workload,type=string,JSONPath=".spec.workloadName",description="Workload name",format=""
//+kubebuilder:printcolumn:priority=0,name=Type,type=string,JSONPath=".spec.workloadType",description="Workload type",format=""
//+kubebuilder:printcolumn:priority=0,name="Status",type=string,JSONPath=".status.workloadStatus",description="Status of Workload Reconciliation",format=""
Expand Down
6 changes: 6 additions & 0 deletions charts/lightrun-operator/crds/lightrunjavaagent_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Deployment name
jsonPath: .spec.deploymentName
name: Deployment
type: string
- description: Workload name
jsonPath: .spec.workloadName
name: Workload
Expand Down Expand Up @@ -210,6 +214,8 @@ spec:
- type
type: object
type: array
deploymentStatus:
type: string
lastScheduleTime:
format: date-time
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/agents.lightrun.com_lightrunjavaagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Deployment name
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

jsonPath: .spec.deploymentName
name: Deployment
type: string
- description: Workload name
jsonPath: .spec.workloadName
name: Workload
Expand Down Expand Up @@ -211,6 +215,8 @@ spec:
- type
type: object
type: array
deploymentStatus:
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this?

Copy link
Contributor Author

@imeliran imeliran May 21, 2025

Choose a reason for hiding this comment

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

it is generated by kubebuilder according to

type LightrunJavaAgentStatus struct {
	LastScheduleTime *metav1.Time       `json:"lastScheduleTime,omitempty"`
	Conditions       []metav1.Condition `json:"conditions,omitempty"`
	WorkloadStatus   string             `json:"workloadStatus,omitempty"`
	DeploymentStatus string             `json:"deploymentStatus,omitempty"`
}

we need to keep DeploymentStatus so we will be able to update Status field accordingly

type: string
lastScheduleTime:
format: date-time
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/samples/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Deployment name
jsonPath: .spec.deploymentName
name: Deployment
type: string
- description: Workload name
jsonPath: .spec.workloadName
name: Workload
Expand Down Expand Up @@ -222,6 +226,8 @@ spec:
- type
type: object
type: array
deploymentStatus:
type: string
lastScheduleTime:
format: date-time
type: string
Expand Down
6 changes: 6 additions & 0 deletions examples/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Deployment name
jsonPath: .spec.deploymentName
name: Deployment
type: string
- description: Workload name
jsonPath: .spec.workloadName
name: Workload
Expand Down Expand Up @@ -212,6 +216,8 @@ spec:
- type
type: object
type: array
deploymentStatus:
type: string
lastScheduleTime:
format: date-time
type: string
Expand Down
2 changes: 2 additions & 0 deletions internal/controller/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (r *LightrunJavaAgentReconciler) successStatus(ctx context.Context, instanc
}
SetStatusCondition(&instance.Status.Conditions, condition)
instance.Status.WorkloadStatus = r.findLastConditionType(&instance.Status.Conditions)
instance.Status.DeploymentStatus = r.findLastConditionType(&instance.Status.Conditions)
err := r.Status().Update(ctx, instance)
if err != nil {
if apierrors.IsConflict(err) {
Expand All @@ -156,6 +157,7 @@ func (r *LightrunJavaAgentReconciler) errorStatus(ctx context.Context, instance
}
SetStatusCondition(&instance.Status.Conditions, condition)
instance.Status.WorkloadStatus = r.findLastConditionType(&instance.Status.Conditions)
instance.Status.DeploymentStatus = r.findLastConditionType(&instance.Status.Conditions)
err := r.Status().Update(ctx, instance)
if err != nil {
if apierrors.IsConflict(err) {
Expand Down
36 changes: 20 additions & 16 deletions internal/controller/lightrunjavaagent_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,30 @@ func (r *LightrunJavaAgentReconciler) Reconcile(ctx context.Context, req ctrl.Re

func (r *LightrunJavaAgentReconciler) determineWorkloadType(lightrunJavaAgent *agentv1beta.LightrunJavaAgent) (agentv1beta.WorkloadType, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, we should support 2 configurations:

  1. deploymentName is set
  2. workloadName and Type are set
    if both are set you fail return an error.

if deploymentName is set you should log a warning that it's deprecated in favor of workloadName and workloadType.

If we agree you can add:
var isDeploymentConfigured bool = spec.DeploymentName != "";
var isWorkloadConfigured bool = spec.WorkloadName != "" || spec.WorkloadType != "";

if both are true/false you return an error.

spec := lightrunJavaAgent.Spec
// Check which configuration approach is being used
var isDeploymentConfigured bool = spec.DeploymentName != ""
var isWorkloadConfigured bool = spec.WorkloadName != "" || spec.WorkloadType != ""
Copy link
Contributor

Choose a reason for hiding this comment

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

should be &&


// === Case 1: Legacy only — DeploymentName only ===
if spec.DeploymentName != "" && spec.WorkloadName == "" && spec.WorkloadType == "" {
if isDeploymentConfigured && !isWorkloadConfigured {
Copy link
Contributor

Choose a reason for hiding this comment

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

based on previous suggestion you can simplify to:
if isDeploymentConfigured

r.Log.Info("Using deprecated field deploymentName, consider migrating to workloadName and workloadType")
return agentv1beta.WorkloadTypeDeployment, nil
}

// === Case 2: New fields — WorkloadName + WorkloadType ===
if spec.DeploymentName == "" && spec.WorkloadName != "" {
if !isDeploymentConfigured && isWorkloadConfigured {
Copy link
Contributor

Choose a reason for hiding this comment

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

based on previous suggestion you can remove the condition here and assume isWorkloadConfigured

if spec.WorkloadType == "" {
return "", errors.New("WorkloadType must be set when using WorkloadName")
return "", errors.New("workloadType must be set when using workloadName")
}
if spec.WorkloadName == "" {
return "", errors.New("workloadName must be set when workloadType is specified")
}
return spec.WorkloadType, nil
}

// === Case 3: Misconfigured — Both names are set ===
if spec.DeploymentName != "" && spec.WorkloadName != "" {
// Same names still ambiguous — rely on workloadType
if spec.DeploymentName == spec.WorkloadName {
if spec.WorkloadType == "" {
return "", errors.New("both DeploymentName and WorkloadName are set and equal; please remove DeploymentName and set workloadType explicitly")
}
return spec.WorkloadType, nil
}
// Names differ — reject as invalid
return "", errors.New("DeploymentName and WorkloadName are both set but differ; please use only WorkloadName with WorkloadType")
// === Case 3: Misconfigured — Both fields exists or both are empty ===
if isDeploymentConfigured && isWorkloadConfigured {
return "", errors.New("invalid configuration: use either deploymentName (legacy) OR workloadName with workloadType, not both")
}

// === Case 4: Fully empty or malformed ===
Expand All @@ -126,7 +125,9 @@ func (r *LightrunJavaAgentReconciler) reconcileDeployment(ctx context.Context, l
// Fall back to legacy field if WorkloadName isn't set
deploymentName = lightrunJavaAgent.Spec.DeploymentName
}

if deploymentName == "" {
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("unable to reconcile deployment: missing workloadName or deploymentName(legacy and deprecated)"))
}
log := r.Log.WithValues("lightrunJavaAgent", lightrunJavaAgent.Name, "deployment", deploymentName)
fieldManager := "lightrun-conrtoller"

Expand Down Expand Up @@ -357,7 +358,10 @@ func (r *LightrunJavaAgentReconciler) reconcileDeployment(ctx context.Context, l
func (r *LightrunJavaAgentReconciler) reconcileStatefulSet(ctx context.Context, lightrunJavaAgent *agentv1beta.LightrunJavaAgent, namespace string) (ctrl.Result, error) {
log := r.Log.WithValues("lightrunJavaAgent", lightrunJavaAgent.Name, "statefulSet", lightrunJavaAgent.Spec.WorkloadName)
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add a check if workloadName is empty

fieldManager := "lightrun-controller"

statefulSetName := lightrunJavaAgent.Spec.WorkloadName
if statefulSetName == "" {
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("unable to reconcile statefulset: missing workloadName field"))
}
stsNamespacedObj := client.ObjectKey{
Name: lightrunJavaAgent.Spec.WorkloadName,
Namespace: namespace,
Expand Down
Loading