Reload marks the cluster as needing to have a reconciliation loop
(ctx context.Context, clusterName string)
| 34 | |
| 35 | // Reload marks the cluster as needing to have a reconciliation loop |
| 36 | func Reload(ctx context.Context, clusterName string) error { |
| 37 | var cluster apiv1.Cluster |
| 38 | |
| 39 | // Get the Cluster object |
| 40 | err := plugin.Client.Get(ctx, client.ObjectKey{Namespace: plugin.Namespace, Name: clusterName}, &cluster) |
| 41 | if err != nil { |
| 42 | return err |
| 43 | } |
| 44 | |
| 45 | clusterRestarted := cluster.DeepCopy() |
| 46 | if clusterRestarted.Annotations == nil { |
| 47 | clusterRestarted.Annotations = make(map[string]string) |
| 48 | } |
| 49 | clusterRestarted.Annotations[utils.ClusterReloadAnnotationName] = pgTime.GetCurrentTimestamp() |
| 50 | clusterRestarted.ManagedFields = nil |
| 51 | |
| 52 | err = plugin.Client.Patch(ctx, clusterRestarted, client.MergeFrom(&cluster)) |
| 53 | if err != nil { |
| 54 | return err |
| 55 | } |
| 56 | |
| 57 | fmt.Printf("%s will be reloaded\n", clusterRestarted.Name) |
| 58 | return nil |
| 59 | } |