Skip to content

Fix duplicate records dw#1434

Open
jesusbv wants to merge 6 commits intomasterfrom
fix-duplicate-records-dw
Open

Fix duplicate records dw#1434
jesusbv wants to merge 6 commits intomasterfrom
fix-duplicate-records-dw

Conversation

@jesusbv
Copy link
Collaborator

@jesusbv jesusbv commented Feb 26, 2026

Description

When the client runs a registration multiple endpoints are called,
one of them is the system update while the products of the system are
being activated

if both endpoints callbacks write to the file, it generates duplicate
records

We could use the system update only to update the file to be exported
to DW but the problem is the information is not complete when the
endpoint is invoked, meaning there would be duplicate records using
that endpoint information because of how registration works

The propose change uses the product activate endpoint to populate the
file whenever there is a product activation or upgrade (for example,
registration) and system update would populate the file when is
invoked outside a registration

How to test

Registration

Run registration on a instance for example SLES 15 SP7 PAYG`
in the file, there should be no duplicates, there should be 11 entries

System update

after > 3 min, on the same instance, run heartbeat command, and check the file:
there should be no duplicates but new 11 entries, identical to the previous ones
but with a different last_seen_at value

Single product activation

remove a product, add the product again, there should be no duplicates in the file

Change Type

Please select the correct option.

  • Bug Fix (a non-breaking change which fixes an issue)
  • New Feature (a non-breaking change which adds new functionality)
  • Documentation Update (a change which only updates documentation)

Checklist

Please check off each item if the requirement is met.

  • I have reviewed my own code and believe that it's ready for an external review.
  • I have provided comments for any hard-to-understand code.
  • I have documented the MANUAL.md file with any changes to the user experience.
  • If my changes are non-trivial, I have added a changelog entry to notify users at package/obs/rmt-server.changes.

Review

Please check out our review guidelines
and get in touch with the author to get a shared understanding of the change.

When the client runs a registration multiple endpoints are called,
one of them is the system update while the products of the system are
being activated

if both endpoints callbacks write to the file, it generates duplicate
records

We could use the system update only to update the file to be exported
to DW but the problem is the information is not complete when the
endpoint is invoked, meaning there would be duplicate records using
that endpoint information because of how registration works

The propose change uses the product activate endpoint to populate the
file whenever there is a product activation or upgrade (for example,
registration) and system update would populate the file when is
invoked outside a registration also

This fixes bsc#1258943
@jesusbv jesusbv self-assigned this Feb 26, 2026
@jesusbv jesusbv added the 2.26 label Feb 26, 2026
after_action :export_rmt_data, only: %i[update], if: lambda {
DataExport.handler.presence && response.successful? && !@system.byos? &&
@system.products.present?
@system.products.present? && @system.registered_at != @system.last_seen_at
Copy link
Collaborator Author

@jesusbv jesusbv Feb 26, 2026

Choose a reason for hiding this comment

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

this means that if a user runs heartbeat command right after registration, we would not write anything to the file

Copy link
Member

Choose a reason for hiding this comment

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

The attributes registered_at and last_seen_at are not initialized with the same value. Both get set independently with Time.zone.now in different places of the code.

https://github.com/SUSE/rmt/blob/master/app/models/system.rb#L25 vs
https://github.com/SUSE/rmt/blob/master/app/controllers/application_controller.rb#L26

You might want to set registered_at directly from the last_seen_at value to guarantee they match.

Copy link
Collaborator Author

@jesusbv jesusbv Feb 27, 2026

Choose a reason for hiding this comment

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

updated the check to be under 10 seconds difference between the two values for a registration

@jesusbv jesusbv requested a review from digitaltom February 27, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants