diff mbox series

[ovs-dev,v2] rhel: move conf.db to /var/lib/openvswitch, using symlinks

Message ID 9286dc65a636d98ed48a2582049b53e3c150b6c5.1668454862.git.tredaelli@redhat.com
State Accepted
Commit 59e8cb8a053d50f49629be8b6fd614562d066404
Headers show
Series [ovs-dev,v2] rhel: move conf.db to /var/lib/openvswitch, using symlinks | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Timothy Redaelli Nov. 14, 2022, 7:41 p.m. UTC
conf.db is by default at /etc/openvswitch, but it should be at
/var/lib/openvswitch like on Debian or like ovnnb_db.db and ovnsb_db.db.

If conf.db already exists in /etc/openvswitch then it's moved to
/var/lib/openvswitch.
Symlinks are created for conf.db and .conf.db.~lock~ into /etc/openvswitch
for backward compatibility.

Reported-at: https://bugzilla.redhat.com/1830857
Reported-by: Yedidyah Bar David <didi@redhat.com>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
v1 -> v2:
- Use hugetlbfs group instead of openvswitch when the package is built
  with dpdk (as reported by Flavio)
---
 rhel/openvswitch-fedora.spec.in | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

Comments

Ilya Maximets Nov. 30, 2022, 3:55 p.m. UTC | #1
On 11/14/22 20:41, Timothy Redaelli wrote:
> conf.db is by default at /etc/openvswitch, but it should be at
> /var/lib/openvswitch like on Debian or like ovnnb_db.db and ovnsb_db.db.
> 
> If conf.db already exists in /etc/openvswitch then it's moved to
> /var/lib/openvswitch.
> Symlinks are created for conf.db and .conf.db.~lock~ into /etc/openvswitch
> for backward compatibility.
> 
> Reported-at: https://bugzilla.redhat.com/1830857
> Reported-by: Yedidyah Bar David <didi@redhat.com>
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> ---
> v1 -> v2:
> - Use hugetlbfs group instead of openvswitch when the package is built
>   with dpdk (as reported by Flavio)
> ---
>  rhel/openvswitch-fedora.spec.in | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)

If that works for Fedora, then LGTM.  Applied.

Thanks!
Best regards, Ilya Maximets.
Roi Dayan Dec. 4, 2022, 8:23 a.m. UTC | #2
On 30/11/2022 17:55, Ilya Maximets wrote:
> On 11/14/22 20:41, Timothy Redaelli wrote:
>> conf.db is by default at /etc/openvswitch, but it should be at
>> /var/lib/openvswitch like on Debian or like ovnnb_db.db and ovnsb_db.db.
>>
>> If conf.db already exists in /etc/openvswitch then it's moved to
>> /var/lib/openvswitch.
>> Symlinks are created for conf.db and .conf.db.~lock~ into /etc/openvswitch
>> for backward compatibility.
>>
>> Reported-at: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.redhat.com%2F1830857&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=%2BIcIVZBKrfhIpq%2B6r6I3QvjdZ9KvjLsrRSlvi9kFHzc%3D&amp;reserved=0
>> Reported-by: Yedidyah Bar David <didi@redhat.com>
>> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
>> ---
>> v1 -> v2:
>> - Use hugetlbfs group instead of openvswitch when the package is built
>>   with dpdk (as reported by Flavio)
>> ---
>>  rhel/openvswitch-fedora.spec.in | 27 +++++++++++++++++++++++----
>>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> If that works for Fedora, then LGTM.  Applied.
> 
> Thanks!
> Best regards, Ilya Maximets.
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=fZZh4iYeUu%2BL2%2F%2FWTIgPNzpvfhpe%2F9MANkVPLmv57aY%3D&amp;reserved=0


hi,

This commit expose some kind of issue and cause openvswitch not
to start on clean systems.

If old conf.db file didn't exists it creates an empty conf.db with
the touch command.
Empty conf.db cause ovsdb-server not to start.

#  /usr/share/openvswitch/scripts/ovs-ctl start
ovsdb-tool: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
Starting ovsdb-server ovsdb-server: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
                                                           [FAILED]

If I remove the conf.db file (can leave the symbolic link in /etc)
then ovs starts fine.
# rm /var/lib/openvswitch/conf.db
#  /usr/share/openvswitch/scripts/ovs-ctl start
/etc/openvswitch/conf.db does not exist ... (warning).
Creating empty database /etc/openvswitch/conf.db           [  OK  ]
Starting ovsdb-server                                      [  OK  ]
system ID not configured, please use --system-id ... failed!
Configuring Open vSwitch system IDs                        [  OK  ]
Starting ovs-vswitchd                                      [  OK  ]
Enabling remote OVSDB managers                             [  OK  ]


