Skip to content

Commit b668a27

Browse files
Prepare v0.2 release (#36)
1 parent a5f8bc3 commit b668a27

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

.github/workflows/create-gh-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
uses: SneaksAndData/github-actions/semver_release@v0.1.9
1717
with:
1818
major_v: 0
19-
minor_v: 1
19+
minor_v: 2

.helm/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ controller:
177177
# A name for a Secret resource that contains Datadog API Key to use for log submissions
178178
apiKeySecret: "secretName"
179179

180-
# A key in the Secret that contains Datadog API Key
180+
# a key in the secret that contains datadog api key
181181
apiKeySecretKey: "secretKey"
182182

183183
# Datadog Service Name parameter

controller.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,7 @@ func (c *Controller) runWorker(ctx context.Context) {
318318
// attempt to process it, by calling the syncHandler.
319319
func (c *Controller) processNextWorkItem(ctx context.Context) bool { // coverage-ignore
320320
objRef, shutdown := c.workqueue.Get()
321-
logger := klog.FromContext(ctx)
322-
metrics := ctx.Value("metrics").(*statsd.Client)
321+
metrics := ctx.Value(telemetry.MetricsClientContextKey).(*statsd.Client)
323322
itemProcessStart := time.Now()
324323

325324
if shutdown {
@@ -342,7 +341,6 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool { // coverage
342341
// If no error occurs then we Forget this item so it does not
343342
// get queued again until another change happens.
344343
c.workqueue.Forget(objRef)
345-
logger.Info("Successfully synced", "objectName", objRef)
346344
return true
347345
}
348346
// there was a failure so be sure to report it. This method allows for
@@ -415,7 +413,7 @@ func (c *Controller) syncSecretsToShard(secretNamespace string, controllerMla *v
415413
// Get the secret with the name specified in MachineLearningAlgorithm.spec
416414
secret, err := c.secretLister.Secrets(secretNamespace).Get(secretName)
417415
// If the referenced Secret resource doesn't exist in the cluster where the controller is deployed, update the syncErr and move on to the next Secret
418-
if k8serrors.IsNotFound(err) {
416+
if k8serrors.IsNotFound(err) { // coverage-ignore
419417
msg := fmt.Sprintf(MessageResourceMissing, secretName, controllerMla.Name)
420418
c.recorder.Event(controllerMla, corev1.EventTypeWarning, ErrResourceMissing, msg)
421419
logger.V(4).Info("Secret not found", "secretName", secretName, "shard", shard.Name)
@@ -429,15 +427,15 @@ func (c *Controller) syncSecretsToShard(secretNamespace string, controllerMla *v
429427
}
430428

431429
// requeue on error
432-
if err != nil {
430+
if err != nil { // coverage-ignore
433431
msg := fmt.Sprintf(MessageResourceOperationFailed, secretName, controllerMla.Name, err)
434432
c.recorder.Event(controllerMla, corev1.EventTypeWarning, ErrResourceSyncError, msg)
435433
return err
436434
}
437435

438436
missingOwner, err := c.isMissingOwnership(shardSecret, shardMla)
439437
// requeue on error
440-
if err != nil {
438+
if err != nil { // coverage-ignore
441439
msg := fmt.Sprintf(MessageResourceOperationFailed, secretName, controllerMla.Name, err)
442440
c.recorder.Event(controllerMla, corev1.EventTypeWarning, ErrResourceSyncError, msg)
443441
return err
@@ -477,7 +475,7 @@ func (c *Controller) syncConfigMapsToShard(configMapNamespace string, controller
477475
// Get the ConfigMap with the name specified in MachineLearningAlgorithm.spec
478476
configMap, err := c.configMapLister.ConfigMaps(configMapNamespace).Get(configMapName)
479477
// If the referenced ConfigMap resource doesn't exist in the cluster where the controller is deployed, update syncErr and move on to the next ConfigMap
480-
if k8serrors.IsNotFound(err) {
478+
if k8serrors.IsNotFound(err) { // coverage-ignore
481479
msg := fmt.Sprintf(MessageResourceMissing, configMapName, controllerMla.Name)
482480
c.recorder.Event(controllerMla, corev1.EventTypeWarning, ErrResourceMissing, msg)
483481
logger.V(4).Info("ConfigMap not found", "configMapName", configMapName, "shard", shard.Name)
@@ -486,20 +484,20 @@ func (c *Controller) syncConfigMapsToShard(configMapNamespace string, controller
486484

487485
shardConfigMap, err := shard.ConfigMapLister.ConfigMaps(shardMla.Namespace).Get(configMap.Name)
488486
// secret does not exist in this shard, create it
489-
if k8serrors.IsNotFound(err) {
487+
if k8serrors.IsNotFound(err) { // coverage-ignore
490488
shardConfigMap, err = shard.CreateConfigMap(shardMla, configMap, FieldManager)
491489
}
492490

493491
// requeue on error
494-
if err != nil {
492+
if err != nil { // coverage-ignore
495493
msg := fmt.Sprintf(MessageResourceOperationFailed, configMapName, controllerMla.Name, err)
496494
c.recorder.Event(controllerMla, corev1.EventTypeWarning, ErrResourceSyncError, msg)
497495
return err
498496
}
499497

500498
missingOwner, err := c.isMissingOwnership(shardConfigMap, shardMla)
501499
// requeue on error
502-
if err != nil {
500+
if err != nil { // coverage-ignore
503501
msg := fmt.Sprintf(MessageResourceOperationFailed, configMapName, controllerMla.Name, err)
504502
c.recorder.Event(controllerMla, corev1.EventTypeWarning, ErrResourceSyncError, msg)
505503
return err

pkg/telemetry/app_metrics.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"time"
2323
)
2424

25+
type contextKey string
26+
2527
const (
2628
// MetricsNamespace sets the datadog metrics namespace to use
2729
MetricsNamespace = "ncc"
@@ -31,31 +33,27 @@ const (
3133

3234
// WorkqueueLengthMetric name for statsd
3335
WorkqueueLengthMetric = "workqueue_length"
36+
37+
MetricsClientContextKey contextKey = "metrics"
3438
)
3539

3640
// WithStatsd enriches the context with a statsd client if it can be instantiated
3741
func WithStatsd(ctx context.Context) context.Context { // coverage-ignore
3842
statsdClient, err := statsd.New("", statsd.WithNamespace(MetricsNamespace))
3943
if err == nil {
40-
return context.WithValue(ctx, "metrics", statsdClient)
44+
return context.WithValue(ctx, MetricsClientContextKey, statsdClient)
4145
}
4246

4347
return ctx
4448
}
4549

4650
// Gauge reports a GAUGE metric using best-effort approach
4751
func Gauge(metrics *statsd.Client, name string, value float64, tags []string, rate float64) { // coverage-ignore
48-
err := metrics.Gauge(name, value, tags, rate)
49-
if err != nil {
50-
// do nothing
51-
}
52+
_ = metrics.Gauge(name, value, tags, rate)
5253
}
5354

5455
// GaugeDuration reports a GAUGE metric corresponding to a duration of an operation that started at a specified time, in milliseconds
5556
func GaugeDuration(metrics *statsd.Client, name string, startedAt time.Time, tags []string, rate float64) { // coverage-ignore
5657
duration := time.Since(startedAt).Milliseconds()
57-
err := metrics.Gauge(name, float64(duration), tags, rate)
58-
if err != nil {
59-
// do nothing
60-
}
58+
_ = metrics.Gauge(name, float64(duration), tags, rate)
6159
}

0 commit comments

Comments
 (0)