Skip to content

Add proc-title-template option. - #8397

Merged
yossigo merged 8 commits into
redis:unstablefrom
yossigo:proc-title-template
Jan 28, 2021
Merged

yossigo merged 8 commits into
redis:unstablefrom
yossigo:proc-title-template

Conversation

@yossigo

@yossigo yossigo commented Jan 25, 2021 •

Copy link
Copy Markdown
Contributor

Make it possible to customize the process title, i.e. include custom
strings, immutable configuration like port/tls-port/unix socket name,
etc.

The default template format is backwards compatible, with the exception
of Redis instances that have only Unix domain sockets (no port/tls-port)
which will now report their listening socket.

Fixes #694, #2081

Make it possible to customize the process title, i.e. include custom
strings, immutable configuration like port/tls-port/unix socket name,
etc.
@yossigo
yossigo requested a review from oranagra January 25, 2021 22:32
Comment thread src/config.c Resolved
Comment thread redis.conf Resolved
Comment thread src/config.c Resolved
Comment thread src/server.c Resolved
* Update redis.conf to match default
* Report unixsocket:<path> if no tcp/tls ports are used.
@yossigo yossigo added release-notes indication that this issue needs to be mentioned in the release notes state:major-decision Requires core team consensus labels Jan 26, 2021
@yossigo yossigo added the approval-needed Waiting for core team approval to be merged label Jan 26, 2021
oranagra
oranagra previously approved these changes Jan 26, 2021
@oranagra

Copy link
Copy Markdown
Member

@redis/core-team please approve

itamarhaber
itamarhaber previously approved these changes Jan 26, 2021

@madolson madolson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a nitpick, I think the API is good.

Comment thread src/config.c Resolved
@madolson

Copy link
Copy Markdown
Contributor

Also, do we still need this separate flag? #3623 We could have an empty string indicate to not use a custom title.

@oranagra

Copy link
Copy Markdown
Member

In theory someone may actually use an empty string.
Also I guess the other explicit version is more intuitive.
But since this will rarely be used, I don't mind.

The one problem I see is that resetting it to "" at runtime will need to fetch the initial value from somewhere (it's not the exact same as "don't mess with the proc-title" )

@madolson

Copy link
Copy Markdown
Contributor

Part of the reason I mention it is just that the current PR will reject setting the template to an empty string. (Or a string composed of all spaces for that matter).

@yossigo

yossigo commented Jan 27, 2021

Copy link
Copy Markdown
Contributor Author

I prefer to have an explicit configuration, even if we currently reject an empty title string and could use it as a hint.

@yossigo
yossigo dismissed stale reviews from itamarhaber and oranagra via ee6d723 January 27, 2021 12:14

@oranagra oranagra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sorry for speaking late, but the verify function is needed for the config file parsing.
without it, the string will be loaded as is, and the validity will only be checked later when applying it (which may have some implications, one of them is not seeing the line number of the config line in the error message)

@yossigo

yossigo commented Jan 27, 2021

Copy link
Copy Markdown
Contributor Author

sorry for pushing early and not stopping to think before doing that :)

@madolson

madolson commented Jan 27, 2021 •

Copy link
Copy Markdown
Contributor

I was expecting we would call exit(1) when that fails in server.c, which is what we typically do anyways. If there is something wrong with our TLS config for example, we exit(1) when trying to start everything, not validate it ahead of time. Having double validation is hard to follow, but I guess throwing a concrete "this config is wrong" is also nice.

@oranagra

Copy link
Copy Markdown
Member

other than printing the config and line number.. The timing if that exit and print can make some difference.
For instance printing to stdout if done early, and to the log file if done late.
Or worse, if there's no log file, and we print after demonization, the print goes nowhere (and the process just silently dies).

Comment thread src/server.c Outdated
initServer();
if (background || server.pidfile) createPidFile();
redisSetProcTitle(argv[0]);
redisSetProcTitle(NULL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we assert here then, and not silently ignore the error code?

@madolson

Copy link
Copy Markdown
Contributor

Ok, if we want the error there (Not sure if TLS has the same problem, not sure where we daemonize), it'd be nice to clear up the expectations around the functions. I just don't like the extra "this should never happen, but if it does" we're just going to write a log.

@yossigo

yossigo commented Jan 28, 2021

Copy link
Copy Markdown
Contributor Author

I actually think it makes sense to consider two steps here:

  • Validate configuration data to determine if it's a valid input
  • Attempt to apply the configuration and consider potential failures

That may not apply to some trivial configs, but in other cases it's inevitable.
In this specific case setproctitle() can't fail (or, in fact, doesn't report failures) so it's redundant.

@oranagra

Copy link
Copy Markdown
Member

@yossigo please rebase.
when merge we should probably close #694 and #2081

# Conflicts:
#	redis.conf
#	src/server.c
#	src/server.h
@yossigo
yossigo merged commit 4bb5ccb into redis:unstable Jan 28, 2021
@yossigo
yossigo deleted the proc-title-template branch January 28, 2021 16:17
@oranagra oranagra mentioned this pull request Jan 31, 2021
JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Mar 2, 2021
Make it possible to customize the process title, i.e. include custom
strings, immutable configuration like port, tls-port, unix socket name,
etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval-needed Waiting for core team approval to be merged release-notes indication that this issue needs to be mentioned in the release notes state:major-decision Requires core team consensus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to identify a Redis instance by a name

5 participants