Skip to content

Commit

Permalink
Fixes #37606 - Drop old CentOS installation media
Browse files Browse the repository at this point in the history
The host mirror.centos.org is gone now that CentOS < 9 is EOL. It
includes a migration to simplify the name, but doesn't include
migrations to remove old entries. That is up to the user because they
may have modified them and still use them.

Co-authored-by: Chris Roberts <[email protected]>
  • Loading branch information
ekohl and chris1984 committed Oct 28, 2024
1 parent eb66c09 commit 66654d0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v2/media_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MediaController < V2::BaseController
PATH_INFO = <<~EOS
The path to the medium, can be a URL or a valid NFS server (exclusive of the architecture).
for example http://mirror.centos.org/centos/$version/os/$arch
for example https://mirror.stream.centos.org/$version-stream/BaseOS/$arch/os
where $arch will be substituted for the host\'s actual OS architecture and $version, $major and $minor
will be substituted for the version of the operating system.
Expand Down
2 changes: 1 addition & 1 deletion app/services/medium_providers/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module MediumProviders
# Example:
# provider = MyMediumProvider.new(centos_host)
# provider.medium_uri
# => #<URI::HTTP http://mirror.centos.org/centos/7/os/x86_64>
# => #<URI::HTTP http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os>
class Provider
delegate :logger, :to => :Rails

Expand Down
2 changes: 1 addition & 1 deletion app/views/media/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="tab-pane active" id="primary">
<%= text_f f, :name %>
<%= text_f f, :path, :size => "col-md-8", :help_block => _("The path to the medium, can be a URL or a valid NFS server (exclusive of the architecture).
for example <em>http://mirror.centos.org/centos/$version/os/$arch</em> where <strong>$arch</strong> will be substituted for the host's actual OS architecture and <strong>$version</strong>, <strong>$major</strong> and <strong>$minor</strong> will be substituted for the version of the operating system. Solaris and Debian media may also use <strong>$release</strong>.").html_safe %>
for example <em>https://mirror.stream.centos.org/$version-stream/BaseOS/$arch/os</em> where <strong>$arch</strong> will be substituted for the host's actual OS architecture and <strong>$version</strong>, <strong>$major</strong> and <strong>$minor</strong> will be substituted for the version of the operating system. Solaris and Debian media may also use <strong>$release</strong>.").html_safe %>
<span id="nfs-section" <%= display?(!required_nfs?) %>>
<%= text_f f, :media_path, :size => "col-md-8", :help_inline => _("The NFS path to the media.") %>
<%= text_f f, :config_path, :size => "col-md-8", :help_inline => _("The NFS path to the jumpstart control files.") %>
Expand Down
21 changes: 21 additions & 0 deletions db/migrate/20240813141845_rename_centos_stream_mirror_to_centos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class RenameCentosStreamMirrorToCentos < ActiveRecord::Migration[6.1]
OLD_NAME = "CentOS Stream 9 mirror"
NEW_NAME = "CentOS mirror"

def up
# Name column isn't unique, so we can't just rename and catch
# ActiveRecord::RecordNotUnique
old = Medium.unscoped.where(name: OLD_NAME)
return unless old.exists?

if Medium.unscoped.where(name: NEW_NAME).exists?
logger.warn("Couldn't rename medium '#{OLD_NAME}' to '#{NEW_NAME}': already exists")
else
old.update_all(name: NEW_NAME)
end
end

def down
Medium.unscoped.where(name: NEW_NAME).update_all(name: OLD_NAME)
end
end
12 changes: 1 addition & 11 deletions db/seeds.d/100-installation_media.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@
Medium.without_auditing do
[
{
:name => "CentOS 7 mirror",
:os_family => "Redhat",
:path => "http://mirror.centos.org/centos/$major/os/$arch",
},
{
:name => "CentOS Stream",
:os_family => "Redhat",
:path => "http://mirror.centos.org/centos/$major-stream/BaseOS/$arch/os",
},
{
:name => "CentOS Stream 9 mirror",
:name => "CentOS mirror",
:os_family => "Redhat",
:path => "http://mirror.stream.centos.org/$major-stream/BaseOS/$arch/os",
},
Expand Down

0 comments on commit 66654d0

Please sign in to comment.