/
start.go
595 lines (514 loc) · 21.3 KB
/
start.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
package machine
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
"github.com/code-ready/crc/pkg/crc/cluster"
"github.com/code-ready/crc/pkg/crc/constants"
crcerrors "github.com/code-ready/crc/pkg/crc/errors"
"github.com/code-ready/crc/pkg/crc/logging"
"github.com/code-ready/crc/pkg/crc/machine/bundle"
"github.com/code-ready/crc/pkg/crc/machine/config"
"github.com/code-ready/crc/pkg/crc/network"
"github.com/code-ready/crc/pkg/crc/oc"
"github.com/code-ready/crc/pkg/crc/services"
"github.com/code-ready/crc/pkg/crc/services/dns"
"github.com/code-ready/crc/pkg/crc/ssh"
crcssh "github.com/code-ready/crc/pkg/crc/ssh"
"github.com/code-ready/crc/pkg/crc/systemd"
"github.com/code-ready/crc/pkg/crc/telemetry"
"github.com/code-ready/crc/pkg/libmachine"
"github.com/code-ready/crc/pkg/libmachine/host"
crcos "github.com/code-ready/crc/pkg/os"
"github.com/code-ready/machine/libmachine/drivers"
"github.com/code-ready/machine/libmachine/state"
"github.com/docker/go-units"
"github.com/pkg/errors"
)
const minimumMemoryForMonitoring = 14336
func getCrcBundleInfo(bundlePath string) (*bundle.CrcBundleInfo, error) {
bundleName := filepath.Base(bundlePath)
bundleInfo, err := bundle.Use(bundleName)
if err == nil {
logging.Infof("Loading bundle: %s ...", bundleName)
return bundleInfo, nil
}
logging.Debugf("Failed to load bundle %s: %v", bundleName, err)
logging.Infof("Extracting bundle: %s ...", bundleName)
if _, err := bundle.Extract(bundlePath); err != nil {
return nil, err
}
return bundle.Use(bundleName)
}
func (client *client) updateVMConfig(startConfig StartConfig, api libmachine.API, host *host.Host) error {
/* Memory */
logging.Debugf("Updating CRC VM configuration")
if err := setMemory(host, startConfig.Memory); err != nil {
logging.Debugf("Failed to update CRC VM configuration: %v", err)
if err == drivers.ErrNotImplemented {
logging.Warn("Memory configuration change has been ignored as the machine driver does not support it")
} else {
return err
}
}
if err := setVcpus(host, startConfig.CPUs); err != nil {
logging.Debugf("Failed to update CRC VM configuration: %v", err)
if err == drivers.ErrNotImplemented {
logging.Warn("CPU configuration change has been ignored as the machine driver does not support it")
} else {
return err
}
}
if err := api.Save(host); err != nil {
return err
}
/* Disk size */
if startConfig.DiskSize != constants.DefaultDiskSize {
if err := setDiskSize(host, startConfig.DiskSize); err != nil {
logging.Debugf("Failed to update CRC disk configuration: %v", err)
if err == drivers.ErrNotImplemented {
logging.Warn("Disk size configuration change has been ignored as the machine driver does not support it")
} else {
return err
}
}
if err := api.Save(host); err != nil {
return err
}
}
return nil
}
func (client *client) Start(ctx context.Context, startConfig StartConfig) (*StartResult, error) {
telemetry.SetCPUs(ctx, startConfig.CPUs)
telemetry.SetMemory(ctx, uint64(startConfig.Memory)*1024*1024)
telemetry.SetDiskSize(ctx, uint64(startConfig.DiskSize)*1024*1024*1024)
if err := client.validateStartConfig(startConfig); err != nil {
return nil, err
}
var crcBundleMetadata *bundle.CrcBundleInfo
libMachineAPIClient, cleanup := createLibMachineClient()
defer cleanup()
// Pre-VM start
var host *host.Host
exists, err := client.Exists()
if err != nil {
return nil, errors.Wrap(err, "Cannot determine if VM exists")
}
if !exists {
telemetry.SetStartType(ctx, telemetry.CreationStartType)
// Ask early for pull secret if it hasn't been requested yet
_, err = startConfig.PullSecret.Value()
if err != nil {
return nil, errors.Wrap(err, "Failed to ask for pull secret")
}
machineConfig := config.MachineConfig{
Name: client.name,
BundleName: filepath.Base(startConfig.BundlePath),
CPUs: startConfig.CPUs,
Memory: startConfig.Memory,
DiskSize: startConfig.DiskSize,
NetworkMode: client.networkMode(),
}
crcBundleMetadata, err = getCrcBundleInfo(startConfig.BundlePath)
if err != nil {
return nil, errors.Wrap(err, "Error getting bundle metadata")
}
if client.useVSock() {
if err := exposePorts(); err != nil {
return nil, err
}
}
logging.Infof("Creating CodeReady Containers VM for OpenShift %s...", crcBundleMetadata.GetOpenshiftVersion())
// Retrieve metadata info
machineConfig.ImageSourcePath = crcBundleMetadata.GetDiskImagePath()
machineConfig.ImageFormat = crcBundleMetadata.Storage.DiskImages[0].Format
machineConfig.SSHKeyPath = crcBundleMetadata.GetSSHKeyPath()
machineConfig.KernelCmdLine = crcBundleMetadata.Nodes[0].KernelCmdLine
machineConfig.Initramfs = crcBundleMetadata.GetInitramfsPath()
machineConfig.Kernel = crcBundleMetadata.GetKernelPath()
host, err = createHost(libMachineAPIClient, machineConfig)
if err != nil {
return nil, errors.Wrap(err, "Error creating machine")
}
} else { // exists
host, err = libMachineAPIClient.Load(client.name)
if err != nil {
return nil, errors.Wrap(err, "Error loading machine")
}
crcBundleMetadata, err = getBundleMetadataFromDriver(host.Driver)
if err != nil {
return nil, errors.Wrap(err, "Error loading bundle metadata")
}
bundleName := crcBundleMetadata.GetBundleName()
if bundleName != filepath.Base(startConfig.BundlePath) {
logging.Debugf("Bundle '%s' was requested, but the existing VM is using '%s'",
filepath.Base(startConfig.BundlePath), bundleName)
return nil, fmt.Errorf("Bundle '%s' was requested, but the existing VM is using '%s'",
filepath.Base(startConfig.BundlePath),
bundleName)
}
vmState, err := host.Driver.GetState()
if err != nil {
return nil, errors.Wrap(err, "Error getting the machine state")
}
if vmState == state.Running {
logging.Infof("A CodeReady Containers VM for OpenShift %s is already running", crcBundleMetadata.GetOpenshiftVersion())
clusterConfig, err := getClusterConfig(crcBundleMetadata)
if err != nil {
return nil, errors.Wrap(err, "Cannot create cluster configuration")
}
telemetry.SetStartType(ctx, telemetry.AlreadyRunningStartType)
return &StartResult{
Status: vmState,
ClusterConfig: *clusterConfig,
KubeletStarted: true,
}, nil
}
if _, err := bundle.Use(bundleName); err != nil {
return nil, err
}
if client.useVSock() {
if err := exposePorts(); err != nil {
return nil, err
}
}
telemetry.SetStartType(ctx, telemetry.StartStartType)
logging.Infof("Starting CodeReady Containers VM for OpenShift %s...", crcBundleMetadata.GetOpenshiftVersion())
if err := client.updateVMConfig(startConfig, libMachineAPIClient, host); err != nil {
return nil, errors.Wrap(err, "Could not update CRC VM configuration")
}
if err := host.Driver.Start(); err != nil {
return nil, errors.Wrap(err, "Error starting stopped VM")
}
}
if runtime.GOOS == "darwin" && client.useVSock() {
if err := makeDaemonVisibleToHyperkit(client.name); err != nil {
return nil, err
}
}
clusterConfig, err := getClusterConfig(crcBundleMetadata)
if err != nil {
return nil, errors.Wrap(err, "Cannot create cluster configuration")
}
// Post-VM start
vmState, err := host.Driver.GetState()
if err != nil {
return nil, errors.Wrap(err, "Error getting the state")
}
if vmState != state.Running {
return nil, errors.Wrap(err, "CodeReady Containers VM is not running")
}
instanceIP, err := getIP(host, client.useVSock())
if err != nil {
return nil, errors.Wrap(err, "Error getting the IP")
}
sshRunner, err := crcssh.CreateRunner(instanceIP, getSSHPort(client.useVSock()), crcBundleMetadata.GetSSHKeyPath(), constants.GetPrivateKeyPath(), constants.GetRsaPrivateKeyPath())
if err != nil {
return nil, errors.Wrap(err, "Error creating the ssh client")
}
defer sshRunner.Close()
logging.Debug("Waiting until ssh is available")
if err := cluster.WaitForSSH(sshRunner); err != nil {
return nil, errors.Wrap(err, "Failed to connect to the CRC VM with SSH -- host might be unreachable")
}
logging.Info("CodeReady Containers VM is running")
// Post VM start immediately update SSH key and copy kubeconfig to instance
// dir and VM
if err := updateSSHKeyAndCopyKubeconfig(sshRunner, client.name, crcBundleMetadata); err != nil {
return nil, errors.Wrap(err, "Error updating public key")
}
// Trigger disk resize, this will be a no-op if no disk size change is needed
if _, _, err = sshRunner.Run("sudo xfs_growfs / >/dev/null"); err != nil {
return nil, errors.Wrap(err, "Error updating filesystem size")
}
// Start network time synchronization if `CRC_DEBUG_ENABLE_STOP_NTP` is not set
if stopNtp, _ := strconv.ParseBool(os.Getenv("CRC_DEBUG_ENABLE_STOP_NTP")); !stopNtp {
logging.Info("Starting network time synchronization in CodeReady Containers VM")
if _, _, err := sshRunner.Run("sudo timedatectl set-ntp on"); err != nil {
return nil, errors.Wrap(err, "Failed to start network time synchronization")
}
}
// Add nameserver to VM if provided by User
if startConfig.NameServer != "" {
if err = addNameServerToInstance(sshRunner, startConfig.NameServer); err != nil {
return nil, errors.Wrap(err, "Failed to add nameserver to the VM")
}
}
proxyConfig, err := getProxyConfig(crcBundleMetadata.ClusterInfo.BaseDomain)
if err != nil {
return nil, errors.Wrap(err, "Error getting proxy configuration")
}
proxyConfig.ApplyToEnvironment()
proxyConfig.AddNoProxy(instanceIP)
// Create servicePostStartConfig for DNS checks and DNS start.
servicePostStartConfig := services.ServicePostStartConfig{
Name: client.name,
// TODO: would prefer passing in a more generic type
SSHRunner: sshRunner,
IP: instanceIP,
// TODO: should be more finegrained
BundleMetadata: *crcBundleMetadata,
NetworkMode: client.networkMode(),
}
// Run the DNS server inside the VM
if err := dns.RunPostStart(servicePostStartConfig); err != nil {
return nil, errors.Wrap(err, "Error running post start")
}
// Check DNS lookup before starting the kubelet
if queryOutput, err := dns.CheckCRCLocalDNSReachable(servicePostStartConfig); err != nil {
if !client.useVSock() {
return nil, errors.Wrapf(err, "Failed internal DNS query: %s", queryOutput)
}
logging.Warn(fmt.Sprintf("Failed internal DNS query: %s: %v", queryOutput, err))
}
logging.Info("Check internal and public DNS query ...")
if queryOutput, err := dns.CheckCRCPublicDNSReachable(servicePostStartConfig); err != nil {
logging.Warnf("Failed public DNS query from the cluster: %v : %s", err, queryOutput)
}
// Check DNS lookup from host to VM
logging.Info("Check DNS query from host ...")
if err := network.CheckCRCLocalDNSReachableFromHost(crcBundleMetadata, instanceIP); err != nil {
if !client.useVSock() {
return nil, errors.Wrap(err, "Failed to query DNS from host")
}
logging.Warn(fmt.Sprintf("Failed to query DNS from host: %v", err))
}
if err := cluster.EnsurePullSecretPresentOnInstanceDisk(sshRunner, startConfig.PullSecret); err != nil {
return nil, errors.Wrap(err, "Failed to update VM pull secret")
}
if err := ensureKubeletAndCRIOAreConfiguredForProxy(sshRunner, proxyConfig, instanceIP); err != nil {
return nil, errors.Wrap(err, "Failed to update proxy configuration of kubelet and crio")
}
// Check the certs validity inside the vm
logging.Info("Verifying validity of the kubelet certificates ...")
certsExpired, err := cluster.CheckCertsValidity(sshRunner)
if err != nil {
return nil, errors.Wrap(err, "Failed to check certificate validity")
}
logging.Info("Starting OpenShift kubelet service")
sd := systemd.NewInstanceSystemdCommander(sshRunner)
if err := sd.Start("kubelet"); err != nil {
return nil, errors.Wrap(err, "Error starting kubelet")
}
ocConfig := oc.UseOCWithSSH(sshRunner)
if err := cluster.ApproveCSRAndWaitForCertsRenewal(sshRunner, ocConfig, certsExpired[cluster.KubeletClientCert], certsExpired[cluster.KubeletServerCert]); err != nil {
logBundleDate(crcBundleMetadata)
return nil, errors.Wrap(err, "Failed to renew TLS certificates: please check if a newer CodeReady Containers release is available")
}
if err := cluster.WaitForAPIServer(ocConfig); err != nil {
return nil, errors.Wrap(err, "Error waiting for apiserver")
}
if err := ensureProxyIsConfiguredInOpenShift(ocConfig, sshRunner, proxyConfig, instanceIP); err != nil {
return nil, errors.Wrap(err, "Failed to update cluster proxy configuration")
}
if err := cluster.EnsurePullSecretPresentInTheCluster(ocConfig, startConfig.PullSecret); err != nil {
return nil, errors.Wrap(err, "Failed to update cluster pull secret")
}
if err := cluster.EnsureClusterIDIsNotEmpty(ocConfig); err != nil {
return nil, errors.Wrap(err, "Failed to update cluster ID")
}
if client.monitoringEnabled() {
logging.Info("Enabling cluster monitoring operator...")
if err := cluster.StartMonitoring(ocConfig); err != nil {
return nil, errors.Wrap(err, "Cannot start monitoring stack")
}
}
// In Openshift 4.3, when cluster comes up, the following happens
// 1. After the openshift-apiserver pod is started, its log contains multiple occurrences of `certificate has expired or is not yet valid`
// 2. Initially there is no request-header's client-ca crt available to `extension-apiserver-authentication` configmap
// 3. In the pod logs `missing content for CA bundle "client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file"`
// 4. After ~1 min /etc/kubernetes/static-pod-resources/kube-apiserver-certs/configmaps/aggregator-client-ca/ca-bundle.crt is regenerated
// 5. It is now also appear to `extension-apiserver-authentication` configmap as part of request-header's client-ca content
// 6. Openshift-apiserver is able to load the CA which was regenerated
// 7. Now apiserver pod log contains multiple occurrences of `error x509: certificate signed by unknown authority`
// When the openshift-apiserver is in this state, the cluster is non functional.
// A restart of the openshift-apiserver pod is enough to clear that error and get a working cluster.
// This is a work-around while the root cause is being identified.
// More info: https://bugzilla.redhat.com/show_bug.cgi?id=1795163
if certsExpired[cluster.AggregatorClientCert] {
logging.Debug("Waiting for the renewal of the request header client ca...")
if err := cluster.WaitForRequestHeaderClientCaFile(sshRunner); err != nil {
return nil, errors.Wrap(err, "Failed to wait for aggregator client ca renewal")
}
if err := cluster.DeleteOpenshiftAPIServerPods(ocConfig); err != nil {
return nil, errors.Wrap(err, "Cannot delete OpenShift API Server pods")
}
}
logging.Info("Starting OpenShift cluster ... [waiting for the cluster to stabilize]")
if err := cluster.WaitForClusterStable(ocConfig, client.monitoringEnabled()); err != nil {
logging.Errorf("Cluster is not ready: %v", err)
}
waitForProxyPropagation(ocConfig, proxyConfig)
logging.Info("Adding crc-admin and crc-developer contexts to kubeconfig...")
if err := writeKubeconfig(instanceIP, clusterConfig); err != nil {
logging.Warnf("Cannot update kubeconfig: %v", err)
}
logging.Warn("The cluster might report a degraded or error state. This is expected since several operators have been disabled to lower the resource usage. For more information, please consult the documentation")
return &StartResult{
KubeletStarted: true,
ClusterConfig: *clusterConfig,
Status: vmState,
}, nil
}
func (client *client) IsRunning() (bool, error) {
libMachineAPIClient, cleanup := createLibMachineClient()
defer cleanup()
host, err := libMachineAPIClient.Load(client.name)
if err != nil {
return false, errors.Wrap(err, "Cannot load machine")
}
// get the actual state
vmState, err := host.Driver.GetState()
if err != nil {
// but reports not started on error
return false, errors.Wrap(err, "Error getting the state")
}
if vmState != state.Running {
return false, nil
}
return true, nil
}
func (client *client) validateStartConfig(startConfig StartConfig) error {
if client.monitoringEnabled() && startConfig.Memory < minimumMemoryForMonitoring {
return fmt.Errorf("Too little memory (%s) allocated to the virtual machine to start the monitoring stack, %s is the minimum",
units.BytesSize(float64(startConfig.Memory)*1024*1024),
units.BytesSize(minimumMemoryForMonitoring*1024*1024))
}
return nil
}
// makeDaemonVisibleToHyperkit crc daemon is launched in background and doesn't know where hyperkit is running.
// In order to vsock to work with hyperkit, we need to put the unix socket in the hyperkit working directory with a
// special name. The name is the hex representation of the cid and the vsock port.
// This function adds the unix socket in the hyperkit directory.
func makeDaemonVisibleToHyperkit(name string) error {
dst := filepath.Join(constants.MachineInstanceDir, name, "00000002.00000400")
if _, err := os.Stat(dst); err != nil {
if !os.IsNotExist(err) {
return errors.Wrap(err, "VSock listener error")
}
if err := os.Symlink(constants.TapSocketPath, dst); err != nil {
return errors.Wrap(err, "VSock listener error")
}
}
return nil
}
func createHost(api libmachine.API, machineConfig config.MachineConfig) (*host.Host, error) {
vm, err := newHost(api, machineConfig)
if err != nil {
return nil, fmt.Errorf("Error creating new host: %s", err)
}
if err := api.Create(vm); err != nil {
return nil, fmt.Errorf("Error creating the VM: %s", err)
}
return vm, nil
}
func addNameServerToInstance(sshRunner *crcssh.Runner, ns string) error {
nameserver := network.NameServer{IPAddress: ns}
nameservers := []network.NameServer{nameserver}
exist, err := network.HasGivenNameserversConfigured(sshRunner, nameserver)
if err != nil {
return err
}
if !exist {
logging.Infof("Adding %s as nameserver to the instance ...", nameserver.IPAddress)
return network.AddNameserversToInstance(sshRunner, nameservers)
}
return nil
}
func updateSSHKeyPair(sshRunner *crcssh.Runner) error {
if _, err := os.Stat(constants.GetPrivateKeyPath()); err != nil {
if !os.IsNotExist(err) {
return err
}
// Generate ssh key pair
logging.Info("Generating new SSH Key pair ...")
if err := ssh.GenerateSSHKey(constants.GetPrivateKeyPath()); err != nil {
return fmt.Errorf("Error generating ssh key pair: %v", err)
}
}
// Read generated public key
publicKey, err := ioutil.ReadFile(constants.GetPublicKeyPath())
if err != nil {
return err
}
authorizedKeys, _, err := sshRunner.Run("cat /home/core/.ssh/authorized_keys")
if err == nil && strings.TrimSpace(authorizedKeys) == strings.TrimSpace(string(publicKey)) {
return nil
}
logging.Info("Updating authorized keys ...")
cmd := fmt.Sprintf("echo '%s' > /home/core/.ssh/authorized_keys; chmod 644 /home/core/.ssh/authorized_keys", publicKey)
_, _, err = sshRunner.Run(cmd)
if err != nil {
return err
}
return err
}
func updateSSHKeyAndCopyKubeconfig(sshRunner *crcssh.Runner, name string, crcBundleMetadata *bundle.CrcBundleInfo) error {
if err := updateSSHKeyPair(sshRunner); err != nil {
return fmt.Errorf("Error updating SSH Keys: %v", err)
}
kubeConfigFilePath := filepath.Join(constants.MachineInstanceDir, name, "kubeconfig")
if _, err := os.Stat(kubeConfigFilePath); err == nil {
return nil
}
// Copy Kubeconfig file from bundle extract path to machine directory.
// In our case it would be ~/.crc/machines/crc/
logging.Info("Copying kubeconfig file to instance dir ...")
err := crcos.CopyFileContents(crcBundleMetadata.GetKubeConfigPath(),
kubeConfigFilePath,
0644)
if err != nil {
return fmt.Errorf("Error copying kubeconfig file to instance dir: %v", err)
}
return nil
}
func ensureKubeletAndCRIOAreConfiguredForProxy(sshRunner *crcssh.Runner, proxy *network.ProxyConfig, instanceIP string) (err error) {
if !proxy.IsEnabled() {
return nil
}
logging.Info("Adding proxy configuration to kubelet and crio service ...")
return cluster.AddProxyToKubeletAndCriO(sshRunner, proxy)
}
func ensureProxyIsConfiguredInOpenShift(ocConfig oc.Config, sshRunner *crcssh.Runner, proxy *network.ProxyConfig, instanceIP string) (err error) {
if !proxy.IsEnabled() {
return nil
}
logging.Info("Adding proxy configuration to the cluster ...")
return cluster.AddProxyConfigToCluster(sshRunner, ocConfig, proxy)
}
func waitForProxyPropagation(ocConfig oc.Config, proxyConfig *network.ProxyConfig) {
if !proxyConfig.IsEnabled() {
return
}
logging.Info("Waiting for the proxy configuration to be applied ...")
checkProxySettingsForOperator := func() error {
proxySet, err := cluster.CheckProxySettingsForOperator(ocConfig, proxyConfig, "marketplace-operator", "openshift-marketplace")
if err != nil {
logging.Debugf("Error getting proxy setting for openshift-marketplace operator %v", err)
return &crcerrors.RetriableError{Err: err}
}
if !proxySet {
logging.Debug("Proxy changes for cluster in progress")
return &crcerrors.RetriableError{Err: fmt.Errorf("")}
}
return nil
}
if err := crcerrors.RetryAfter(300*time.Second, checkProxySettingsForOperator, 2*time.Second); err != nil {
logging.Debug("Failed to propagate proxy settings to cluster")
}
}
func logBundleDate(crcBundleMetadata *bundle.CrcBundleInfo) {
if buildTime, err := crcBundleMetadata.GetBundleBuildTime(); err == nil {
bundleAgeDays := time.Since(buildTime).Hours() / 24
if bundleAgeDays >= 30 {
/* Initial bundle certificates are only valid for 30 days */
logging.Debugf("Bundle has been generated %d days ago", int(bundleAgeDays))
}
}
}