]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Upgrade process for obsolete options
authorAmos Jeffries <amosjeffries@squid-cache.org>
Sat, 23 Oct 2010 08:50:56 +0000 (02:50 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Sat, 23 Oct 2010 08:50:56 +0000 (02:50 -0600)
One problem we currently have with upgrades is leaving the parser able
to avoid its bungled/unknown option message for directives which have
been fully removed or massively syntax altered.

We are able to handle this for flags and option syntax easily but the
parser has been particularly dense and strict on the directives (first
word of each line).

This patch updates the cf_* and cfgman code to allow a special directive
type "obsolete" which causes these directives to be handled specially
without causing the directives to remain in the publicly visible
squid.conf documentation.

It allows DOC_START / DOC_END comments to be written in cf.data.pre
describing the upgrade actions that need to be taken. This text is
dumped to cache.log verbatim when the configuration option is sighted.

If "-k parse" is used the text is displayed at debug level 0, otherwise
displayed at debug level 1. One line indicating a generic "directive X
is obsolete" is always displayed at level 0 for backwards compatibility
with admin expectations of a high level "bungled" message.

After all this text display, parse_obsolete(char*) is called with the
directive name. This function exists in cache_cf.cc and can be coded to
selectivey do more complex handling of the directive. ie for upgrade
actions deeper than removal.

 * cf.data.pre has entries added for all the 2.6-3.1 directives I could
   find that were removed up to 3.HEAD

scripts/www/build-cfg-help.pl
src/cache_cf.cc
src/cf.data.depend
src/cf.data.pre
src/cf_gen.cc
src/globals.h
src/main.cc

index caefc1a2242adfadcd5431f373f5253f9ca43c1e..44f23d3371bffb727ab168c2ee1ad4161a15db32 100755 (executable)
@@ -305,6 +305,7 @@ print $index "<hr />\n" if $format eq "singlehtml";
 # and now, build the option pages
 my (@names) = keys %option;
 foreach $name (@names) {
+       next if $option{$name}->{'type'} eq "obsolete";
        generate_page("${top}/${pagetemplate}", $option{$name});
 }
 
@@ -350,6 +351,7 @@ print $fh "<ul>\n";
 
 foreach $name (sort keys %all_names) {
        my ($data) = $all_names{$name};
+       next if $data->{'type'} eq "obsolete";
        print $fh '    <li><a href="' . uriescape($data->{'name'}) . '.html" name="toc_' . htmlescape($name) . '">' . htmlescape($name) . "</a></li>\n";
 }
 
index 7e91a7f5aa14bd2212f7e762fc0da8daad754e96..ddd01a49c8017b3c3995686d17c50c678aae38d8 100644 (file)
@@ -144,6 +144,7 @@ static void parse_string(char **);
 static void default_all(void);
 static void defaults_if_none(void);
 static int parse_line(char *);
+static void parse_obsolete(const char *);
 static void parseBytesLine(size_t * bptr, const char *units);
 #if !USE_DNSSERVERS
 static void parseBytesLineSigned(ssize_t * bptr, const char *units);
@@ -893,6 +894,22 @@ configDoConfigure(void)
 #endif
 }
 
+/** Parse a line containing an obsolete directive.
+ * To upgrade it where possible instead of just "Bungled config" for
+ * directives which cannot be marked as simply aliases of the some name.
+ * For example if the parameter order and content has changed.
+ * Or if the directive has been completely removed.
+ */
+void
+parse_obsolete(const char *name)
+{
+    // Directives which have been radically changed rather than removed
+    if (!strcmp(name, "url_rewrite_concurrency")) {
+        debugs(3, DBG_CRITICAL, "WARNING: url_rewrite_concurrency upgrade overriding url_rewrite_children settings.");
+        parse_int(&Config.redirectChildren.concurrency);
+    }
+}
+
 /* Parse a time specification from the config file.  Store the
  * result in 'tptr', after converting it to 'units' */
 static void
index 3b0e6912dc0d269cc9172616d0baf29e0f2ed079..92ff6af37648d29721b8b7496ec8faed7616c4d4 100644 (file)
@@ -43,6 +43,7 @@ kb_int64_t
 kb_size_t
 logformat
 memcachemode
+obsolete
 onoff
 peer
 peer_access            cache_peer acl
index 815e8dd24edb5293fd19eb33bf29ad8c9c2db8c8..32f57864ba936fbddec10acc9ff0041b503ec2b3 100644 (file)
@@ -96,6 +96,75 @@ COMMENT_START
        across all Squid processes.
 COMMENT_END
 
+# Options Removed in 3.2
+NAME: ignore_expect_100
+TYPE: obsolete
+DOC_START
+       Remove this line. The HTTP/1.1 feature is now fully supported by default.
+DOC_END
+
+NAME: ftp_list_width
+TYPE: obsolete
+DOC_START
+       Remove this line. Configure FTP page display using the CSS controls in errorpages.css instead.
+DOC_END
+
+NAME: url_rewrite_concurrency
+TYPE: obsolete
+DOC_START
+       Remove this line. Set the 'concurrency=' option of url_rewrite_children instead.
+DOC_END
+
+# Options Removed in 3.1
+NAME: dns_testnames
+TYPE: obsolete
+DOC_START
+       Remove this line. DNS is no longer tested on startup.
+DOC_END
+
+NAME: extension_methods
+TYPE: obsolete
+DOC_START
+       Remove this line. All valid methods for HTTP are accepted by default.
+DOC_END
+
+# 2.7 Options Removed/Replaced in 3.1
+NAME: incoming_rate
+TYPE: obsolete
+DOC_NONE
+
+NAME: server_http11
+TYPE: obsolete
+DOC_START
+       Remove this line. HTTP/1.1 is supported by default.
+DOC_END
+
+NAME: upgrade_http0.9
+TYPE: obsolete
+DOC_START
+       Remove this line. ICY/1.0 streaming protocol is supported by default.
+DOC_END
+
+NAME: zph_local zph_mode zph_option zph_parent zph_sibling
+TYPE: obsolete
+DOC_START
+       Alter these entries. Use the qos_flows directive instead.
+DOC_END
+
+# Options Removed in 3.0
+NAME: header_access
+TYPE: obsolete
+DOC_START
+       Since squid-3.0 replace with request_header_access or reply_header_access
+       depending on whether you wish to match client requests or server replies.
+DOC_END
+
+NAME: httpd_accel_no_pmtu_disc
+TYPE: obsolete
+DOC_START
+       Since squid-3.0 use the 'disable-pmtu-discovery' flag on http_port instead.
+DOC_END
+
 COMMENT_START
  OPTIONS FOR AUTHENTICATION
  -----------------------------------------------------------------------------
index e64e267a6a56455bf41da5d2d17af2b39628e856..8b0b4464eec2f4d9ba33ac72da8166507f2ae425 100644 (file)
@@ -556,6 +556,9 @@ gen_default(Entry * head, FILE * fp)
         if (!strcmp(entry->name, "comment"))
             continue;
 
+        if (!strcmp(entry->type, "obsolete"))
+            continue;
+
         if (entry->loc == NULL) {
             fprintf(stderr, "NO LOCATION FOR %s\n", entry->name);
             rc |= 1;
@@ -601,7 +604,9 @@ gen_default_if_none(Entry * head, FILE * fp)
 
     for (entry = head; entry != NULL; entry = entry->next) {
         assert(entry->name);
-        assert(entry->loc);
+
+        if (!entry->loc)
+            continue;
 
         if (entry->default_if_none == NULL)
             continue;
@@ -636,7 +641,14 @@ gen_parse_alias(char *name, EntryAlias *alias, Entry *entry, FILE *fp)
 {
     fprintf(fp, "\tif (!strcmp(token, \"%s\")) {\n", name);
 
-    if (strcmp(entry->loc, "none") == 0) {
+    if (strcmp(entry->type,"obsolete") == 0) {
+        fprintf(fp, "\t\tdebugs(0, DBG_CRITICAL, \"ERROR: Directive '%s' is obsolete.\");\n", name);
+        for (Line *line = entry->doc; line != NULL; line = line->next) {
+            // offset line to strip initial whitespace tab byte
+            fprintf(fp, "\t\tdebugs(0, opt_parse_cfg_only?0:1, \"%s : %s\");\n", name, &line->data[1]);
+        }
+        fprintf(fp, "\t\tparse_obsolete(token);\n");
+    } else if (!entry->loc || strcmp(entry->loc, "none") == 0) {
         fprintf(fp,
                 "\t\tparse_%s();\n",
                 entry->type
@@ -666,8 +678,6 @@ gen_parse_entry(Entry *entry, FILE *fp)
 
     EntryAlias *alias = entry->alias;
 
-    assert (entry->loc);
-
     bool more;
 
     do {
@@ -718,9 +728,8 @@ gen_dump(Entry * head, FILE * fp)
            );
 
     for (entry = head; entry != NULL; entry = entry->next) {
-        assert(entry->loc);
 
-        if (strcmp(entry->loc, "none") == 0)
+        if (!entry->loc || strcmp(entry->loc, "none") == 0)
             continue;
 
         if (strcmp(entry->name, "comment") == 0)
@@ -753,9 +762,7 @@ gen_free(Entry * head, FILE * fp)
            );
 
     for (entry = head; entry != NULL; entry = entry->next) {
-        assert(entry->loc);
-
-        if (strcmp(entry->loc, "none") == 0)
+        if (!entry->loc || strcmp(entry->loc, "none") == 0)
             continue;
 
         if (strcmp(entry->name, "comment") == 0)
@@ -816,6 +823,8 @@ gen_conf(Entry * head, FILE * fp, bool verbose_output)
 
         if (!strcmp(entry->name, "comment"))
             (void) 0;
+        else if (!strcmp(entry->name, "obsolete"))
+            (void) 0;
         else if (verbose_output) {
             fprintf(fp, "#  TAG: %s", entry->name);
 
index 7d468cd1a7df97ed5a5cba49ac78fce1ef4f2d89..a110e2d6159f93f8d851511a503f7cb5c231ab79 100644 (file)
@@ -170,6 +170,7 @@ extern "C" {
     extern const char *external_acl_message;      /* NULL */
     extern int opt_send_signal;        /* -1 */
     extern int opt_no_daemon; /* 0 */
+    extern int opt_parse_cfg_only; /* 0 */
 
 /// current Squid process number (e.g., 4).
 /// Zero for SMP-unaware code and in no-SMP mode.
index 111e878dce84e77cdaba72b7a2b6433f2883cfbf..a326df7686ba8265a41368d9e72d47f57b0c46a7 100644 (file)
@@ -121,7 +121,6 @@ void WINAPI WIN32_svcHandler(DWORD);
 /** for error reporting from xmalloc and friends */
 SQUIDCEXTERN void (*failure_notify) (const char *);
 
-static int opt_parse_cfg_only = 0;
 static char *opt_syslog_facility = NULL;
 static int icpPortNumOverride = 1;     /* Want to detect "-u 0" */
 static int configured_once = 0;