Skip to content

feat(collector): Ingress upload logic#356

Open
pkoprda wants to merge 2 commits intomainfrom
pkoprda/collector-ingress-upload
Open

feat(collector): Ingress upload logic#356
pkoprda wants to merge 2 commits intomainfrom
pkoprda/collector-ingress-upload

Conversation

@pkoprda
Copy link
Contributor

@pkoprda pkoprda commented Feb 17, 2026

Add upload functionality for collector archive files to the Red Hat Hybrid Cloud Console. The upload flow includes creating multipart form data from archive file, loading client certificates, configuring HTTP client, and sending POST request to ingress endpoint.

Co-authored-by: Claude Code

@pkoprda pkoprda force-pushed the pkoprda/collector-ingress-upload branch from de72e32 to 53024e2 Compare February 17, 2026 16:18
Copy link
Contributor

@jlocash jlocash left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I just had one clarifying question

Copy link
Collaborator

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

I'd like to introduce this new functionality in at least a new file. Long-term, we'll need to properly define a structure somewhere so we can talk to multiple services in a shared manner, but I won't go that far here.

In your commit message, can you include some instructions or even a short script to showcase how this is expected to work? Doesn't have to be pretty, but I'd like a reference to verify against.

More comments inline. I haven't tried the code out yet, these are just a few observations.

@pkoprda pkoprda force-pushed the pkoprda/collector-ingress-upload branch from 53024e2 to 8ed14f9 Compare February 23, 2026 15:07
@pkoprda
Copy link
Contributor Author

pkoprda commented Feb 23, 2026

Steps to verify the functionality:

  1. Register to subscription-manager
  2. Run insights-client collection without uploading (insights-client --no-upload --compressor xz)
  3. Create main function in ingress.go as an entry point for UploadArchive()
func main() {
	archive := ArchiveDto{
		Path:        "/var/cache/insights-client/<your-tar-xz-archive>",
		ContentType: "application/vnd.redhat.advisor.collection",
	}
	config := ServiceConfig{
		URL:           "https://cert.console.redhat.com/api/ingress/v1/upload",
		CertPath:      "/etc/pki/consumer/cert.pem",
		ClientKeyPath: "/etc/pki/consumer/key.pem",
	}
	err := UploadArchive(archive, config)
	if err != nil {
		slog.Error(err.Error())
		os.Exit(1)
	}
}
  1. Run ingress.go
$ go run ingress.go
2026/02/23 15:30:13 INFO Uploading archive archive=/var/cache/insights-client/insights-fedora-20260223152708.tar.xz url=https://cert.console.redhat.com/api/ingress/v1/upload
2026/02/23 15:30:14 INFO Successfully uploaded archive archive=/var/cache/insights-client/insights-fedora-20260223152708.tar.xz
  1. Log in to Inventory and find your system - it should have information from data collection.

Copy link
Collaborator

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

It works!

For a tech preview this PR is structured fine, I don't have any major problems with it. I have plans long-term to do dependency injection

type Uploader struct {
    httpClient HTTPClient
    fs         FileSystem
}

together with interfaces, which would allow us to test stuff better. The Service would long-term exist as an interface as well, with multiple implementations (Ingress, Inventory, Candlepin) with specific code relevant to the service.

This client isn't communicating what it is, later we'll need to add User-Agent (tracked by CCT-2063).

Copy link
Collaborator

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

Add upload functionality for collector archive files to the Red Hat Console Ingress service.

It is Red Hat Hybrid Cloud Console, or Red Hat Lightspeed, or Red Hat Insights.

Please include AI sign-off if you have used it.

@jirihnidek
Copy link
Contributor

My first question: How do you smoke test this?

My expectation would be:

  1. Create some new CLI too, command or sub-command for testing with no-op
  2. Then create some business logic for uploading anything anywhere

Without some new binary or command you are not able to get feedback from QE soon. I cannot test it too.

My feedback could be only from looking at some code that probably work, but it maybe does not work in real work at all and it will be necessary to change in the future.

@m-horky
Copy link
Collaborator

m-horky commented Mar 2, 2026

Without some new binary or command you are not able to get feedback from QE soon. I cannot test it too.

That's out of scope. See CCT-1700 (this card) and CCT-1699 (a follow up).

Peter provided an example snippet above, which I used for the happy path validation.

This is one of several steps we took to make the patch reviewable, and we "paid" with not having product code to verify the new logic. Integration will be handled during CCT-1854 and later through ad-hoc cards addressing the goals of whole feature CCT-1294.

Copy link
Contributor

@jirihnidek jirihnidek left a comment

Choose a reason for hiding this comment

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

I have few comments. I will continue with my review tomorrow.

@pkoprda pkoprda force-pushed the pkoprda/collector-ingress-upload branch from 8ed14f9 to 46f29d8 Compare March 2, 2026 16:46
Copy link
Contributor

@jirihnidek jirihnidek left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I have several comments and requests.

@pkoprda pkoprda force-pushed the pkoprda/collector-ingress-upload branch 2 times, most recently from 0feb361 to 1c8b8aa Compare March 3, 2026 11:33
@jirihnidek
Copy link
Contributor

Peter provided an example snippet above, which I used for the happy path validation.

Oh, I overlooked this comment. There is lot of comments. I think that this is enough.

Copy link
Contributor

@jirihnidek jirihnidek left a comment

Choose a reason for hiding this comment

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

Thanks for the update. I still have some comments and requests.

@pkoprda pkoprda force-pushed the pkoprda/collector-ingress-upload branch from 1c8b8aa to 78a39d3 Compare March 5, 2026 16:00
Copy link
Collaborator

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

With misconfigured/missing proxy, this errors out with

read tcp t.u.v.x:52032->a.b.c.d:443: read: connection reset by peer"

I'd like to see some error wrapping so we can see which specific operation failed.

Copy link
Contributor

@jirihnidek jirihnidek left a comment

Choose a reason for hiding this comment

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

Thanks for your updates. I have some comments.

@pkoprda pkoprda force-pushed the pkoprda/collector-ingress-upload branch from 78a39d3 to 14b7f20 Compare March 9, 2026 12:03
Copy link
Collaborator

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

I like it. My notes are mostly minor, I believe we're getting close to having this PR merged.

pkoprda added 2 commits March 9, 2026 16:41
* Card ID: CCT-1700

Add upload functionality for collector archive files to the Red Hat
Hybrid Cloud Console. The upload flow includes creating multipart form
data from archive file, loading client certificates, configuring HTTP
client, and sending POST request to ingress endpoint.

Co-authored-by: Claude Code
In `internal/http/client.go` there is unused method Get(), which can be
safely dropped from the codebase.
@pkoprda pkoprda force-pushed the pkoprda/collector-ingress-upload branch from 14b7f20 to 224cc09 Compare March 9, 2026 15:43
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.

4 participants