Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Handling DHCP timeouts in script
2012-11-06, 06:16
Post: #1
Handling DHCP timeouts in script
I've got an iPXE setup that is scripted to boot off an iSCSI target. I followed the examples for handling dhcp timeouts/errors, but I'm still getting random machines that timeout on the dhcp request and exit the script. The booting system displays "Connection timed out" and "No more network devices" errors and then exits back to the BIOS. I can't for the life of me figure out why. Can someone point out my error in the following script:

#!ipxe

:retry_dhcp
dhcp && isset ${filename} || goto retry_dhcp

set initiator-iqn iqn.2010-04.org.ipxe:${mac:hexhyp}

:iscsiboot
sanboot iscsi:10.0.0.1:::0:iqn.2008-08.com.target:prod-disk1 ||
sleep 3
goto iscsiboot
Find all posts by this user
Quote this message in a reply
2012-11-06, 09:03
Post: #2
RE: Handling DHCP timeouts in script
Your script is almost good. I believe the isset in the dhcp line starts a new conditional, so if dhcp fails, it will indeed exit.

I would do something like this instead:
Code:
:retry_dhcp
dhcp || goto retry_dhcp
isset ${filename} || goto retry_dhcp

Then again, I don't understand why you check if the ${filename} variable is set, when you don't use it later. I would just skip that line, as it doesn't really make any difference in your script. After all, if the dhcp fails to retrieve an IP it will fail and go back to retry_dhcp.

You might want to consider jumping back to :retry_dhcp instead of :iscsiboot if the sanboot fails, as it will just be standing there looping on trying to connect to the same target if it isn't able to connect. Depending on your setup, that might be exactly what you want, but redoing the dhcp and trying to connect again seems like a more robust setup.
Visit this user's website Find all posts by this user
Quote this message in a reply
2012-11-06, 17:06
Post: #3
RE: Handling DHCP timeouts in script
I was using that method since it was a copy and paste straight off the ipxe.org website as how to deal with retrying DHCP requests if they fail. So the site is wrong? I realize there's the extra check for the boot filename, but I tried your approach earlier and it didn't seem to work. I'll give it a go again. Good point on looping back to dhcp if sanboot fails. Thanks!
Find all posts by this user
Quote this message in a reply
2012-11-08, 17:45
Post: #4
RE: Handling DHCP timeouts in script
Indeed the example at http://ipxe.org/cmd/dhcp is similar to your script. To be absolutely certain I think you should ask the developer mailing list for the exact behavior of the branching logic.
Visit this user's website Find all posts by this user
Quote this message in a reply
2012-11-08, 21:50
Post: #5
RE: Handling DHCP timeouts in script
(2012-11-06 17:06)digitalis99 Wrote:  I was using that method since it was a copy and paste straight off the ipxe.org website as how to deal with retrying DHCP requests if they fail. So the site is wrong? I realize there's the extra check for the boot filename, but I tried your approach earlier and it didn't seem to work. I'll give it a go again. Good point on looping back to dhcp if sanboot fails. Thanks!

Did you see the "Retry DHCP indefinitely until it succeeds" on that page? It seems you were looking at the "Notes" section, instead, which deals with a particular scenario that doesn't seem relevant to your original post.
Find all posts by this user
Quote this message in a reply
2012-11-09, 09:36
Post: #6
RE: Handling DHCP timeouts in script
@Sha0: Yes, we were indeed looking at the "Notes" section. In particular, I was wondering what the behavior is when you have nested conditionals like this. Would the goto at the end of the line be based on the return code from dhcp or isset? I'm assuming isset. And in that particular case, if dhcp fails, it will indeed throw an exception and abort the script (which I seem to recall was his original problem).
Visit this user's website Find all posts by this user
Quote this message in a reply
2012-11-13, 04:39
Post: #7
RE: Handling DHCP timeouts in script
I can't get a retry in either error phase of my script, the DHCP request or the sanboot. Any error in either one generates the "No more network devices" prompt, at which point I'm dumped back to the BIOS. There doesn't appear to be any error handling at all. My current script is quite simple. I can't see why neither goto is working...

