Skip to content

Commit 8ef80a5

Browse files
Fixed Panic Errors
1 parent 33d1650 commit 8ef80a5

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

pkg/operator/aws.go renamed to pkg/operator/awsTagController.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import (
3030
"github.com/openshift/cluster-image-registry-operator/pkg/storage/s3"
3131
)
3232

33-
// AWSController is for storing internal data required for
33+
// AWSTagController is for storing internal data required for
3434
// performing AWS controller operations
35-
type AWSController struct {
35+
type AWSTagController struct {
3636
infraConfigClient configv1client.InfrastructureInterface
3737
imageRegistryConfigClient imageregistryv1client.ConfigInterface
3838
listers *regopclient.Listers
@@ -55,9 +55,9 @@ var kubernetesNamespaceRegex = regexp.MustCompile(`^([^/]*\.)?kubernetes.io/`)
5555
// openshiftNamespaceRegex is used to check that a tag key is not in the openshift.io namespace.
5656
var openshiftNamespaceRegex = regexp.MustCompile(`^([^/]*\.)?openshift.io/`)
5757

58-
// NewAWSController is for obtaining AWSController object
59-
// required for invoking AWS controller methods.
60-
func NewAWSController(
58+
// NewAWSTagController is for obtaining AWSTagController object
59+
// required for invoking AWS Tag controller methods.
60+
func NewAWSTagController(
6161
infraConfigClient configv1client.InfrastructureInterface,
6262
imageRegistryConfigClient imageregistryv1client.ConfigInterface,
6363
kubeInformerFactory kubeinformers.SharedInformerFactory,
@@ -68,15 +68,15 @@ func NewAWSController(
6868
openshiftConfigManagedKubeInformerFactory kubeinformers.SharedInformerFactory,
6969
eventRecorder events.Recorder,
7070
featureGateAccessor featuregates.FeatureGateAccess,
71-
) (*AWSController, error) {
72-
c := &AWSController{
71+
) (*AWSTagController, error) {
72+
c := &AWSTagController{
7373
infraConfigClient: infraConfigClient,
7474
imageRegistryConfigClient: imageRegistryConfigClient,
7575
featureGateAccessor: featureGateAccessor,
7676
event: eventRecorder,
7777
queue: workqueue.NewNamedRateLimitingQueue(
7878
workqueue.DefaultControllerRateLimiter(),
79-
"AWSController"),
79+
"AWSTagController"),
8080
}
8181

8282
infraConfig := configInformerFactory.Config().V1().Infrastructures()
@@ -118,15 +118,16 @@ func NewAWSController(
118118
}
119119

120120
// eventHandler is the callback method for handling events from informer
121-
func (c *AWSController) eventHandler() cache.ResourceEventHandler {
121+
func (c *AWSTagController) eventHandler() cache.ResourceEventHandler {
122122
const workQueueKey = "aws"
123123
return cache.ResourceEventHandlerFuncs{
124124
AddFunc: func(obj interface{}) {
125125
infra, ok := obj.(*configv1.Infrastructure)
126126
if !ok || infra == nil {
127127
return
128128
}
129-
if infra.Status.PlatformStatus.AWS != nil && len(infra.Status.PlatformStatus.AWS.ResourceTags) != 0 {
129+
if infra.Status.PlatformStatus != nil && infra.Status.PlatformStatus.AWS != nil &&
130+
len(infra.Status.PlatformStatus.AWS.ResourceTags) != 0 {
130131
c.queue.Add(workQueueKey)
131132
return
132133
}
@@ -140,7 +141,8 @@ func (c *AWSController) eventHandler() cache.ResourceEventHandler {
140141
if !ok || newInfra == nil {
141142
return
142143
}
143-
if oldInfra.Status.PlatformStatus.AWS != nil && newInfra.Status.PlatformStatus.AWS != nil {
144+
if oldInfra.Status.PlatformStatus != nil && oldInfra.Status.PlatformStatus.AWS != nil &&
145+
newInfra.Status.PlatformStatus != nil && newInfra.Status.PlatformStatus.AWS != nil {
144146
if !reflect.DeepEqual(oldInfra.Status.PlatformStatus.AWS.ResourceTags, newInfra.Status.PlatformStatus.AWS.ResourceTags) {
145147
c.queue.Add(workQueueKey)
146148
return
@@ -151,7 +153,7 @@ func (c *AWSController) eventHandler() cache.ResourceEventHandler {
151153
}
152154

153155
// Run is the main method for starting the AWS controller
154-
func (c *AWSController) Run(ctx context.Context) {
156+
func (c *AWSTagController) Run(ctx context.Context) {
155157
defer k8sruntime.HandleCrash()
156158
defer c.queue.ShutDown()
157159

@@ -167,14 +169,14 @@ func (c *AWSController) Run(ctx context.Context) {
167169
klog.Infof("Shutting down AWS Controller")
168170
}
169171

170-
func (c *AWSController) runWorker() {
172+
func (c *AWSTagController) runWorker() {
171173
for c.processNextWorkItem() {
172174
}
173175
}
174176

175177
// processNextWorkItem is for prcessing the event received
176178
// which blocks until a new item is received
177-
func (c *AWSController) processNextWorkItem() bool {
179+
func (c *AWSTagController) processNextWorkItem() bool {
178180
obj, shutdown := c.queue.Get()
179181
if shutdown {
180182
return false
@@ -196,14 +198,14 @@ func (c *AWSController) processNextWorkItem() bool {
196198
// on receiving a informer event.
197199
// Fetches image registry config data, required for obtaining
198200
// the S3 bucket configuration and creating a driver out of it
199-
func (c *AWSController) sync() error {
201+
func (c *AWSTagController) sync() error {
200202
return c.syncTags()
201203
}
202204

203205
// syncTags fetches user tags from Infrastructure resource, which
204206
// is then compared with the tags configured for the created S3 bucket
205207
// fetched using the driver object passed and updates if any new tags.
206-
func (c *AWSController) syncTags() error {
208+
func (c *AWSTagController) syncTags() error {
207209
cr, err := c.imageRegistryConfigClient.Get(
208210
context.Background(),
209211
defaults.ImageRegistryResourceName,

pkg/operator/starter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func RunOperator(ctx context.Context, kubeconfig *restclient.Config) error {
217217
return err
218218
}
219219

220-
awsController, err := NewAWSController(
220+
awsTagController, err := NewAWSTagController(
221221
configClient.ConfigV1().Infrastructures(),
222222
imageregistryClient.ImageregistryV1().Configs(),
223223
kubeInformers,
@@ -251,10 +251,10 @@ func RunOperator(ctx context.Context, kubeconfig *restclient.Config) error {
251251
go imageConfigStatusController.Run(ctx.Done())
252252
go imagePrunerController.Run(ctx.Done())
253253
go loggingController.Run(ctx, 1)
254-
go metricsController.Run(ctx)
255254
go azureStackCloudController.Run(ctx)
256255
go azurePathFixController.Run(ctx.Done())
257-
go awsController.Run(ctx)
256+
go awsTagController.Run(ctx)
257+
go metricsController.Run(ctx)
258258

259259
//// Fetch on Infrastructure resource is trivial and failure to fetch
260260
//// shouldn't be a reason to shutdown operator. Starting an unnecessary

0 commit comments

Comments
 (0)