This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
smi/health: fix race condition leading to controller crash
This change fixes a bug where a pkg scoped map is being concurrently modified to check if SMI API resources are available. Additionally, it refactors the code for clarity and better unit testing. Signed-off-by: Shashank Ram <[email protected]>
- Loading branch information
1 parent
509f30b
commit 35dcb3d
Showing
5 changed files
with
211 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package k8s | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/discovery" | ||
) | ||
|
||
// FakeDiscoveryClient is a fake client for k8s API discovery | ||
type FakeDiscoveryClient struct { | ||
discovery.ServerResourcesInterface | ||
Resources map[string]metav1.APIResourceList | ||
Err error | ||
} | ||
|
||
// ServerResourcesForGroupVersion returns the supported resources for a group and version. | ||
func (f *FakeDiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) { | ||
resp := f.Resources[groupVersion] | ||
return &resp, f.Err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.