I'm not sure where it's better to fix this. either the spec here
not to create an empty file or in ovsdb/log.c to an accept empty conf.db,
or maybe even upgrade_db() in ovs-lib bash file to call create_db
even if conf.db exists but it's empty.

Thanks,
Roi
Ilya Maximets Dec. 5, 2022, 2:36 p.m. UTC | #3
On 12/4/22 09:23, Roi Dayan wrote:
> 
> 
> On 30/11/2022 17:55, Ilya Maximets wrote:
>> On 11/14/22 20:41, Timothy Redaelli wrote:
>>> conf.db is by default at /etc/openvswitch, but it should be at
>>> /var/lib/openvswitch like on Debian or like ovnnb_db.db and ovnsb_db.db.
>>>
>>> If conf.db already exists in /etc/openvswitch then it's moved to
>>> /var/lib/openvswitch.
>>> Symlinks are created for conf.db and .conf.db.~lock~ into /etc/openvswitch
>>> for backward compatibility.
>>>
>>> Reported-at: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.redhat.com%2F1830857&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=%2BIcIVZBKrfhIpq%2B6r6I3QvjdZ9KvjLsrRSlvi9kFHzc%3D&amp;reserved=0
>>> Reported-by: Yedidyah Bar David <didi@redhat.com>
>>> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
>>> ---
>>> v1 -> v2:
>>> - Use hugetlbfs group instead of openvswitch when the package is built
>>>   with dpdk (as reported by Flavio)
>>> ---
>>>  rhel/openvswitch-fedora.spec.in | 27 +++++++++++++++++++++++----
>>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> If that works for Fedora, then LGTM.  Applied.
>>
>> Thanks!
>> Best regards, Ilya Maximets.
>> _______________________________________________
>> dev mailing list
>> dev@openvswitch.org
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=fZZh4iYeUu%2BL2%2F%2FWTIgPNzpvfhpe%2F9MANkVPLmv57aY%3D&amp;reserved=0
> 
> 
> hi,
> 
> This commit expose some kind of issue and cause openvswitch not
> to start on clean systems.
> 
> If old conf.db file didn't exists it creates an empty conf.db with
> the touch command.
> Empty conf.db cause ovsdb-server not to start.
> 
> #  /usr/share/openvswitch/scripts/ovs-ctl start
> ovsdb-tool: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
> Starting ovsdb-server ovsdb-server: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
>                                                            [FAILED]
> 
> If I remove the conf.db file (can leave the symbolic link in /etc)
> then ovs starts fine.
> # rm /var/lib/openvswitch/conf.db
> #  /usr/share/openvswitch/scripts/ovs-ctl start
> /etc/openvswitch/conf.db does not exist ... (warning).
> Creating empty database /etc/openvswitch/conf.db           [  OK  ]
> Starting ovsdb-server                                      [  OK  ]
> system ID not configured, please use --system-id ... failed!
> Configuring Open vSwitch system IDs                        [  OK  ]
> Starting ovs-vswitchd                                      [  OK  ]
> Enabling remote OVSDB managers                             [  OK  ]
> 
> 
> I'm not sure where it's better to fix this. either the spec here
> not to create an empty file or in ovsdb/log.c to an accept empty conf.db,
> or maybe even upgrade_db() in ovs-lib bash file to call create_db
> even if conf.db exists but it's empty.

Thanks, Roi, for the report!
I think, fixing the spec should be the right approach here.

