Skip to content

Commit

Permalink
Fixes #37481 - Update cached value for manifest expiration date durin…
Browse files Browse the repository at this point in the history
…g import
  • Loading branch information
jeremylenz committed May 22, 2024
1 parent 7864fcc commit 2933094
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/lib/actions/katello/organization/manifest_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def plan(organization, path, force)
end
end

def run
organization = ::Organization.find_by(name: input[:organization_name])
organization&.manifest_expiration_date(cached: false) # update the date
end

def failure_notification(plan)
::Katello::UINotifications::Subscriptions::ManifestImportError.deliver!(
:subject => subject_organization,
Expand Down
6 changes: 3 additions & 3 deletions app/models/katello/concerns/organization_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def manifest_imported?(cached: false)

def manifest_expiration_date(cached: true)
Rails.cache.fetch("#{self.label}_manifest_expiration_date", expires_in: 1.minute, force: !cached) do
unless manifest_imported?(cached: true)
unless manifest_imported?(cached: cached)
Rails.logger.error "Manifest not imported for organization #{self.label}"
return nil
end
Expand All @@ -117,8 +117,8 @@ def manifest_expiration_date(cached: true)
end
end

def manifest_expired?
manifest_expiry = manifest_expiration_date
def manifest_expired?(cached: true)
manifest_expiry = manifest_expiration_date(cached: cached)

if manifest_expiry
manifest_expiry < DateTime.now
Expand Down
4 changes: 2 additions & 2 deletions webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ManageManifestModal extends Component {
/>
</Alert>
}
{manifestExpired &&
{manifestExpired && isManifestImported &&
<Alert
ouiaId="manifest-expired-alert"
variant="danger"
Expand All @@ -198,7 +198,7 @@ class ManageManifestModal extends Component {
{getManifestName()}
</Col>
</Row>
{isManifestImported &&
{isManifestImported && manifestExpirationDate &&
<Row>
<Col sm={5} />
<Col sm={7}>
Expand Down

0 comments on commit 2933094

Please sign in to comment.