diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-04-01 19:14:17 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-04-01 19:14:17 +0200 |
commit | 80f8f43b841f45e14929ee5801a5bc8e7448a385 (patch) | |
tree | 9bfec2a9b016e9703bce4098459e4fdd16991dfa /node-admin | |
parent | 83f42c8c3a106f0685deb175d57d4f725185df5d (diff) |
Default to epoch 0 with YumPackageName::toVersionLockName
Diffstat (limited to 'node-admin')
2 files changed, 13 insertions, 4 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java index 54c8719bceb..3f5c3025850 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java @@ -72,6 +72,15 @@ public class YumPackageName { architecture = packageName.architecture; } + /** + * Set the epoch of the YUM package. + * + * <p>WARNING: Should only be invoked if the YUM package actually has an epoch. Typically + * YUM packages doesn't have one explicitly set, and in case "0" will be used with + * {@link #toVersionLockName()} (otherwise it fails), but it will be absent from an + * install with {@link #toName()} (otherwise it fails). This typically means that + * you should set this only if the epoch is != "0".</p> + */ public Builder setEpoch(String epoch) { this.epoch = Optional.of(epoch); return this; } public Builder setName(String name) { this.name = name; return this; } public Builder setVersion(String version) { this.version = Optional.of(version); return this; } @@ -235,7 +244,7 @@ public class YumPackageName { */ public String toVersionLockName() { return String.format("%s:%s-%s-%s.%s", - epoch.orElseThrow(() -> new IllegalStateException("Epoch is missing for YUM package " + name)), + epoch.orElse("0"), name, version.orElseThrow(() -> new IllegalStateException("Version is missing for YUM package " + name)), release.orElseThrow(() -> new IllegalStateException("Release is missing for YUM package " + name)), diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java index 01664f5c22b..64e2997d486 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java @@ -56,7 +56,7 @@ public class YumPackageNameTest { "1.el7", null, "docker-engine-selinux-1.12.6-1.el7", - null); + "0:docker-engine-selinux-1.12.6-1.el7.*"); // name-ver-rel.arch verifyPackageName("docker-engine-selinux-1.12.6-1.el7.x86_64", @@ -66,7 +66,7 @@ public class YumPackageNameTest { "1.el7", "x86_64", "docker-engine-selinux-1.12.6-1.el7.x86_64", - null); + "0:docker-engine-selinux-1.12.6-1.el7.*"); // name-epoch:ver-rel.arch verifyPackageName( @@ -112,7 +112,7 @@ public class YumPackageNameTest { yumPackageName.toVersionLockName(); fail(); } catch (IllegalStateException e) { - assertThat(e.getMessage(), containsStringIgnoringCase("epoch is missing")); + assertThat(e.getMessage(), containsStringIgnoringCase("Version is missing ")); } } else { assertEquals(toVersionName, yumPackageName.toVersionLockName()); |