#!ipxe

:retry_dhcp
dhcp || goto retry_dhcp

set initiator-iqn iqn.2010-04.org.ipxe:${mac:hexhyp}
sanboot iscsi:10.0.0.1:::0:iqn.2008-08.com.target:prod-disk1 ||
sleep 1
goto retry_dhcp
Find all posts by this user
Quote this message in a reply
2012-11-13, 23:42
Post: #8
RE: Handling DHCP timeouts in script
Are you sure your device is actually supported? If you're using undionly.kpxe and chainloading things should just work, but if you're using ipxe.usb/iso/pxe you might have an unsupported network card. Have you verified that your card is in the list generated by the script below?

Code:
src/util/niclist.pl --format csv

Run it from the ipxe git checkout folder.
Visit this user's website Find all posts by this user
Quote this message in a reply
2012-11-13, 23:50
Post: #9
RE: Handling DHCP timeouts in script
I'm chainloading undionly.kpxe. Most of the boot attempts work, but when they don't, neither of the retry actions appear to retry. They exit instead.
Find all posts by this user
Quote this message in a reply
2012-11-14, 10:02
Post: #10
RE: Handling DHCP timeouts in script
I'm stumped. I suggest you try to email the mailing-list. Hopefully someone can shine some light on things there.
Visit this user's website Find all posts by this user
Quote this message in a reply
2012-11-15, 01:40
Post: #11
RE: Handling DHCP timeouts in script
Done, hopefully I can get some answers.
Find all posts by this user
Quote this message in a reply
2012-11-24, 20:32
Post: #12
RE: Handling DHCP timeouts in script
It works for me... I do something a little less "aggressive" in my undionly script... I have to slow things down a bit to avoid possible issues with ports getting shutdown for too many broadcasts on an interface (an issue with highly subscribed virtualization farms).

Code:
#!ipxe
#Embedded Boot Script for undionly.kpxe
#Zero Stratum Script; all "Script Local" Variables should be prefaced with a "0_"

cpuid --ext 29 && set arch x86_64 || set arch i386
cpuid 6 && set pae 1 || set pae 0
cpuid --ecx 5 && set vmx 1 || set vmx 0
cpuid --ext --ecx 2 && set svm 1 || set svm 0

set network-mode undi

set 0_attempt 1
echo
echo Welcome to iPXE!
echo
echo iPXE is running in UNDI Mode...
echo
goto 0_startme

:0_retry0
set 0_attempt 2
sleep 3
goto 0_startme

:0_retry1
set 0_attempt 3
sleep 3
goto 0_startme

:0_retry2
echo No Boot Filename received; Exiting iPXE.
sleep 3
exit

:0_startme
dhcp && isset ${filename} || goto 0_retry_loop
goto 0_sys_info

:0_retry_loop
#Three (3) re-tries of the 0_startme Function.
iseq ${0_attempt} 1 && goto 0_retry0 ||
iseq ${0_attempt} 2 && goto 0_retry1 ||
iseq ${0_attempt} 3 && goto 0_retry2 ||

:0_sys_info
echo
echo iPXE System Summary:
echo Processor Architecture: ${arch}
echo PAE Supported ${pae}
iseq ${vmx} 1 && echo VTx Supported ${vmx} ||
iseq ${svm} 1 && echo AMD-v Supported ${svm} ||
echo Model: ${product}
echo UUID: ${uuid}
echo Serial Number: ${serial}
echo MAC Address of Active Interface: ${net0/mac}
echo Root Path: ${17}
echo Boot File Name: ${filename}
echo
sleep 5

chain ${17}/NetBoot/iPXE/default/check-hw.ipxe && goto 0_end ||

:0_end
echo
echo Thank You for using iPXE!
sleep 3
exit

"Thus far, you have been adrift within the sheltered harbor of my patience..."
Find all posts by this user
Quote this message in a reply
2012-11-25, 00:57
Post: #13
RE: Handling DHCP timeouts in script
If whitespace were an issue, then I'd think the entire script wouldn't work. It works fine as long as none of the steps error out.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 4 Guest(s)