Skip to content

Commit

Permalink
Addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
divolgin committed Aug 7, 2020
1 parent 0ec058b commit f2b3927
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kotsadm/pkg/k8s/cluster.go
Expand Up @@ -57,7 +57,7 @@ func UploadCertsWithNewKey() (string, error) {

key, err := copycerts.CreateCertificateKey()
if err != nil {
return "", errors.Wrap(err, "failed to genertae key")
return "", errors.Wrap(err, "failed to generate key")
}
config.CertificateKey = key

Expand Down
8 changes: 7 additions & 1 deletion kotsadm/pkg/kurl/configmap.go
Expand Up @@ -2,6 +2,7 @@ package kurl

import (
"context"
"os"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -69,10 +70,15 @@ func UpdateConfigMap(client kubernetes.Interface, generateBootstrapToken, upload
if uploadCerts {
certsDuration := time.Hour * 2
certsExpiration := time.Now().Add(certsDuration)
key, err := createCertAndKey(context.TODO(), client, "default")

ctx, cancel := context.WithTimeout(context.TODO(), 60*time.Second)
defer cancel()

key, err := createCertAndKey(ctx, client, os.Getenv("POD_NAMESPACE"))
if err != nil {
return nil, errors.Wrap(err, "upload certs with new key")
}

cm.Data[certKey] = key
cm.Data[certsExpirationKey] = certsExpiration.Format(time.RFC3339)
}
Expand Down
16 changes: 13 additions & 3 deletions kotsadm/pkg/kurl/join_cert.go
Expand Up @@ -46,7 +46,13 @@ func createCertAndKey(ctx context.Context, client kubernetes.Interface, namespac
status.Status.Phase == corev1.PodSucceeded {
break
}

time.Sleep(time.Second * 1)

// TODO: Do we need this? Shouldn't Get function fail if there's a ctx error?
if err := ctx.Err(); err != nil {
return "", errors.Wrap(err, "failed to wait for pod to terminate")
}
}

podLogs, err := getCertGenLogs(ctx, client, pod)
Expand All @@ -63,12 +69,9 @@ func createCertAndKey(ctx context.Context, client kubernetes.Interface, namespac
}

func getCertGenLogs(ctx context.Context, client kubernetes.Interface, pod *corev1.Pod) ([]byte, error) {
// maxLines := int64(10000)
podLogOpts := corev1.PodLogOptions{
Follow: false,
Container: pod.Spec.Containers[0].Name,
// TailLines:
// SinceTime:
}

req := client.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &podLogOpts)
Expand Down Expand Up @@ -151,6 +154,13 @@ func getPodSpec(clientset kubernetes.Interface, namespace string) (*corev1.Pod,
NodeSelector: map[string]string{
"node-role.kubernetes.io/master": "",
},
Tolerations: []corev1.Toleration{
{
Key: "node-role.kubernetes.io/master",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
},
RestartPolicy: corev1.RestartPolicyNever,
ImagePullSecrets: existingDeployment.Spec.Template.Spec.ImagePullSecrets,
Volumes: []corev1.Volume{
Expand Down

0 comments on commit f2b3927

Please sign in to comment.