MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / Reload

Function Reload

internal/cmd/plugin/reload/reload.go:36–59  ·  view source on GitHub ↗

Reload marks the cluster as needing to have a reconciliation loop

(ctx context.Context, clusterName string)

Source from the content-addressed store, hash-verified

34
35// Reload marks the cluster as needing to have a reconciliation loop
36func 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}

Callers 1

NewCmdFunction · 0.85

Calls 3

DeepCopyMethod · 0.95
GetMethod · 0.45
PatchMethod · 0.45

Tested by

no test coverage detected