Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure: hardcode fallback for wireserver endpoint #145

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/providers/azure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Content-Transfer-Encoding: base64

";

/// This is a known working wireserver endpoint within Azure.
/// See: https://blogs.msdn.microsoft.com/mast/2015/05/18/what-is-the-ip-address-168-63-129-16/
const FALLBACK_WIRESERVER_ADDR: [u8; 4] = [168, 63, 129, 16]; // for grep: 168.63.129.16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for grep: 168.63.129.16

💯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Four years later, I did indeed end up finding this line with grep. 🎉


#[derive(Debug, Deserialize, Clone, Default)]
struct GoalState {
#[serde(rename = "Container")]
Expand Down Expand Up @@ -150,8 +154,7 @@ pub struct Azure {

impl Azure {
pub fn try_new() -> Result<Azure> {
let addr = Azure::get_fabric_address()
.chain_err(|| "failed to get fabric address")?;
let addr = Azure::get_fabric_address();
let client = retry::Client::try_new()?
.header(HeaderName::from_static(HDR_AGENT_NAME),
HeaderValue::from_static(MS_AGENT_NAME))
Expand Down Expand Up @@ -179,7 +182,16 @@ impl Azure {
.ok_or_else(|| "failed to get goal state: not found response".into())
}

fn get_fabric_address() -> Result<IpAddr> {
fn get_fabric_address() -> IpAddr {
// try to fetch from dhcp, else use fallback; this is similar to what WALinuxAgent does
Azure::get_fabric_address_from_dhcp().unwrap_or_else(|e| {
warn!("Failed to get fabric address from DHCP: {}", e);
info!("Using fallback address");
IpAddr::from(FALLBACK_WIRESERVER_ADDR)
})
}

fn get_fabric_address_from_dhcp() -> Result<IpAddr> {
let v = util::dns_lease_key_lookup(OPTION_245)?;
// value is an 8 digit hex value. convert it to u32 and
// then parse that into an ip. Ipv4Addr::from(u32)
Expand Down