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

Replay the unprocessed event from transport when the manager restarts #751

Merged
merged 9 commits into from
Jan 10, 2024

Conversation

yanmxa
Copy link
Member

@yanmxa yanmxa commented Dec 27, 2023

Signed-off-by: myan [email protected]

Ref: https://issues.redhat.com/browse/ACM-9056

  • The offset committer is to persist transport payload to the database.
  • The committer should not block the bundle process

Blocked by cloudevents/sdk-go#988, cause the sarama binding cannot consume the event from the persist position.

@yanmxa
Copy link
Member Author

yanmxa commented Jan 4, 2024

/test ci/prow/test-unit

Copy link

openshift-ci bot commented Jan 4, 2024

@yanmxa: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test gofmt
  • /test images
  • /test sonarcloud
  • /test test-e2e
  • /test test-unit

Use /test all to run all jobs.

In response to this:

/test ci/prow/test-unit

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@yanmxa
Copy link
Member Author

yanmxa commented Jan 4, 2024

/test test-unit

1 similar comment
@yanmxa
Copy link
Member Author

yanmxa commented Jan 4, 2024

/test test-unit

@yanmxa
Copy link
Member Author

yanmxa commented Jan 5, 2024

/retest

@yanmxa
Copy link
Member Author

yanmxa commented Jan 5, 2024

/cc @clyang82 @ldpliu

@openshift-ci openshift-ci bot requested review from clyang82 and ldpliu January 5, 2024 10:29
@yanmxa
Copy link
Member Author

yanmxa commented Jan 7, 2024

/retest

@@ -114,3 +114,11 @@ CREATE TABLE IF NOT EXISTS history.local_compliance_job_log (
offsets int8,
error TEXT
);

CREATE TABLE IF NOT EXISTS status.transport (
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to handle the upgrade case.

Copy link
Member Author

@yanmxa yanmxa Jan 10, 2024

Choose a reason for hiding this comment

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

@clyang82 What do you mean the upgrade case?

The table hasn't been created before. So it will create the table if it database doesn't contain the table. And the operator will handle the upgrade.


CREATE TABLE IF NOT EXISTS status.transport (
-- transport name, it is the topic name for the kafka transport
name character varying(254) PRIMARY KEY,
Copy link
Contributor

Choose a reason for hiding this comment

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

topic name or managed hub cluster name?

Copy link
Member Author

@yanmxa yanmxa Jan 10, 2024

Choose a reason for hiding this comment

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

It's the topic name, cause the table only for transport

Copy link
Member Author

Choose a reason for hiding this comment

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

hoh=# select * from status.transport;
       name       |            payload             |         created_at         |         updated_at
------------------+--------------------------------+----------------------------+----------------------------
 status.kind-hub1 | {"offset": 16, "partition": 0} | 2024-01-04 02:37:05.56802  | 2024-01-09 07:27:48.741223
 status.kind-hub2 | {"offset": 16, "partition": 0} | 2024-01-04 02:37:05.56802  | 2024-01-09 07:27:48.741223

if c.withDatabasePosition {
db := database.GetGorm()
var positions []models.Transport
err := db.Find(&positions).Error
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to find all or find by name?

Copy link
Member Author

Choose a reason for hiding this comment

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

The transport only caches the manager receiver topics. So It's okay to find all the topics for now.

Since all the topics are dynamically created and match the regular ^status.*. We can also add the filter with the like statement where name ~ '^status*'

Signed-off-by: myan <[email protected]>
Signed-off-by: Meng Yan <[email protected]>
Signed-off-by: Meng Yan <[email protected]>
Signed-off-by: Meng Yan <[email protected]>
Signed-off-by: Meng Yan <[email protected]>
Signed-off-by: Meng Yan <[email protected]>
Signed-off-by: Meng Yan <[email protected]>
Signed-off-by: myan <[email protected]>
Copy link

sonarcloud bot commented Jan 10, 2024

if err != nil {
return nil, err
}
offsetToStart = append(offsetToStart, kafka.TopicPartition{
Copy link
Contributor

Choose a reason for hiding this comment

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

the offsetToStart may contain the old topicpartition information if the managed hub cluster is detached. Need to cleanup the table to keep it up-to-date.

Copy link
Contributor

@clyang82 clyang82 left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci openshift-ci bot added the lgtm label Jan 10, 2024
Copy link

openshift-ci bot commented Jan 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clyang82, yanmxa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit d6c0016 into stolostron:main Jan 10, 2024
8 checks passed
@yanmxa yanmxa deleted the br_assign_offset branch January 10, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants