Skip to content

Set hostname in dhcp_relay container#868

Closed
pyadvichuk wants to merge 1 commit intosonic-net:masterfrom
pyadvichuk:pyadvychuk/dhcp_docker_hostname
Closed

Set hostname in dhcp_relay container#868
pyadvichuk wants to merge 1 commit intosonic-net:masterfrom
pyadvichuk:pyadvychuk/dhcp_docker_hostname

Conversation

@pyadvichuk
Copy link

@pyadvichuk pyadvichuk commented Apr 12, 2019

Summary:

dhcp_relay testcase expects to see {{ inventory_hostname }} as a part of Option82::Agent Circuit ID but, inside docker container the hostname is sonic. That's why the testcase failed.

Type of change

  • Bug fix
  • [] Testbed and Framework(new/improvement)
  • [] Test case(new/improvement)

Approach

How did you do it?

execute remote shell to set hostname in the container

How did you verify/test it?

run dhcp_relay testacase, checked status

Any platform specific information?

no

@lguohan, @yxieca: please review and merge this.

@lguohan lguohan requested a review from jleveque April 17, 2019 18:07
@jleveque
Copy link
Contributor

@pyadvichuk: I have not experienced the behavior you're describing. Can you please post some output showing this behavior?

@pyadvichuk
Copy link
Author

@pyadvichuk: I have not experienced the behavior you're describing. Can you please post some output showing this behavior?

actually this comes from RFC 3046, section 2.0 - Relay Agent Information Option
but formally we can get the explanation directly from ptftests/dhcp_relay_test.py

>>> ptftests/dhcp_relay_test.py

        # option82 is a byte string created by the relay agent. It contains the circuit_id and remote_id fields.
        # circuit_id is stored as suboption 1 of option 82.
        # It consists of the following:
        #  Byte 0: Suboption number, always set to 1
        #  Byte 1: Length of suboption data in bytes
        #  Bytes 2+: Suboption data
        # Our circuit_id string is of the form "hostname:portname"
        circuit_id_string = self.hostname + ":" + self.client_iface_alias
        self.option82 = struct.pack('BB', 1, len(circuit_id_string))
        self.option82 += circuit_id_string

actually, it correspond to the implementation details of Linux dhcrelay program.
and, of courese, PTF expects to see such string in the relayed packet.

>>> ptftests/dhcp_relay_test.py
.......
def create_dhcp_request_relayed_packet(self):
......
        bootp /= scapy.DHCP(options=[('message-type', 'request'),
                    ('requested_addr', self.client_ip),
                    ('server_id', self.server_ip),
                    ('relay_agent_Information', self.option82),          <------------
                    ('end')])

so.. that's why it is required to have correct hostname inside dhcp_relay container - bc PTF will perform exactly matching. But the hostname defined for device in config_db.json::DEVICE_METADATA::localhost::hostname is applying only in base system, all the containers still have default hostname - sonic.

Probably, it is required to start the discussion regarding setting correct hostname for containers but i have no any information about dev plans and even can't imagine the scope of changes to implement this.

So, from my understanding proposed fix is the simplest and fastest way.

@jleveque
Copy link
Contributor

jleveque commented Apr 17, 2019

I understand how our Option 82 circuit_id is supposed to be formatted. I developed the patch for dhcrelay to support this format.

I was asking for logs and/or output from one of your affected devices, because we do not see this issue. When I run hostname in any Docker container, I get the proper hostname, and our relayed DHCP packets have the proper circuit_id. Our tests do not fail.

Can you please provide more details/output? What version of SONiC are you running?

@pyadvichuk
Copy link
Author

I understand how our Option 82 circuit_id is supposed to be formatted. I developed the patch for this.

I was asking for logs and/or output from one of your affected devices, because we do not see this issue. When I run hostname in any Docker container, I get the proper hostname, and our relayed DHCP packets have the proper circuit_id.

Can you please provide more details/output? What version of SONiC are you running?

It's built from master by jenkins job Mar 30, 2019.

show version
SONiC Software Version: SONiC.HEAD.254-dirty-20190330.203936
Distribution: Debian 9.8
Kernel: 4.9.0-8-2-amd64
Build commit: 9c83b54
Build date: Sat Mar 30 20:47:57 UTC 2019
Built by: johnar@jenkins-worker-4
> hostname 
cab18-3-switch3
> docker exec -it syncd hostname
sonic
> docker exec -it dhcp_relay hostname
sonic
..........

@jleveque
Copy link
Contributor

I don't have any machines running that exact build. However, I just tested on a machine running a newer build from April 11 (commit: sonic-net/sonic-buildimage@0a6dd88), and running hostname inside Docker containers returns the same, proper hostname as the base image.

@pyadvichuk
Copy link
Author

I don't have any machines running that exact build. However, I just tested on a machine running a newer build from April 11 (commit: Azure/sonic-buildimage@0a6dd88), and running hostname inside Docker containers returns the same, proper hostname as the base image.

@jleveque could you please have a look at #2806 as it looks i've found the root couse of issue we've faced.

