Skip to content

chore: SREP-969: Reuse Ocm Connection and handle closure of connection#785

Merged
openshift-merge-bot[bot] merged 11 commits intoopenshift:mainfrom
karanjitsingh01:SREP-969_setup_and_reuse_ocm_connection
Sep 30, 2025
Merged

chore: SREP-969: Reuse Ocm Connection and handle closure of connection#785
openshift-merge-bot[bot] merged 11 commits intoopenshift:mainfrom
karanjitsingh01:SREP-969_setup_and_reuse_ocm_connection

Conversation

@karanjitsingh01
Copy link
Contributor

@karanjitsingh01 karanjitsingh01 commented Sep 23, 2025

What type of PR is this?

  • fix (Bug Fix)
  • feat (New Feature)
  • docs (Documentation)
  • test (Test Coverage)
  • chore (Clean Up / Maintenance Tasks)
  • other (Anything that doesn't fit the above)

What this PR does / Why we need it?

This PR Focus on restructuring SetupOCMConnection for reusing existing connections rather than creating new one always.
SetupOCMConnection now reduce dependency of calling close in callers methods as cleanup is handled be a cleaner thread which starts after timeout interval (default 30s). If a connection is requested after a timeout interval, a new connection is created, again cleaner thread is also spawned to take care of resource cleanup.

Which Jira/Github issue(s) does this PR fix?

  • Related Issue #
  • Closes #

Special notes for your reviewer

Unit Test Coverage

Guidelines

  • If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
  • If it's a bug fix for an existing sub-command, please cover 70% of the code

Test coverage checks

  • Added unit tests
  • Created jira card to add unit test
  • This PR may not need unit tests

Unit Test can't be run as setup initiates actual ocm connection.
I have tested the updated code by running locally and making sure no leak is there and connections being utilized within timout interval and new connection being created after a timeout interval of previous connection. Adding a snipp of testcase and result.

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR
  • Backward compatible

/label tide/merge-method-squash

image

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 23, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 23, 2025

@karanjitsingh01: This pull request references SREP-969 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

Details

In response to this:

What type of PR is this?

  • fix (Bug Fix)
  • feat (New Feature)
  • docs (Documentation)
  • test (Test Coverage)
  • [T ] chore (Clean Up / Maintenance Tasks)
  • other (Anything that doesn't fit the above)

What this PR does / Why we need it?

This PR Focus on restructuring SetupOCMConnection for reusing existing connections rather than creating new one always.
SetupOCMConnection now reduce dependency of calling close in callers methods as cleanup is handled be a cleaner thread which starts after timeout interval (default 30s). If a connection is requested after a timeout interval, a new connection is created, again cleaner thread is also spawned to take care of resource cleanup.

Which Jira/Github issue(s) does this PR fix?

  • Related Issue #
  • Closes #

Special notes for your reviewer

Unit Test Coverage

Guidelines

  • If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
  • If it's a bug fix for an existing sub-command, please cover 70% of the code

Test coverage checks

  • Added unit tests
  • Created jira card to add unit test
  • [T ] This PR may not need unit tests

Unit Test can't be run as setup initiates actual ocm connection.
I have tested the updated code by running locally and making sure no leak is there and connections being utilized within timout interval and new connection being created after a timeout interval of previous connection. Adding a snipp of testcase and result.

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR
  • Backward compatible

/label tide/merge-method-squash

image

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. labels Sep 23, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 23, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 23, 2025

@karanjitsingh01: This pull request references SREP-969 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

Details

In response to this:

What type of PR is this?

  • fix (Bug Fix)
  • feat (New Feature)
  • docs (Documentation)
  • test (Test Coverage)
  • [T ] chore (Clean Up / Maintenance Tasks)
  • other (Anything that doesn't fit the above)

What this PR does / Why we need it?

This PR Focus on restructuring SetupOCMConnection for reusing existing connections rather than creating new one always.
SetupOCMConnection now reduce dependency of calling close in callers methods as cleanup is handled be a cleaner thread which starts after timeout interval (default 30s). If a connection is requested after a timeout interval, a new connection is created, again cleaner thread is also spawned to take care of resource cleanup.

Which Jira/Github issue(s) does this PR fix?

  • Related Issue #
  • Closes #

Special notes for your reviewer

Unit Test Coverage

Guidelines

  • If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
  • If it's a bug fix for an existing sub-command, please cover 70% of the code

Test coverage checks

  • Added unit tests
  • Created jira card to add unit test
  • [T ] This PR may not need unit tests

Unit Test can't be run as setup initiates actual ocm connection.
I have tested the updated code by running locally and making sure no leak is there and connections being utilized within timout interval and new connection being created after a timeout interval of previous connection. Adding a snipp of testcase and result.

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR
  • Backward compatible

/label tide/merge-method-squash

image

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 23, 2025

@karanjitsingh01: This pull request references SREP-969 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

Details

In response to this:

What type of PR is this?

  • fix (Bug Fix)
  • feat (New Feature)
  • docs (Documentation)
  • test (Test Coverage)
  • [T ] chore (Clean Up / Maintenance Tasks)
  • other (Anything that doesn't fit the above)

What this PR does / Why we need it?

This PR Focus on restructuring SetupOCMConnection for reusing existing connections rather than creating new one always.
SetupOCMConnection now reduce dependency of calling close in callers methods as cleanup is handled be a cleaner thread which starts after timeout interval (default 30s). If a connection is requested after a timeout interval, a new connection is created, again cleaner thread is also spawned to take care of resource cleanup.

Which Jira/Github issue(s) does this PR fix?

  • Related Issue #
  • Closes #

Special notes for your reviewer

Unit Test Coverage

Guidelines

  • If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
  • If it's a bug fix for an existing sub-command, please cover 70% of the code

Test coverage checks

  • Added unit tests
  • Created jira card to add unit test
  • [T ] This PR may not need unit tests

Unit Test can't be run as setup initiates actual ocm connection.
I have tested the updated code by running locally and making sure no leak is there and connections being utilized within timout interval and new connection being created after a timeout interval of previous connection. Adding a snipp of testcase and result.

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR
  • Backward compatible

/label tide/merge-method-squash

image

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 23, 2025

@karanjitsingh01: This pull request references SREP-969 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

Details

In response to this:

What type of PR is this?

  • fix (Bug Fix)
  • feat (New Feature)
  • docs (Documentation)
  • test (Test Coverage)
  • [] chore (Clean Up / Maintenance Tasks)
  • other (Anything that doesn't fit the above)

What this PR does / Why we need it?

This PR Focus on restructuring SetupOCMConnection for reusing existing connections rather than creating new one always.
SetupOCMConnection now reduce dependency of calling close in callers methods as cleanup is handled be a cleaner thread which starts after timeout interval (default 30s). If a connection is requested after a timeout interval, a new connection is created, again cleaner thread is also spawned to take care of resource cleanup.

Which Jira/Github issue(s) does this PR fix?

  • Related Issue #
  • Closes #

Special notes for your reviewer

Unit Test Coverage

Guidelines

  • If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
  • If it's a bug fix for an existing sub-command, please cover 70% of the code

Test coverage checks

  • Added unit tests
  • Created jira card to add unit test
  • This PR may not need unit tests

Unit Test can't be run as setup initiates actual ocm connection.
I have tested the updated code by running locally and making sure no leak is there and connections being utilized within timout interval and new connection being created after a timeout interval of previous connection. Adding a snipp of testcase and result.

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR
  • Backward compatible

/label tide/merge-method-squash

image

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 23, 2025

@karanjitsingh01: This pull request references SREP-969 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

Details

In response to this:

What type of PR is this?

  • fix (Bug Fix)
  • feat (New Feature)
  • docs (Documentation)
  • test (Test Coverage)
  • chore (Clean Up / Maintenance Tasks)
  • other (Anything that doesn't fit the above)

What this PR does / Why we need it?

This PR Focus on restructuring SetupOCMConnection for reusing existing connections rather than creating new one always.
SetupOCMConnection now reduce dependency of calling close in callers methods as cleanup is handled be a cleaner thread which starts after timeout interval (default 30s). If a connection is requested after a timeout interval, a new connection is created, again cleaner thread is also spawned to take care of resource cleanup.

Which Jira/Github issue(s) does this PR fix?

  • Related Issue #
  • Closes #

Special notes for your reviewer

Unit Test Coverage

Guidelines

  • If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
  • If it's a bug fix for an existing sub-command, please cover 70% of the code

Test coverage checks

  • Added unit tests
  • Created jira card to add unit test
  • This PR may not need unit tests

Unit Test can't be run as setup initiates actual ocm connection.
I have tested the updated code by running locally and making sure no leak is there and connections being utilized within timout interval and new connection being created after a timeout interval of previous connection. Adding a snipp of testcase and result.

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR
  • Backward compatible

/label tide/merge-method-squash

image

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 23, 2025

@karanjitsingh01: This pull request references SREP-969 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

Details

In response to this:

What type of PR is this?

  • fix (Bug Fix)
  • feat (New Feature)
  • docs (Documentation)
  • test (Test Coverage)
  • chore (Clean Up / Maintenance Tasks)
  • other (Anything that doesn't fit the above)

What this PR does / Why we need it?

This PR Focus on restructuring SetupOCMConnection for reusing existing connections rather than creating new one always.
SetupOCMConnection now reduce dependency of calling close in callers methods as cleanup is handled be a cleaner thread which starts after timeout interval (default 30s). If a connection is requested after a timeout interval, a new connection is created, again cleaner thread is also spawned to take care of resource cleanup.

Which Jira/Github issue(s) does this PR fix?

  • Related Issue #
  • Closes #

Special notes for your reviewer

Unit Test Coverage

Guidelines

  • If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
  • If it's a bug fix for an existing sub-command, please cover 70% of the code

Test coverage checks

  • Added unit tests
  • Created jira card to add unit test
  • This PR may not need unit tests

Unit Test can't be run as setup initiates actual ocm connection.
I have tested the updated code by running locally and making sure no leak is there and connections being utilized within timout interval and new connection being created after a timeout interval of previous connection. Adding a snipp of testcase and result.

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR
  • Backward compatible

/label tide/merge-method-squash

image

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 openshift-eng/jira-lifecycle-plugin repository.

@karanjitsingh01 karanjitsingh01 marked this pull request as ready for review September 24, 2025 03:15
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 24, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 25.92593% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.79%. Comparing base (1da978f) to head (2c4d63c).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/ocm/ocm.go 25.92% 18 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #785      +/-   ##
==========================================
+ Coverage   52.65%   52.79%   +0.13%     
==========================================
  Files          80       80              
  Lines        6056     6065       +9     
==========================================
+ Hits         3189     3202      +13     
+ Misses       2442     2435       -7     
- Partials      425      428       +3     
Files with missing lines Coverage Δ
...ocm-backplane/accessrequest/createAccessRequest.go 43.47% <ø> (+0.62%) ⬆️
...ocm-backplane/accessrequest/expireAccessRequest.go 34.61% <ø> (+1.28%) ⬆️
...md/ocm-backplane/accessrequest/getAccessRequest.go 36.00% <ø> (+1.38%) ⬆️
cmd/ocm-backplane/cloud/console.go 22.22% <ø> (+0.22%) ⬆️
cmd/ocm-backplane/cloud/credentials.go 63.38% <ø> (+0.88%) ⬆️
cmd/ocm-backplane/cloud/ssm.go 56.08% <ø> (+0.37%) ⬆️
pkg/login/printClusterInfo.go 80.95% <ø> (+3.67%) ⬆️
pkg/ocm/ocm.go 4.18% <25.92%> (+4.18%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pkg/ocm/ocm.go Outdated
Comment on lines 91 to 105
go func(ctx context.Context, cancel context.CancelFunc, conn *ocmsdk.Connection) {
fmt.Println("starting ocm connection timeout watcher", o.Timeout)
<-ctx.Done()
o.mu.Lock()
defer o.mu.Unlock()
if o.connection != nil {
logger.Debugln(fmt.Sprintf("closing ocm connection after %v", o.Timeout))
o.connection.Close()
o.connection = nil
}
// cancel the context to release resources
cancel()

}(ctx, cancel, connection)

Copy link
Contributor

Choose a reason for hiding this comment

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

What if the move go routine function as a new private method on DefaultOCMInterface stuct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, added as a private method for DefaultOCMInterface

pkg/ocm/ocm.go Outdated
Comment on lines 564 to 589
func createConnection() (*ocmsdk.Connection, error) {

envURL := os.Getenv("OCM_URL")
if envURL != "" {
// Fetch the real ocm url from the alias and set it back to the ENV
ocmURL, err := ocmurls.ResolveGatewayURL(envURL, nil)
if err != nil {
return nil, err
}
os.Setenv("OCM_URL", ocmURL)
logger.Debugf("reset the OCM_URL to %s", ocmURL)
}

// Setup connection at the first try
connection, err := ocmocm.NewConnection().Build()
if err != nil {
if strings.Contains(err.Error(), ocmNotLoggedInMessage) {
return nil, fmt.Errorf("please ensure you are logged into OCM by using the command " +
"\"ocm login --url $ENV\"")
} else {
return nil, err
}
}
fmt.Println("OCM connection established")
return connection, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if move this as a private function of DefaultOCMInterface ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, added as a private method for DefaultOCMInterface

pkg/ocm/ocm.go Outdated
// important to set a timeout to avoid leaking connections
// new connections are created if the previous one has been closed after the timeout
if o.Timeout == 0 {
o.Timeout = 30 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

may be move connection timeout as const , which may be easy to change via config in future

Copy link
Contributor Author

@karanjitsingh01 karanjitsingh01 Sep 25, 2025

Choose a reason for hiding this comment

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

added constant

pkg/ocm/ocm.go Outdated

type DefaultOCMInterfaceImpl struct {
// connection *ocmsdk.Connection
Timeout time.Duration // Timeout for the OCM connection can be set
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe ocmConnectionTimeout ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to ocmConnectionTimeout

pkg/ocm/ocm.go Outdated
type DefaultOCMInterfaceImpl struct {
// connection *ocmsdk.Connection
Timeout time.Duration // Timeout for the OCM connection can be set
mu sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

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

what if add the readble var name ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to ocmConnectionMutex


ocmsdk "github.com/openshift-online/ocm-sdk-go"
"github.com/openshift/backplane-cli/pkg/ocm"
"github.com/stretchr/testify/assert"
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't use the new test lib for asserting, pls reuse ginkgo and gomega

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for informing me, I wasn't aware that we have to strictly use ginkgo and gomega.
I have updated the tests accordingly.

@@ -0,0 +1,141 @@
package ocm_test
Copy link
Contributor

Choose a reason for hiding this comment

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

You may be able to move tests to https://github.com/openshift/backplane-cli/blob/main/pkg/ocm/ocm_test.go#L1 rather than adding a new file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reused existing test file and added new tests

go.mod Outdated
github.com/spf13/cobra v1.10.1
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
Copy link
Contributor

Choose a reason for hiding this comment

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

May not need new test ib , pls reuse existing test libs

Copy link
Contributor Author

@karanjitsingh01 karanjitsingh01 Sep 26, 2025

Choose a reason for hiding this comment

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

reused ginkgo, removed dependency in go mod as well

Comment on lines 116 to 121
conn1, _ := impl.SetupOCMConnection()
conn2, _ := impl.SetupOCMConnection()
assert.Equal(t, conn1, conn2, "connections should be reused before timeout")
assert.False(t, conn1.closed, "connection should be active initially")
assert.NotNil(t, conn1.ocmConnection, "real connection should not be nil")

Copy link
Contributor

Choose a reason for hiding this comment

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

Move all tests to the function with clear BDD patterns
ex : https://github.com/openshift/backplane-cli/blob/main/pkg/ocm/ocm_test.go#L30

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated tests to follow BDD pattern

assert.NotNil(t, conn3.ocmConnection, "real connection should not be nil")

// wait for new connection to auto-close
time.Sleep(250 * time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we inject small timeout for tests, otherwise all tests wait for 250 Millisecond

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reduced timeout for "fake ocm client" test to 50ms, total test is taking around 140-150ms.
reduced timeout for "real ocm connection" test to 100ms, I tested it with shorter duration, but real ocm connection is taking time to establish and close. overall time for test is around 450-500ms. we are creating 2 real connections and reusing them 3 times. after that we wait for closure routine to close ocm connection properly.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 26, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2025
pkg/ocm/ocm.go Outdated
}

func (o *DefaultOCMInterfaceImpl) initiateCloseConnection(ctx context.Context, cancel context.CancelFunc, conn *ocmsdk.Connection) {
fmt.Println("starting ocm connection timeout watcher", o.Timeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put this to logger Debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated !!
Just for thought, Should we have creation and closure of connection logs to info log level.
I am assuming that application should be running with info loglevel (default), and we should able to see when connection was established successfully and when it was closed in the logs. Reusing of connection can be with debug log level.

Copy link
Contributor

Choose a reason for hiding this comment

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

The default log level is warning, that means anything else below that would not be shown without additional parameters to the cli.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, then we only see WARN/ERROR/PANIC logs.
Those above logs have been added to debug level 👍

pkg/ocm/ocm.go Outdated
return nil, err
}
}
fmt.Println("OCM connection established")
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put this to logger Debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated !!

pkg/ocm/ocm.go Outdated
// connection *ocmsdk.Connection
Timeout time.Duration // Timeout for the OCM connection can be set
ocmConnectionMutex sync.Mutex
ocmConnectionTimeout *ocmsdk.Connection
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean ocmConnectionWithTimeout?
The name is timeout but the type is connection which is a bit confusing.

Copy link
Contributor Author

@karanjitsingh01 karanjitsingh01 Sep 29, 2025

Choose a reason for hiding this comment

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

yes, it was a miss while refactoring test, I have corrected the namings now, for connection -> ocmConnection and for timeout -> OcmConnectionTimeout

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 29, 2025

@karanjitsingh01: all tests passed!

Full PR test history. Your PR dashboard.

Details

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-sigs/prow repository. I understand the commands that are listed here.


type DefaultOCMInterfaceImpl struct {
// connection *ocmsdk.Connection
OcmConnectionTimeout time.Duration // Timeout for the OCM connection can be set
Copy link
Contributor

@bmeng bmeng Sep 30, 2025

Choose a reason for hiding this comment

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

Any reason to capitalize this one?

Copy link
Contributor Author

@karanjitsingh01 karanjitsingh01 Sep 30, 2025

Choose a reason for hiding this comment

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

Yes, It's made public, DefaultOCMInterfaceImpl timeout can be set while initializing,
something like - impl = &ocm.DefaultOCMInterfaceImpl{OcmConnectionTimeout: 100 * time.Millisecond}, by default the timeout is 30s if not initialized.

@xiaoyu74
Copy link
Contributor

Please add "chore:" in the PR title so it can be grouped under Chore to make our bp-cli release notes clearer

@karanjitsingh01 karanjitsingh01 changed the title SREP-969: Reuse Ocm Connection and handle closure of connection chore: SREP-969: Reuse Ocm Connection and handle closure of connection Sep 30, 2025
@karanjitsingh01
Copy link
Contributor Author

karanjitsingh01 commented Sep 30, 2025

Please add "chore:" in the PR title so it can be grouped under Chore to make our bp-cli release notes clearer

something like this "chore: SREP-969: Reuse Ocm Connection and handle closure of connection" ?

@bmeng
Copy link
Contributor

bmeng commented Sep 30, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 30, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bmeng, karanjitsingh01

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

The pull request process is described 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 30, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 039a6d5 into openshift:main Sep 30, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants