From d8fa71011123fbd851446a4dd51a8070d3a06423 Mon Sep 17 00:00:00 2001 From: Devon Bautista Date: Wed, 11 Dec 2024 08:40:03 -0700 Subject: [PATCH] Revert "feat: allow config-specified host prefix instead of 'nid'" This reverts commit 6f1bfe36ff182eb59d10f6ab363542c070535a63. --- coresmd/main.go | 19 +++++-------------- resources/config.example.yaml | 9 +++------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/coresmd/main.go b/coresmd/main.go index abc76e8..13c8fb0 100644 --- a/coresmd/main.go +++ b/coresmd/main.go @@ -37,7 +37,6 @@ var ( cache *Cache baseURL *url.URL bootScriptBaseURL *url.URL - hostnamePrefix string leaseDuration time.Duration ) @@ -49,8 +48,8 @@ func setup4(args ...string) (handler.Handler4, error) { log.Infof("initializing coresmd/coresmd %s (%s), built %s", version.Version, version.GitCommit, version.BuildTime) // Ensure all required args were passed - if len(args) != 6 { - return nil, errors.New("expected 6 arguments: base URL, boot script base URL, CA certificate path, hostname prefix, cache duration, lease duration") + if len(args) != 5 { + return nil, errors.New("expected 5 arguments: base URL, boot script base URL, CA certificate path, cache duration, lease duration") } // Create new SmdClient using first argument (base URL) @@ -82,25 +81,17 @@ func setup4(args ...string) (handler.Handler4, error) { log.Infof("CA certificate path was empty, not setting") } - // Parse hostname prefix - hostnamePrefix = strings.Trim(args[3], `"'`) - log.Infof("hostname prefix: %s", hostnamePrefix) - if hostnamePrefix == "" { - log.Info("no hostname prefix set, defaulting to 'nid'") - hostnamePrefix = "nid" - } - // Create new Cache using fourth argument (cache validity duration) and new SmdClient // pointer log.Debug("generating new Cache") - cache, err = NewCache(args[4], smdClient) + cache, err = NewCache(args[3], smdClient) if err != nil { return nil, fmt.Errorf("failed to create new cache: %w", err) } // Set lease duration from fifth argument log.Debug("setting lease duration") - leaseDuration, err = time.ParseDuration(args[5]) + leaseDuration, err = time.ParseDuration(args[4]) if err != nil { return nil, fmt.Errorf("failed to parse lease duration: %w", err) } @@ -140,7 +131,7 @@ func Handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool) { // Set client hostname if ifaceInfo.Type == "Node" { - resp.Options.Update(dhcpv4.OptHostName(fmt.Sprintf("%s%04d", hostnamePrefix, ifaceInfo.CompNID))) + resp.Options.Update(dhcpv4.OptHostName(fmt.Sprintf("nid%04d", ifaceInfo.CompNID))) } // Set root path to this server's IP diff --git a/resources/config.example.yaml b/resources/config.example.yaml index e2e2b23..6d3d456 100644 --- a/resources/config.example.yaml +++ b/resources/config.example.yaml @@ -43,13 +43,10 @@ server4: # address if name servers are not configured. # 3. (OPTIONAL) Path to CA cert used for TLS with the SMD base URL. If # there is already a trusted certificate, this can be blank (""). - # 4. Node hostname prefix. The hostnames given to nodes will be of the - # format "". If this argument is blank, "nid" is used as - # the prefix. is the node ID number, 0-padded to four places. - # 5. Cache validity duration. Coresmd uses a pull-through cache to store + # 4. Cache validity duration. Coresmd uses a pull-through cache to store # network information and this is the duration to refresh that cache. - # 6. Lease duration. - - coresmd: https://foobar.openchami.cluster http://172.16.0.253:8081 /root_ca/root_ca.crt '' 30s 1h + # 5. Lease duration. + - coresmd: https://foobar.openchami.cluster http://172.16.0.253:8081 /root_ca/root_ca.crt 30s 1h # Any requests reaching this point are unknown to SMD and it is up to the # administrator to decide how to handle unknown packets.