Skip to content

Init config refactor #2035

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

turetske
Copy link
Collaborator

@turetske turetske commented Feb 21, 2025

Moved InitConfig into InitServer and InitClient and adjusts the tests as needed.

Also made InitConfigDir platform agnostic.

Ideally, I would like to be able to make InitConfig private, but its use in the cmd/config_printer test makes that impossible.

I'm worried InitConfig will keep being used in tests until we figure out a solution for that if the author/reviewer don't catch it organically.

@turetske turetske requested a review from Saartank February 21, 2025 20:18
@turetske turetske added the internal Internal code improvements, not user-facing label Feb 21, 2025
@turetske turetske added this to the v7.14 milestone Feb 21, 2025
@turetske turetske marked this pull request as draft February 21, 2025 20:41
@turetske turetske modified the milestones: v7.14, v7.15 Feb 24, 2025
@turetske turetske force-pushed the init-config-refactor branch 2 times, most recently from 42bf05f to f55f544 Compare February 27, 2025 21:12
@turetske turetske marked this pull request as ready for review February 27, 2025 21:38
Copy link
Contributor

@Saartank Saartank left a comment

Choose a reason for hiding this comment

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

With this change, the log file initialization code runs when InitServer is executed. However, some code is executed before InitServer is reached. Because of this, all logs generated before InitServer runs will be output to the console even if the log file is configured. This could be problematic if something goes wrong before InitServer is reached, as the log file would not contain the relevant information.

@turetske turetske modified the milestones: v7.15, v7.16 Mar 21, 2025
@turetske turetske force-pushed the init-config-refactor branch from f55f544 to 40118c7 Compare March 24, 2025 22:24
@turetske turetske force-pushed the init-config-refactor branch from 40118c7 to 9e7b6d0 Compare April 11, 2025 02:46
@turetske turetske requested review from Saartank and jhiemstrawisc and removed request for Saartank April 11, 2025 03:23
@turetske turetske requested a review from jhiemstrawisc April 16, 2025 16:27
@jhiemstrawisc jhiemstrawisc modified the milestones: v7.16, v7.17 Apr 22, 2025
@turetske turetske force-pushed the init-config-refactor branch from 787ec30 to 3b0c518 Compare June 12, 2025 18:35
@turetske turetske assigned jhiemstrawisc and unassigned Saartank Jun 12, 2025
@turetske turetske force-pushed the init-config-refactor branch from 2c139bc to 11d53b7 Compare June 12, 2025 21:47
@turetske turetske requested a review from jhiemstrawisc June 12, 2025 21:56
Copy link
Member

@jhiemstrawisc jhiemstrawisc left a comment

Choose a reason for hiding this comment

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

Getting close! I suspect both of the change requests are related to your epic rebase adventure.

@jhiemstrawisc
Copy link
Member

Bumping this to the 7.18 milestone since it's not critical for 7.17 (which we'd like to release today), but we can still try to merge soon before there's time to accumulate more merge conflicts.

@jhiemstrawisc jhiemstrawisc modified the milestones: v7.17, v7.18 Jun 16, 2025
@turetske turetske force-pushed the init-config-refactor branch from 9047a7b to 4887d9c Compare June 26, 2025 16:59
@turetske turetske requested a review from jhiemstrawisc June 26, 2025 16:59
@@ -1275,12 +1291,10 @@ func InitServer(ctx context.Context, currentServers server_structs.ServerType) e
webConfigPath := param.Server_WebConfigFile.GetString()
if webConfigPath != "" {
if err := os.MkdirAll(filepath.Dir(webConfigPath), 0700); err != nil {
logging.FlushLogs(true)
Copy link
Member

Choose a reason for hiding this comment

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

I think we still need the log flush here -- otherwise we throw away any logs up until this point when the error is triggered.

cobra.CheckErr(errors.Wrapf(err, "failed to create directory for web config file at %s", webConfigPath))
}
}
if err := setWebConfigOverride(viper.GetViper(), webConfigPath); err != nil {
logging.FlushLogs(true)
Copy link
Member

Choose a reason for hiding this comment

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

Here as well

@jhiemstrawisc
Copy link
Member

By the way, the failing tests look like a bug I must have introduced to main recently. I'll dig into it.

jhiemstrawisc added a commit to jhiemstrawisc/pelican that referenced this pull request Jun 27, 2025
Some tests use IP addresses from http test servers for various
Pelican server configs (e.g. 'Server.ExternalWebUrl'). When we do
this, the certificates Pelican generates for itself are invalid because
they contain a SAN that says the IP is a DNS entry.

This was exposed in tests for PelicanPlatform#2035 after it picked up the new
verification code that checks the cert against configured hostnames.
@jhiemstrawisc
Copy link
Member

@turetske Assuming #2457 is approved, I've already checked that rebasing against it appears to fix these tests for me locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Internal code improvements, not user-facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InitConfig refactor to fix initConfigDir and proper InitServer/InitClient testing. InitConfigDir is not platform agnostic
3 participants