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

fix unmarshal err for blank field #283

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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