Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit 64f318f

Browse files
authored
Cancel refresh of StorageOS token (#67)
* Cancel refresh of StorageOS token * Remove duplicated licence header * Fix typo at CRD ServerURL
1 parent 825d7de commit 64f318f

File tree

5 files changed

+11
-23
lines changed

5 files changed

+11
-23
lines changed

api/v1alpha1/portalconfig_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type IOTCoreConfig struct {
3131
// Region is the GCP region, e.g. "europe-west1".
3232
Region string `json:"region,omitempty"`
3333

34-
// SeverURL is the url of the iot server
34+
// ServerURL is the url of the iot server
3535
ServerURL string `json:"serverUrl,omitempty"`
3636

3737
// SignatureKey is the public part of message signature keys.

config/crd/bases/storageos.com_portalconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ spec:
9090
description: Registry is the ID of the IOT Core Registry.
9191
type: string
9292
serverUrl:
93-
description: SeverURL is the url of the iot server
93+
description: ServerURL is the url of the iot server
9494
type: string
9595
signatureKey:
9696
description: SignatureKey is the public part of message signature

controllers/config_controller.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
/*
22
Copyright 2022.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
16-
17-
/*
18-
Copyright 2022.
19-
204
Licensed under the Apache License, Version 2.0 (the "License");
215
you may not use this file except in compliance with the License.
226
You may obtain a copy of the License at

endpoints/storageos.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (e *StorageOSEndpoint) UpdateLicence(key string) (*stosapiv2.Licence, error
5151
}
5252

5353
// Start start endpoint service and token refresh.
54-
func (e *StorageOSEndpoint) Start() error {
54+
func (e *StorageOSEndpoint) Start(ctx context.Context) error {
5555
e.logger.V(3).Info("Start storageos endpoint...")
5656

5757
var err error
@@ -67,14 +67,18 @@ func (e *StorageOSEndpoint) Start() error {
6767

6868
e.logger.V(3).Info("Storageos endpoint started", "ClusterID", e.clusterID)
6969

70-
// TODO would be nice to properly stop refresh.
7170
go func() {
7271
for {
73-
if err := e.client.Refresh(context.Background(), time.Minute); err != nil {
72+
if err := e.client.Refresh(ctx, time.Minute); err != nil {
7473
e.logger.Error(err, "Failed to start refresh")
7574
}
7675

77-
time.Sleep(time.Second)
76+
select {
77+
case <-ctx.Done():
78+
return
79+
default:
80+
time.Sleep(time.Second)
81+
}
7882
}
7983
}()
8084

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func main() {
173173
stosService := fmt.Sprintf(stosServiceTemplate, currentNS)
174174

175175
stosEndpoint := endpoints.NewStorageOSEndpoint(stosUsername, stosPassword, stosService, logger)
176-
err = stosEndpoint.Start()
176+
err = stosEndpoint.Start(ctx)
177177
if err != nil {
178178
setupLogger.Error(err, "unable to start storageos endpoint")
179179
panic(err)

0 commit comments

Comments
 (0)