<h3>Description</h3>
<p>gethostname not accurate in kubernetes</p>

<h3>Troubleshooting</h3>
<h4>Reproduction</h4>

<p>on a recent test with kamailio in kubernetes, found that gethostname can return only the hostname and not the fqdn. this depends on the kind of object is used (deployment/statefulset)</p>
<h3>Possible Solutions</h3>

<p>the below patch fixed the issues i was having</p>
<pre><code>diff --git a/src/modules/ipops/ipops_pv.c b/src/modules/ipops/ipops_pv.c
index 5f77aa9..f65b4dd 100644
--- a/src/modules/ipops/ipops_pv.c
+++ b/src/modules/ipops/ipops_pv.c
@@ -455,6 +455,11 @@
        if (gethostname(hbuf, 512)<0) {
                LM_WARN("gethostname failed - host pvs will be null\n");
                return -1;
+       } else {
+               struct hostent* h;
+               if((h = gethostbyname(hbuf)) != NULL) {
+                       memcpy(hbuf, h->h_name, 512);
+               }
        }
 
        hlen = strlen(hbuf);

</code></pre>
<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>latest master
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>

<pre><code>buster & centos7
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2119?email_source=notifications&email_token=ABO7UZLSQSD2VZY5XOMSO5TQRLYUJA5CNFSM4JHLXPF2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HV2CWWA">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZLBEFXFFPB4HSTLP6DQRLYUJANCNFSM4JHLXPFQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZIYKR72SQBY4QU4J7DQRLYUJA5CNFSM4JHLXPF2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HV2CWWA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2119?email_source=notifications\u0026email_token=ABO7UZLSQSD2VZY5XOMSO5TQRLYUJA5CNFSM4JHLXPF2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HV2CWWA",
"url": "https://github.com/kamailio/kamailio/issues/2119?email_source=notifications\u0026email_token=ABO7UZLSQSD2VZY5XOMSO5TQRLYUJA5CNFSM4JHLXPF2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HV2CWWA",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>