Skip to content

chore: Improve external image provider for ImagePuller#2101

Merged
tolusha merged 2 commits intomainfrom
defaultimages
Mar 20, 2026
Merged

chore: Improve external image provider for ImagePuller#2101
tolusha merged 2 commits intomainfrom
defaultimages

Conversation

@tolusha
Copy link
Contributor

@tolusha tolusha commented Mar 19, 2026

What does this PR do?

Refactors the ImagePuller's image fetching code: renames DashboardApiDefaultImagesProvider to ExternalImagesProvider, improves error handling (failures now block reconciliation by default instead of being silently
ignored), adds proper HTTP response body cleanup and status code checking.

Screenshot/screencast of this PR

N/A

What issues does this PR fix or reference?

eclipse-che/che#23686

How to test this PR?

  1. Deploy the operator:

OpenShift

./build/scripts/olm/test-catalog-from-sources.sh

or

build/scripts/docker-run.sh /bin/bash -c "
  oc login \
    --token=<...> \
    --server=<...> \
    --insecure-skip-tls-verify=true && \
  build/scripts/olm/test-catalog-from-sources.sh
"

on Minikube

./build/scripts/minikube-tests/test-operator-from-sources.sh

Common Test Scenarios

  • Deploy Eclipse Che
  • Start an empty workspace
  • Open terminal and build/run an image
  • Stop a workspace
  • Check operator logs for reconciliation errors or infinite reconciliation loops

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
@tolusha
Copy link
Contributor Author

tolusha commented Mar 19, 2026

/retest


func NewExternalImagesProvider() *ExternalImagesProvider {
p := &ExternalImagesProvider{
imagesFilePath: externalImagesStoreFilePath,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, hardcoding /tmp doesn't look ideal. If you think it's okay maybe :

Suggested change
imagesFilePath: externalImagesStoreFilePath,
imagesFilePath: filepath.Join(os.TempDir(), externalImagesStoreFileName)

func fetchRawData(url string) ([]byte, error) {
client := &http.Client{
Transport: &http.Transport{},
Timeout: time.Second * 1,
Copy link
Contributor

@rohanKanojia rohanKanojia Mar 19, 2026

Choose a reason for hiding this comment

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

Not related to this PR, I see it's coming from refactored changes from defaultimages.go; But isn't 1 second timeout a bit short? Maybe we can increase it?


url := sample["url"]
if url != nil {
urls = append(urls, url.(string))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a minor thought: we’re using a direct type assertion here, which could be a bit brittle.

Should we move to a guarded ok check to prevent any unexpected panics down the road?

Comment on lines +233 to +243
func getDashboardEditorsInternalAPIUrl(ctx *chetypes.DeployContext) string {
dashboardNamespace := ctx.CheCluster.Namespace
dashboardServiceName := defaults.GetCheFlavor() + "-dashboard"
return fmt.Sprintf("http://%s.%s.svc:8080/dashboard/api/editors", dashboardServiceName, dashboardNamespace)
}

func getDashboardSamplesInternalAPIUrl(ctx *chetypes.DeployContext) string {
dashboardNamespace := ctx.CheCluster.Namespace
dashboardServiceName := defaults.GetCheFlavor() + "-dashboard"
return fmt.Sprintf("http://%s.%s.svc:8080/dashboard/api/airgap-sample", dashboardServiceName, dashboardNamespace)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, minor duplication

Suggested change
func getDashboardEditorsInternalAPIUrl(ctx *chetypes.DeployContext) string {
dashboardNamespace := ctx.CheCluster.Namespace
dashboardServiceName := defaults.GetCheFlavor() + "-dashboard"
return fmt.Sprintf("http://%s.%s.svc:8080/dashboard/api/editors", dashboardServiceName, dashboardNamespace)
}
func getDashboardSamplesInternalAPIUrl(ctx *chetypes.DeployContext) string {
dashboardNamespace := ctx.CheCluster.Namespace
dashboardServiceName := defaults.GetCheFlavor() + "-dashboard"
return fmt.Sprintf("http://%s.%s.svc:8080/dashboard/api/airgap-sample", dashboardServiceName, dashboardNamespace)
}
func getDashboardBaseInternalURL(ctx *chetypes.DeployContext) string {
namespace := ctx.CheCluster.Namespace
serviceName := defaults.GetCheFlavor() + "-dashboard"
return fmt.Sprintf("http://%s.%s.svc:8080/dashboard/api", serviceName, namespace)
}
func getDashboardEditorsInternalAPIUrl(ctx *chetypes.DeployContext) string {
return fmt.Sprintf("%s/editors", getDashboardBaseInternalURL(ctx))
}
func getDashboardSamplesInternalAPIUrl(ctx *chetypes.DeployContext) string {
return fmt.Sprintf("%s/airgap-sample", getDashboardBaseInternalURL(ctx))
}

Comment on lines +82 to +88
expectedFileContent := ""
for i, img := range tc.expectedImages {
if i > 0 {
expectedFileContent += "\n"
}
expectedFileContent += img
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The test reconstructs file content using logic similar to the implementation (strings.Join). Do you think we can use this?

Suggested change
expectedFileContent := ""
for i, img := range tc.expectedImages {
if i > 0 {
expectedFileContent += "\n"
}
expectedFileContent += img
}
expectedFileContent := strings.Join(tc.expectedImages, "\n")

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
@tolusha
Copy link
Contributor Author

tolusha commented Mar 20, 2026

@rohanKanojia
Thank you for review.
Fixed.

@openshift-ci
Copy link

openshift-ci bot commented Mar 20, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rohanKanojia, tolusha

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

Details 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

@tolusha tolusha merged commit e3b6ada into main Mar 20, 2026
21 checks passed
@tolusha tolusha deleted the defaultimages branch March 20, 2026 11:09
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.

2 participants