Best regards, Ilya Maximets.
Ilya Maximets Dec. 13, 2022, 11:57 a.m. UTC | #4
On 12/5/22 15:36, Ilya Maximets wrote:
> On 12/4/22 09:23, Roi Dayan wrote:
>>
>>
>> On 30/11/2022 17:55, Ilya Maximets wrote:
>>> On 11/14/22 20:41, Timothy Redaelli wrote:
>>>> conf.db is by default at /etc/openvswitch, but it should be at
>>>> /var/lib/openvswitch like on Debian or like ovnnb_db.db and ovnsb_db.db.
>>>>
>>>> If conf.db already exists in /etc/openvswitch then it's moved to
>>>> /var/lib/openvswitch.
>>>> Symlinks are created for conf.db and .conf.db.~lock~ into /etc/openvswitch
>>>> for backward compatibility.
>>>>
>>>> Reported-at: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.redhat.com%2F1830857&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=%2BIcIVZBKrfhIpq%2B6r6I3QvjdZ9KvjLsrRSlvi9kFHzc%3D&amp;reserved=0
>>>> Reported-by: Yedidyah Bar David <didi@redhat.com>
>>>> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
>>>> ---
>>>> v1 -> v2:
>>>> - Use hugetlbfs group instead of openvswitch when the package is built
>>>>   with dpdk (as reported by Flavio)
>>>> ---
>>>>  rhel/openvswitch-fedora.spec.in | 27 +++++++++++++++++++++++----
>>>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>>
>>> If that works for Fedora, then LGTM.  Applied.
>>>
>>> Thanks!
>>> Best regards, Ilya Maximets.
>>> _______________________________________________
>>> dev mailing list
>>> dev@openvswitch.org
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=fZZh4iYeUu%2BL2%2F%2FWTIgPNzpvfhpe%2F9MANkVPLmv57aY%3D&amp;reserved=0
>>
>>
>> hi,
>>
>> This commit expose some kind of issue and cause openvswitch not
>> to start on clean systems.
>>
>> If old conf.db file didn't exists it creates an empty conf.db with
>> the touch command.
>> Empty conf.db cause ovsdb-server not to start.
>>
>> #  /usr/share/openvswitch/scripts/ovs-ctl start
>> ovsdb-tool: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
>> Starting ovsdb-server ovsdb-server: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
>>                                                            [FAILED]
>>
>> If I remove the conf.db file (can leave the symbolic link in /etc)
>> then ovs starts fine.
>> # rm /var/lib/openvswitch/conf.db
>> #  /usr/share/openvswitch/scripts/ovs-ctl start
>> /etc/openvswitch/conf.db does not exist ... (warning).
>> Creating empty database /etc/openvswitch/conf.db           [  OK  ]
>> Starting ovsdb-server                                      [  OK  ]
>> system ID not configured, please use --system-id ... failed!
>> Configuring Open vSwitch system IDs                        [  OK  ]
>> Starting ovs-vswitchd                                      [  OK  ]
>> Enabling remote OVSDB managers                             [  OK  ]
>>
>>
>> I'm not sure where it's better to fix this. either the spec here
>> not to create an empty file or in ovsdb/log.c to an accept empty conf.db,
>> or maybe even upgrade_db() in ovs-lib bash file to call create_db
>> even if conf.db exists but it's empty.
> 
> Thanks, Roi, for the report!
> I think, fixing the spec should be the right approach here.

Hi, Timothy.  Do you plan to work on the fix for this issue?

Otherwise we may just revert the change for now until the proper
fix is available.  Thoughts?

Best regards, Ilya Maximets.
Timothy Redaelli Dec. 15, 2022, 2:38 p.m. UTC | #5
On Tue, 13 Dec 2022 12:57:08 +0100
Ilya Maximets <i.maximets@ovn.org> wrote:

> On 12/5/22 15:36, Ilya Maximets wrote:
> > On 12/4/22 09:23, Roi Dayan wrote:
> >>
> >>
> >> On 30/11/2022 17:55, Ilya Maximets wrote:
> >>> On 11/14/22 20:41, Timothy Redaelli wrote:
> >>>> conf.db is by default at /etc/openvswitch, but it should be at
> >>>> /var/lib/openvswitch like on Debian or like ovnnb_db.db and ovnsb_db.db.
> >>>>
> >>>> If conf.db already exists in /etc/openvswitch then it's moved to
> >>>> /var/lib/openvswitch.
> >>>> Symlinks are created for conf.db and .conf.db.~lock~ into /etc/openvswitch
> >>>> for backward compatibility.
> >>>>
> >>>> Reported-at: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.redhat.com%2F1830857&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=%2BIcIVZBKrfhIpq%2B6r6I3QvjdZ9KvjLsrRSlvi9kFHzc%3D&amp;reserved=0
> >>>> Reported-by: Yedidyah Bar David <didi@redhat.com>
> >>>> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> >>>> ---
> >>>> v1 -> v2:
> >>>> - Use hugetlbfs group instead of openvswitch when the package is built
> >>>>   with dpdk (as reported by Flavio)
> >>>> ---
> >>>>  rhel/openvswitch-fedora.spec.in | 27 +++++++++++++++++++++++----
> >>>>  1 file changed, 23 insertions(+), 4 deletions(-)
> >>>
> >>> If that works for Fedora, then LGTM.  Applied.
> >>>
> >>> Thanks!
> >>> Best regards, Ilya Maximets.
> >>> _______________________________________________
> >>> dev mailing list
> >>> dev@openvswitch.org
> >>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=fZZh4iYeUu%2BL2%2F%2FWTIgPNzpvfhpe%2F9MANkVPLmv57aY%3D&amp;reserved=0
> >>
> >>
> >> hi,
> >>
> >> This commit expose some kind of issue and cause openvswitch not
> >> to start on clean systems.
> >>
> >> If old conf.db file didn't exists it creates an empty conf.db with
> >> the touch command.
> >> Empty conf.db cause ovsdb-server not to start.
> >>
> >> #  /usr/share/openvswitch/scripts/ovs-ctl start
> >> ovsdb-tool: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
> >> Starting ovsdb-server ovsdb-server: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
> >>                                                            [FAILED]
> >>
> >> If I remove the conf.db file (can leave the symbolic link in /etc)
> >> then ovs starts fine.
> >> # rm /var/lib/openvswitch/conf.db
> >> #  /usr/share/openvswitch/scripts/ovs-ctl start
> >> /etc/openvswitch/conf.db does not exist ... (warning).
> >> Creating empty database /etc/openvswitch/conf.db           [  OK  ]
> >> Starting ovsdb-server                                      [  OK  ]
> >> system ID not configured, please use --system-id ... failed!
> >> Configuring Open vSwitch system IDs                        [  OK  ]
> >> Starting ovs-vswitchd                                      [  OK  ]
> >> Enabling remote OVSDB managers                             [  OK  ]
> >>
> >>
> >> I'm not sure where it's better to fix this. either the spec here
> >> not to create an empty file or in ovsdb/log.c to an accept empty conf.db,
> >> or maybe even upgrade_db() in ovs-lib bash file to call create_db
> >> even if conf.db exists but it's empty.
> > 
> > Thanks, Roi, for the report!
> > I think, fixing the spec should be the right approach here.
> 
> Hi, Timothy.  Do you plan to work on the fix for this issue?

Yes sure, I'll do that today or tomorrow

> Otherwise we may just revert the change for now until the proper
> fix is available.  Thoughts?

I prefer just to fix it, without the revert, if it's possible

> Best regards, Ilya Maximets.
>
Ilya Maximets Dec. 15, 2022, 6:25 p.m. UTC | #6
On 12/15/22 15:38, Timothy Redaelli wrote:
> On Tue, 13 Dec 2022 12:57:08 +0100
> Ilya Maximets <i.maximets@ovn.org> wrote:
> 
>> On 12/5/22 15:36, Ilya Maximets wrote:
>>> On 12/4/22 09:23, Roi Dayan wrote:
>>>>
>>>>
>>>> On 30/11/2022 17:55, Ilya Maximets wrote:
>>>>> On 11/14/22 20:41, Timothy Redaelli wrote:
>>>>>> conf.db is by default at /etc/openvswitch, but it should be at
>>>>>> /var/lib/openvswitch like on Debian or like ovnnb_db.db and ovnsb_db.db.
>>>>>>
>>>>>> If conf.db already exists in /etc/openvswitch then it's moved to
>>>>>> /var/lib/openvswitch.
>>>>>> Symlinks are created for conf.db and .conf.db.~lock~ into /etc/openvswitch
>>>>>> for backward compatibility.
>>>>>>
>>>>>> Reported-at: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.redhat.com%2F1830857&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=%2BIcIVZBKrfhIpq%2B6r6I3QvjdZ9KvjLsrRSlvi9kFHzc%3D&amp;reserved=0
>>>>>> Reported-by: Yedidyah Bar David <didi@redhat.com>
>>>>>> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
>>>>>> ---
>>>>>> v1 -> v2:
>>>>>> - Use hugetlbfs group instead of openvswitch when the package is built
>>>>>>   with dpdk (as reported by Flavio)
>>>>>> ---
>>>>>>  rhel/openvswitch-fedora.spec.in | 27 +++++++++++++++++++++++----
>>>>>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>>>>
>>>>> If that works for Fedora, then LGTM.  Applied.
>>>>>
>>>>> Thanks!
>>>>> Best regards, Ilya Maximets.
>>>>> _______________________________________________
>>>>> dev mailing list
>>>>> dev@openvswitch.org
>>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&amp;data=05%7C01%7Croid%40nvidia.com%7Cd69116141ff645fc2c7308dad2eb4612%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638054205222362304%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=fZZh4iYeUu%2BL2%2F%2FWTIgPNzpvfhpe%2F9MANkVPLmv57aY%3D&amp;reserved=0
>>>>
>>>>
>>>> hi,
>>>>
>>>> This commit expose some kind of issue and cause openvswitch not
>>>> to start on clean systems.
>>>>
>>>> If old conf.db file didn't exists it creates an empty conf.db with
>>>> the touch command.
>>>> Empty conf.db cause ovsdb-server not to start.
>>>>
>>>> #  /usr/share/openvswitch/scripts/ovs-ctl start
>>>> ovsdb-tool: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
>>>> Starting ovsdb-server ovsdb-server: ovsdb error: /etc/openvswitch/conf.db: cannot identify file type
>>>>                                                            [FAILED]
>>>>
>>>> If I remove the conf.db file (can leave the symbolic link in /etc)
>>>> then ovs starts fine.
>>>> # rm /var/lib/openvswitch/conf.db
>>>> #  /usr/share/openvswitch/scripts/ovs-ctl start
>>>> /etc/openvswitch/conf.db does not exist ... (warning).
>>>> Creating empty database /etc/openvswitch/conf.db           [  OK  ]
>>>> Starting ovsdb-server                                      [  OK  ]
>>>> system ID not configured, please use --system-id ... failed!
>>>> Configuring Open vSwitch system IDs                        [  OK  ]
>>>> Starting ovs-vswitchd                                      [  OK  ]
>>>> Enabling remote OVSDB managers                             [  OK  ]
>>>>
>>>>
>>>> I'm not sure where it's better to fix this. either the spec here
>>>> not to create an empty file or in ovsdb/log.c to an accept empty conf.db,
>>>> or maybe even upgrade_db() in ovs-lib bash file to call create_db
>>>> even if conf.db exists but it's empty.
>>>
>>> Thanks, Roi, for the report!
>>> I think, fixing the spec should be the right approach here.
>>
>> Hi, Timothy.  Do you plan to work on the fix for this issue?
> 
> Yes sure, I'll do that today or tomorrow
> 
>> Otherwise we may just revert the change for now until the proper
>> fix is available.  Thoughts?
> 
> I prefer just to fix it, without the revert, if it's possible

