(ctx context.Context, instance *postgres.Instance, info postgres.InitInfo)
| 95 | } |
| 96 | |
| 97 | func joinSubCommand(ctx context.Context, instance *postgres.Instance, info postgres.InitInfo) error { |
| 98 | contextLogger := log.FromContext(ctx) |
| 99 | |
| 100 | if err := info.EnsureTargetDirectoriesDoNotExist(ctx); err != nil { |
| 101 | return err |
| 102 | } |
| 103 | |
| 104 | client, err := management.NewControllerRuntimeClient() |
| 105 | if err != nil { |
| 106 | contextLogger.Error(err, "Error creating Kubernetes client") |
| 107 | return err |
| 108 | } |
| 109 | |
| 110 | // Download the cluster definition from the API server |
| 111 | var cluster apiv1.Cluster |
| 112 | if err := client.Get(ctx, |
| 113 | ctrl.ObjectKey{Namespace: instance.GetNamespaceName(), Name: instance.GetClusterName()}, |
| 114 | &cluster, |
| 115 | ); err != nil { |
| 116 | contextLogger.Error(err, "Error while getting cluster") |
| 117 | return err |
| 118 | } |
| 119 | instance.SetCluster(&cluster) |
| 120 | |
| 121 | if _, err := instancecertificate.NewReconciler(client, instance).RefreshSecrets(ctx, &cluster); err != nil { |
| 122 | contextLogger.Error(err, "Error while refreshing secrets") |
| 123 | return err |
| 124 | } |
| 125 | |
| 126 | // Run "pg_basebackup" to download the data directory from the primary |
| 127 | if err := info.Join(ctx, &cluster); err != nil { |
| 128 | contextLogger.Error(err, "Error joining node") |
| 129 | return err |
| 130 | } |
| 131 | |
| 132 | return nil |
| 133 | } |
no test coverage detected