@pyadvichuk pyadvichuk closed this May 2, 2019
deerao02 pushed a commit to deerao02/sonic-mgmt that referenced this pull request Dec 18, 2025
…ic-net#868)

<!--
Please make sure you've read and understood our contributing guidelines;
https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md

Please provide following information to help code review process a bit easier:
-->
### Description of PR
<!--
- Please include a summary of the change and which issue is fixed.
- Please also include relevant motivation and context. Where should reviewer start? background context?
- List any dependencies that are required for this change.
-->

Summary:
Fixes # (issue)
After delivering PR sonic-net#20782, we see diverse test outcome on some platforms, while initially failing platform shows success.

As this failure is caused by loganalyzer warning message, temporarily disabling log analyzer until we find root cause of different outcomes in different platforms.

Once we investigate and find root cause of failure in certain platforms, we will revert this change to catch WARNING messages again, as they are indication of original test gap we filled.

This pull request simplifies the `test_lldp_neighbor_post_swss_reboot` test in `tests/lldp/test_lldp.py` by removing the use of the `loganalyzer` fixture and its associated log pattern handling. The test is now marked to disable loganalyzer, streamlining its execution.

Test simplification:

* Removed all logic related to the `loganalyzer` fixture from the `test_lldp_neighbor_post_swss_reboot` test, including the handling of ignore and match regex patterns for log analysis. The test no longer takes `loganalyzer` as a parameter.
* Added the `@pytest.mark.disable_loganalyzer` decorator to explicitly disable loganalyzer for this test.

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
 - [ ] Skipped for non-supported platforms
- [x] Test case improvement

### Back port request
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [x] 202411
- [x] 202412
- [x] 202505

### Approach
#### What is the motivation for this PR?
https://msazure.visualstudio.com/One/_workitems/edit/35611584
#### How did you do it?

#### How did you verify/test it?

#### Any platform specific information?

#### Supported testbed topology if it's a new test case?

### Documentation
<!--
(If it's a new feature, new test case)
Did you update documentation/Wiki relevant to your implementation?
Link to the wiki page?
-->
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
…t#3112)

0ed90ba - [policerorch]: Fix return code comparison error (sonic-net#968) (1 minutes ago) <Shuotian Cheng)
80fcada -  remove crm acl_counters when acl_table removed (sonic-net#918) (3 hours ago) <JaredLius>
bd3651f - [aclorch]: Fix matching MIRROR_DSCP throws unnecessary errors (sonic-net#966) (2 minutes ago) <Shuotian Cheng>
0af226a - [aclorch]: Add MIRROR_DSCP table type (sonic-net#906) (4 weeks ago) <Shuotian Cheng>
9005962 - [vstest]: Update the mirror session state table name (sonic-net#917) (5 weeks ago) <Shuotian Cheng>
c4e3e54 - [policerorch]: Add PolicerOrch to bundle with mirror session (sonic-net#889) (6 weeks ago) <Shuotian Cheng>
ee49926 - [Makefile]: Remove header files from source files (sonic-net#883) (8 weeks ago) <Shuotian Cheng>
f889f80 - [aclorch]: Add ICMP type/code match for v4/v6 (sonic-net#868) (8 weeks ago) <Shuotian Cheng>
9931450 - [aclorch]: Add MIRRORv6 and MIRRORv4v6 support for ACL table (sonic-net#825) (9 weeks ago) <Shuotian Cheng>
a1ab18c - [mirrororch]: Fix comments typo (sonic-net#863) (9 weeks ago) <Shuotian Cheng>

sonic-swss-common
485db07 - [schema]: Add SWITCH_CAPABILITY_TABLE (sonic-net#276) (6 weeks ago) <Shuotian Cheng>        
3f49b20 - [schema]: Add POLICER configuration table (sonic-net#277) (6 weeks ago) <Shuotian Cheng>    
539b87d - [schema]: Add STATE_MIRROR_SESSION_TABLE_NAME (sonic-net#278) (6 weeks ago) <Shuotian Cheng>

sonic-utilities
dc52015 - [Sonic-utilities]: Added commands to view acl and port running configs (sonic-net#557) (6 days ago) <Prem Prakash>
635dc88 - [config]: Add config acl add/remove table command (sonic-net#541) (4 weeks ago) <Shuotian Cheng>
dcdc922 - [show]: Add show policer command (sonic-net#540) (4 weeks ago) <Shuotian Cheng>                                        
128462a - [config]: Add --policer option for mirror session (sonic-net#537) (6 weeks ago) <Shuotian Cheng>                       
38da7f3 - [acl_loader]: Add policer attribute in show mirror_session command (sonic-net#538) (6 weeks ago) <Shuotian Cheng>      
f95ff00 - [acl_loader]: Do not apply default DENY rule for MIRRORV6 table (sonic-net#522) (6 weeks ago) <Shuotian Cheng>

Signed-off-by: Shu0T1an ChenG <[email protected]>
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
 [201911] Explicitly specify command names with underscores (continued)
(sonic-net#868)
[fwutil]: Update Command-Reference.md. (sonic-net#876)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants