scylladb / scylla-machine-image

Apache License 2.0
18 stars 25 forks source link

scylla-machine-image:replace package during upgrade #486

Closed yaronkaikov closed 8 months ago

yaronkaikov commented 8 months ago

When upgrading OSS to Enterprise we need to make sure scylla-machine-image will be replaced with scylla-enterprise-machine-image package

Adding Obsoletes indication in the .spec file and controle.template so scylla-enterprise-machine-image is a replacement for scylla-machine-image.

Closes: https://github.com/scylladb/scylla-enterprise-machine-image/issues/51

Closes: https://github.com/scylladb/scylla-enterprise-machine-image/issues/50

syuu1228 commented 8 months ago

Can we do Replaces: scylla-machine-image or Obsoletes: scylla-machine-image when product == "scylla"? I'm not really sure it will work without problem or not, but since this is only needed on enterprise version, probably better to add if product != "scylla" condition like this:

diff --git a/dist/debian/control.template b/dist/debian/control.template
index dab5697..89063fa 100644
--- a/dist/debian/control.template
+++ b/dist/debian/control.template
@@ -8,7 +8,7 @@ Rules-Requires-Root: no

 Package: %{product}-machine-image
 Architecture: all
-Depends: %{product}, %{product}-python3, ${shlibs:Depends}, ${misc:Depends}
+Depends: %{product}, %{product}-python3, ${shlibs:Depends}, ${misc:Depends}%{replaces}
 Description: Scylla Machine Image
  Scylla is a highly scalable, eventually consistent, distributed,
  partitioned row DB.
diff --git a/dist/debian/debian_files_gen.py b/dist/debian/debian_files_gen.py
index bf21a36..e9b153f 100755
--- a/dist/debian/debian_files_gen.py
+++ b/dist/debian/debian_files_gen.py
@@ -58,7 +58,10 @@ s = DebianFilesTemplate(changelog_template)
 changelog_applied = s.substitute(product=product, version=version, release=release, revision='1', codename='stable')

 s = DebianFilesTemplate(control_template)
-control_applied = s.substitute(product=product)
+replaces = ''
+if product != 'scylla':
+    replaces = '\nReplaces: scylla-machine-image'
+control_applied = s.substitute(product=product, replaces=replaces)

 with open('build/debian/scylla-machine-image/debian/changelog', 'w') as f:
     f.write(changelog_applied)
diff --git a/dist/redhat/scylla-machine-image.spec b/dist/redhat/scylla-machine-image.spec
index 8b83b33..e70c45b 100644
--- a/dist/redhat/scylla-machine-image.spec
+++ b/dist/redhat/scylla-machine-image.spec
@@ -10,7 +10,9 @@ Source0:        %{name}-%{version}-%{release}.tar
 Requires:       %{product} = %{version} %{product}-python3 curl

 BuildArch:      noarch
-Obsoletes:      %{product}-ami
+%if "%{package_name}" != "scylla"
+Obsoletes:      scylla-machine-image
+%endif

 %global _python_bytecompile_errors_terminate_build 0
 %global __brp_python_bytecompile %{nil}
syuu1228 commented 8 months ago

Also, I'm not really sure we should add this PR or not, since the implementation is inconsistent between scylla core packages, see: https://github.com/scylladb/scylla-enterprise-machine-image/issues/51#issuecomment-1757180557

yaronkaikov commented 8 months ago

Can we do Replaces: scylla-machine-image or Obsoletes: scylla-machine-image when product == "scylla"? I'm not really sure it will work without problem or not, but since this is only needed on enterprise version, probably better to add if product != "scylla" condition like this:

diff --git a/dist/debian/control.template b/dist/debian/control.template
index dab5697..89063fa 100644
--- a/dist/debian/control.template
+++ b/dist/debian/control.template
@@ -8,7 +8,7 @@ Rules-Requires-Root: no

 Package: %{product}-machine-image
 Architecture: all
-Depends: %{product}, %{product}-python3, ${shlibs:Depends}, ${misc:Depends}
+Depends: %{product}, %{product}-python3, ${shlibs:Depends}, ${misc:Depends}%{replaces}
 Description: Scylla Machine Image
  Scylla is a highly scalable, eventually consistent, distributed,
  partitioned row DB.
diff --git a/dist/debian/debian_files_gen.py b/dist/debian/debian_files_gen.py
index bf21a36..e9b153f 100755
--- a/dist/debian/debian_files_gen.py
+++ b/dist/debian/debian_files_gen.py
@@ -58,7 +58,10 @@ s = DebianFilesTemplate(changelog_template)
 changelog_applied = s.substitute(product=product, version=version, release=release, revision='1', codename='stable')

 s = DebianFilesTemplate(control_template)
-control_applied = s.substitute(product=product)
+replaces = ''
+if product != 'scylla':
+    replaces = '\nReplaces: scylla-machine-image'
+control_applied = s.substitute(product=product, replaces=replaces)

 with open('build/debian/scylla-machine-image/debian/changelog', 'w') as f:
     f.write(changelog_applied)
diff --git a/dist/redhat/scylla-machine-image.spec b/dist/redhat/scylla-machine-image.spec
index 8b83b33..e70c45b 100644
--- a/dist/redhat/scylla-machine-image.spec
+++ b/dist/redhat/scylla-machine-image.spec
@@ -10,7 +10,9 @@ Source0:        %{name}-%{version}-%{release}.tar
 Requires:       %{product} = %{version} %{product}-python3 curl

 BuildArch:      noarch
-Obsoletes:      %{product}-ami
+%if "%{package_name}" != "scylla"
+Obsoletes:      scylla-machine-image
+%endif

 %global _python_bytecompile_errors_terminate_build 0
 %global __brp_python_bytecompile %{nil}

@syuu1228 The current change will already replace Scylla-machine-image during an upgrade. Why do we need to add a condition for product? I mean, even if we do upgrade from OSS -> OSS we probably should remove the old version during the installation of the new version