Validates the uniqueness of the persistence IDs used in the given resources. They need to be unique per role on each slave.
| 912 | // Validates the uniqueness of the persistence IDs used in the given |
| 913 | // resources. They need to be unique per role on each slave. |
| 914 | Option<Error> validateUniquePersistenceID( |
| 915 | const Resources& resources) |
| 916 | { |
| 917 | hashmap<string, hashset<string>> persistenceIds; |
| 918 | |
| 919 | // Check duplicated persistence ID within the given resources. |
| 920 | Resources volumes = resources.persistentVolumes(); |
| 921 | |
| 922 | foreach (const Resource& volume, volumes) { |
| 923 | const string& role = Resources::reservationRole(volume); |
| 924 | const string& id = volume.disk().persistence().id(); |
| 925 | |
| 926 | if (persistenceIds.contains(role) && |
| 927 | persistenceIds[role].contains(id)) { |
| 928 | return Error("Persistence ID '" + id + "' is not unique"); |
| 929 | } |
| 930 | |
| 931 | persistenceIds[role].insert(id); |
| 932 | } |
| 933 | |
| 934 | return None(); |
| 935 | } |
| 936 | |
| 937 | |
| 938 | // Validates that revocable and non-revocable |
no test coverage detected