Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #283 from stewart-yu/stewart-bugfix
Browse files Browse the repository at this point in the history
fix unmarshal err for blank field
  • Loading branch information
k8s-ci-robot authored Oct 25, 2019
2 parents 2cdce45 + 55ecff3 commit af8eedb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions internal/locking/control_plane_init_mutex.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (c *ControlPlaneInitMutex) Lock(ctx context.Context, cluster *clusterv1.Clu
err := c.client.Get(ctx, client.ObjectKey{
Namespace: cluster.Namespace,
Name: cmName,
}, &sema.ConfigMap)
}, sema.ConfigMap)
switch {
case apierrors.IsNotFound(err):
break
Expand Down Expand Up @@ -82,9 +82,8 @@ func (c *ControlPlaneInitMutex) Lock(ctx context.Context, cluster *clusterv1.Clu
log.Error(err, "Failed to acquire lock while setting semaphore information")
return false
}

log.Info("Attempting to acquire the lock")
err = c.client.Create(ctx, &sema.ConfigMap)
err = c.client.Create(ctx, sema.ConfigMap)
switch {
case apierrors.IsAlreadyExists(err):
log.Info("Cannot acquire the lock. The lock has been acquired by someone else")
Expand All @@ -106,7 +105,7 @@ func (c *ControlPlaneInitMutex) Unlock(ctx context.Context, cluster *clusterv1.C
err := c.client.Get(ctx, client.ObjectKey{
Namespace: cluster.Namespace,
Name: cmName,
}, &sema.ConfigMap)
}, sema.ConfigMap)
switch {
case apierrors.IsNotFound(err):
log.Info("Control plane init lock not found, it may have been released already")
Expand All @@ -116,7 +115,7 @@ func (c *ControlPlaneInitMutex) Unlock(ctx context.Context, cluster *clusterv1.C
return false
default:
// Delete the config map semaphore if there is no error fetching it
if err := c.client.Delete(ctx, &sema.ConfigMap); err != nil {
if err := c.client.Delete(ctx, sema.ConfigMap); err != nil {
// TODO: return true on apierrors.IsNotFound
log.Error(err, "Error deleting the config map underlying the control plane init lock")
return false
Expand All @@ -130,11 +129,11 @@ type information struct {
}

type semaphore struct {
apicorev1.ConfigMap
*apicorev1.ConfigMap
}

func newSemaphore() *semaphore {
return &semaphore{apicorev1.ConfigMap{}}
return &semaphore{&apicorev1.ConfigMap{}}
}

func configMapName(clusterName string) string {
Expand Down

0 comments on commit af8eedb

Please sign in to comment.