Skip to content

Cisco-IOS-XR-infra-policymgr-cfg cyclic dependency #1749

Description

@M0NsTeRRR

Hello,

I used libyang to parse a config file we use, and I've encountered this issue:

libyang.util.LibyangError: cannot load module: When condition cyclic dependency on the node "event-mode-match-first".: Schema path: /Cisco-IOS-XR-infra-policymgr-cfg:policy-manager/policy-maps/policy-map/event/event-mode-match-all

After checking the IOS XR YANG models (the issue exists in all versions), reordering the leaves would not fix it, since the two when expressions reference each other regardless of declaration order.

leaf event-mode-match-all {
when "count(../event-mode-match-first) = 0" {
description
"Event MUST have only one mode.";
}
type empty;
description
"Execute all the matched classes.";
}
leaf event-mode-match-first {
when "count(../event-mode-match-all) = 0" {
description
"Event MUST have only one mode.";
}
type empty;
description
"Execute only the first matched class.";
}

Quoting the rfc https://www.ietf.org/archive/id/draft-yn-netmod-rfc7950bis-00.html#section-7.21.5

If the XPath expression references any node that also has associated "when" statements, those "when" expressions MUST be evaluated first. There MUST NOT be any circular dependencies among "when" expressions.

Instead of using two leaves with mutually referencing when conditions, using a choice should fix the issue:

choice event-mode {
  description
    "Event MUST have only one mode.";

  case match-all {
    leaf event-mode-match-all {
      type empty;
      description
        "Execute all the matched classes.";
    }
  }

  case match-first {
    leaf event-mode-match-first {
      type empty;
      description
        "Execute only the first matched class.";
    }
  }
}

I'm not sure what the correct way to fix this is, since vendors commit their YANG models directly into this repository.
cc @alfleung as you are the commit author :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions