[ZBX-8486] Web scenario can't be re-linked Created: 2014 Jul 18  Updated: 2017 May 30  Resolved: 2014 Dec 02

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 2.2.4
Fix Version/s: 2.2.8rc1, 2.4.3rc1, 2.5.0

Type: Incident report Priority: Critical
Reporter: Marc Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: httptest, undefinedindex, webmonitoring
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

zabbix-web-pgsql-2.2.4-1.el6.noarch (upstream)


Issue Links:
Duplicate
is duplicated by ZBX-9056 "Undefined index" on re-linking the w... Closed

 Description   

Details were originally posted in ZBX-7409. See:
https://support.zabbix.com/browse/ZBX-7409?focusedCommentId=116604&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-116604

DBfetch() appears to return lowercase indexes while camel case are expected.

The following diff is not meant to be a patch hence not attached.

--- BEGIN unified diff ---

--- ./api/classes/managers/CHttpTestManager.php.orig    2014-07-17 21:49:52.000000000 +0200
+++ ./api/classes/managers/CHttpTestManager.php 2014-07-17 21:52:30.000000000 +0200
@@ -446,8 +446,8 @@
                );
                while ($dbItems = DBfetch($dbCursor)) {
                        DB::update('items', array(
-                               'values' => array('templateid' => $dbItems['parentId']),
-                               'where' => array('itemid' => $dbItems['childId'])
+                               'values' => array('templateid' => $dbItems['parentid']),
+                               'where' => array('itemid' => $dbItems['childid'])
                        ));
                }
 
@@ -464,8 +464,8 @@
                );
                while ($dbItems = DBfetch($dbCursor)) {
                        DB::update('items', array(
-                               'values' => array('templateid' => $dbItems['parentId']),
-                               'where' => array('itemid' => $dbItems['childId'])
+                               'values' => array('templateid' => $dbItems['parentid']),
+                               'where' => array('itemid' => $dbItems['childid'])
                        ));
                }
        }

--- END unified diff ---

I'm pretty sure to have tested it agains plain vanilla.
Anyway, I'll double-check it again (tomorrow) because it couldn't be reproduced by others.
Possibly DBfetch behaves differently for databases but haven't checked that yet.



 Comments   
Comment by Marc [ 2014 Aug 08 ]

This is another issue preventing to re-link, that may happen somehow - dunno why yet though

Given is:
T1 -> H1
T1 -> T2

After unlinking T1 from H1 and trying to re-link T2 to H1 the procedure fails and complains about already existing Web scenario.

A quick analysis of compareHttpSteps() for this particular case shows the reason:

return '5Log off4Security3Profile2Log on1Welcome' == '1Welcome2Log on3Profile4Security5Log off'

In fact there T1 was linked to more hosts previously and the same procedure worked well. Just the last of the hosts (here H1) makes problems.

Comment by Fernando Schmitt [ 2014 Nov 03 ]

I've tried the patch above (I know it's not intended as a patch and it does work. However, if we add the template scenario to a new application after unlinking it from the host, the change is NOT propagated to the host when re-linking the template. I think this is related to the use of camel case '...Id' in CApplicationManager.php. I'm using zabbix 2.4.1 with postgresql.

Comment by Alexander Vladishev [ 2014 Nov 19 ]

The issue is not reproducible with MySQL backend.

Comment by Krists Krigers (Inactive) [ 2014 Nov 24 ]

Cause of problems was PostgreSQL specifics:

  • Unquoted aliases get converted to lowercase. In this case I opted to not add quotes because nowhere in code camel-case is used for aliases.
  • Order of result rows can be arbitrary if "ORDER BY" is not used.

Fixed in r50774, branch svn://svn.zabbix.com/branches/dev/ZBX-8486 (copy of branches/2.2).

Comment by Alexander Vladishev [ 2014 Nov 25 ]

(1) arrays in compareHttpSteps() should be sorted by using the same algorythm. Now it works, but we can change CArrayHelper::sort() method in the future. It is a potential bug.

kristsk RESOLVED in r50828.

sasha CLOSED

Comment by Krists Krigers (Inactive) [ 2014 Nov 27 ]

Fixed and merged:

  • to 2.2.8rc1 in r50897,
  • to 2.4.3rc1 in r50899,
  • to 2.5.0 (trunk) in r50901.
Comment by Krists Krigers (Inactive) [ 2014 Nov 27 ]

(1) Updated API changelogs:

Is this the right way/place? This affects a number of APIs (host, template, httptest) I thought of putting it in "General" section.

sasha Excuse me. I was incorrectly made copy/paste. Please put it in right place.

RESOLVED

martins-v Reviewed. CLOSED.

Generated at Fri Apr 26 04:15:08 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.