If you know how to fix that, than sure.  I tried to quickly come up
with a fix before sending a revert patch, but I wasn't successful.

Here is what I tried:

diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
index 4a3e6294b..ebb6a46ed 100644
--- a/rhel/openvswitch-fedora.spec.in
+++ b/rhel/openvswitch-fedora.spec.in
@@ -339,11 +339,10 @@ for base in conf.db .conf.db.~lock~; do
     if test ! -e $old && test ! -h $old; then
         ln -s $new $old
     fi
-    touch $new
 %if %{with dpdk}
-    chown openvswitch:hugetlbfs $new
+    chown -h openvswitch:hugetlbfs $old
 %else
-    chown openvswitch:openvswitch $new
+    chown -h openvswitch:openvswitch $old
 %endif
 done
 
---

With that the ovsdb-server service still fails to start on my system.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
index df296ea08..c8d238fbc 100644
--- a/rhel/openvswitch-fedora.spec.in
+++ b/rhel/openvswitch-fedora.spec.in
@@ -239,8 +239,6 @@  rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
 
 install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch
 
-touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/conf.db
-touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/.conf.db.~lock~
 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/system-id.conf
 
 install -p -m 644 -D selinux/openvswitch-custom.pp \
@@ -329,6 +327,27 @@  if [ $1 -eq 1 ]; then
 fi
 %endif
 
+# Ensure that /etc/openvswitch/conf.db links to /var/lib/openvswitch,
+# moving an existing file if there is one.
+#
+# Ditto for .conf.db.~lock~.
+for base in conf.db .conf.db.~lock~; do
+    new=/var/lib/openvswitch/$base
+    old=/etc/openvswitch/$base
+    if test -f $old && test ! -e $new; then
+        mv $old $new
+    fi
+    if test ! -e $old && test ! -h $old; then
+        ln -s $new $old
+    fi
+    touch $new
+%if %{with dpdk}
+    chown openvswitch:hugetlbfs $new
+%else
+    chown openvswitch:openvswitch $new
+%endif
+done
+
 %if 0%{?systemd_post:1}
     # This may not enable openvswitch service or do daemon-reload.
     %systemd_post %{name}.service
@@ -414,8 +433,8 @@  fi
 %endif
 %dir %{_sysconfdir}/openvswitch
 %{_sysconfdir}/openvswitch/default.conf
-%config %ghost %{_sysconfdir}/openvswitch/conf.db
-%ghost %{_sysconfdir}/openvswitch/.conf.db.~lock~
+%config %ghost %{_sharedstatedir}/openvswitch/conf.db
+%ghost %{_sharedstatedir}/openvswitch/.conf.db.~lock~
 %config %ghost %{_sysconfdir}/openvswitch/system-id.conf
 %config(noreplace) %{_sysconfdir}/sysconfig/openvswitch
 %defattr(-,root,root)