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

feat(config): add pprof global config support #729

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clayzermk1
Copy link

Implements #705

I've tested both port and host as working on my cluster against a custom docker image with these changes.

Copy link
Owner

@alexandrevilain alexandrevilain left a comment

Choose a reason for hiding this comment

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

Single comment about the code logic.
Don't you think it could be cool to expose this port in the containers and in the service too ? It would make it easier to reach the pprof endpoint.

// Port is required if the object is defined.
// Host is optional.
// Do not set a pprof config if the port is 0.
if pprofConfig.Port > 0 {
Copy link
Owner

Choose a reason for hiding this comment

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

Is this condition mandatory ? Maybe this could be moved to the first condition.
WDYT ?

Copy link
Author

Choose a reason for hiding this comment

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

Happy to remove it and reorder the conditionals.

Copy link
Author

Choose a reason for hiding this comment

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

Updated, LMK if that's what you were looking for.

@clayzermk1
Copy link
Author

Single comment about the code logic. Don't you think it could be cool to expose this port in the containers and in the service too ? It would make it easier to reach the pprof endpoint.

Let me take a look at what's involved. Since the temporal-config config map is used by the frontend, matching, history, and worker pods, are you proposing that it to be exposed as a containerPort on those pods?

@clayzermk1 clayzermk1 force-pushed the add-pprof-config-to-cluster-spec branch from 9ea6c2a to 8a3b79f Compare May 20, 2024 20:01
@clayzermk1 clayzermk1 force-pushed the add-pprof-config-to-cluster-spec branch from 8a3b79f to 0040110 Compare May 21, 2024 22:32
Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@clayzermk1
Copy link
Author

@alexandrevilain added auto containerPort creation. I've tested it locally against the dev cluster. The pprof port is automatically created for the service pod deployments, I can port-forward and connect 👍

One thing I couldn't figure out was how to prevent a nil host from appearing in the ConfigMap when only a port is specified in the 02-...yaml config. It generates ConfigMap yaml with host: "" despite the host being a *string and optional json parameter. Do you know if I'm doing something wrong there? The system correctly assigns a host of "localhost" in that situation (the default in Temporal).

@clayzermk1
Copy link
Author

One thing I couldn't figure out was how to prevent a nil host from appearing in the ConfigMap

I figured it out. It's because the Temporal PProf struct that I'm instantiating does not consider Host optional. This is expected behavior.

Copy link
Owner

@alexandrevilain alexandrevilain left a comment

Choose a reason for hiding this comment

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

@clayzermk1 added some comments :)

If you're wondering on default values for host and port, you can set default values in: https://github.com/alexandrevilain/temporal-operator/blob/main/api/v1beta1/temporalcluster_defaults.go#L60

// PProfPort defines a custom pprof port for the service.
// The port is defined by the global config.
// +optional
PProfPort *int `json:"pprofPort,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

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

IMO this field is useless. If spec.pprof != nil the container will expose spec.pprof.port.

@@ -326,6 +326,16 @@ func (b *DeploymentBuilder) Update(object client.Object) error {
}
}

if b.instance.Spec.PProf != nil && b.instance.Spec.PProf.Port > 0 {
b.service.PProfPort = &b.instance.Spec.PProf.Port
Copy link
Owner

Choose a reason for hiding this comment

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

To follow my comment on the spec, you can remove this assignment.


containerPorts = append(containerPorts, corev1.ContainerPort{
Name: "pprof",
ContainerPort: int32(*b.service.PProfPort),
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
ContainerPort: int32(*b.service.PProfPort),
ContainerPort: int32(b.instance.Spec.PProf.Port),

@clayzermk1
Copy link
Author

clayzermk1 commented May 29, 2024

Thanks! I'll take a look and turn this around ASAP.

you can set default values

I was trying to avoid setting default values since Temporal sets them itself. That way if they ever decide to change the defaults, no code change would be required.

@alexandrevilain
Copy link
Owner

Hi @clayzermk1 !

Do you need any help ?

@clayzermk1
Copy link
Author

Hi @alexandrevilain,

Sorry for the slow turn, I've been reassigned to a different project. I'm not sure when I'll get back around to this.

@clayzermk1
Copy link
Author

I received permission to work on this. I should be able to pick it up in a week or so 👍

@clayzermk1
Copy link
Author

Still on the radar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants