]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Upgrade process for obsolete options
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 17 Dec 2010 19:46:13 +0000 (12:46 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 17 Dec 2010 19:46:13 +0000 (12:46 -0700)
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.

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 8a795e59c449a082592c1ce1cf3ef23b12fe049b..da99aac8f7660dad10752d8bf4296b6c3161f815 100644 (file)
@@ -129,6 +129,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);
 static size_t parseBytesUnits(const char *unit);
 static void free_all(void);
@@ -746,6 +747,24 @@ configDoConfigure(void)
     }
 }
 
+/** 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")) {
+        int cval;
+        parse_int(&cval);
+        debugs(3, DBG_CRITICAL, "WARNING: url_rewrite_concurrency upgrade overriding url_rewrite_children settings.");
+        Config.redirectChildren.concurrency = cval;
+    }
+}
+
 /* Parse a time specification from the config file.  Store the
  * result in 'tptr', after converting it to 'units' */
 static void
index 29dfb3b716ec30e1a9e4a70862ed34cd8dfbd86b..06706ca2c6064d108f6a477822f6e776428e8e02 100644 (file)
@@ -36,6 +36,7 @@ int
 kb_int64_t
 kb_size_t
 logformat
+obsolete
 onoff
 peer
 peer_access            cache_peer acl
index 6a2d76c846181f50663d7f0898ff72dc4302a546..cba7316aacc6c03dd1b8a56cbbeba9961cc604df 100644 (file)
@@ -59,6 +59,56 @@ COMMENT_START
   configuration files.
 COMMENT_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 78dd9a9aa3312c07cec6c86cd85f2890b4017ccf..c8681ffbbaa07188f259bcc7f4a1caefb870324a 100644 (file)
@@ -551,6 +551,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;
@@ -596,7 +599,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;
@@ -631,7 +636,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
@@ -661,8 +673,6 @@ gen_parse_entry(Entry *entry, FILE *fp)
 
     EntryAlias *alias = entry->alias;
 
-    assert (entry->loc);
-
     bool more;
 
     do {
@@ -713,9 +723,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)
@@ -747,9 +756,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)
@@ -810,6 +817,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 2250063573ac71cbd165da5e8c1dd34d7cbf8c4c..2acd0d50cdd6f04b937b632196b12e80bccea384 100644 (file)
@@ -176,6 +176,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 */
 
 
 #ifdef __cplusplus
index fdfe274012c19ef3ddf3d671169f6a47c6ae67e9..941126d7806c125dcfd51f176851686c8acdab73 100644 (file)
@@ -113,7 +113,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;