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

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

Conversation

yaronkaikov
Copy link
Collaborator

@yaronkaikov yaronkaikov commented Oct 10, 2023

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

@yaronkaikov yaronkaikov requested review from syuu1228, fruch and a team October 10, 2023 21:10
@syuu1228
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Collaborator Author

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

@yaronkaikov yaronkaikov force-pushed the replace-scylla-machine-image-during-upgrade branch from d23b2d2 to 466d98d Compare October 30, 2023 06:52
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: scylladb/scylla-enterprise-machine-image#51
@yaronkaikov yaronkaikov force-pushed the replace-scylla-machine-image-during-upgrade branch from 466d98d to eef7e75 Compare October 30, 2023 06:52
Copy link
Contributor

@syuu1228 syuu1228 left a comment

Choose a reason for hiding this comment

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

LGTM

@yaronkaikov yaronkaikov merged commit bc8a38f into scylladb:next Oct 30, 2023
1 check passed
@yaronkaikov yaronkaikov deleted the replace-scylla-machine-image-during-upgrade branch October 30, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants