Enforce explicit read or write for bootstrap

This commit is contained in:
Erik Wilson 2019-07-12 16:18:53 -07:00
parent 403e73ab1c
commit e79fda96d2

View File

@ -77,7 +77,10 @@ func fetchBootstrapData(cfg *config.Control) error {
return err
}
if len(gr.Kvs) == 0 {
return nil
if cfg.BootstrapType != bootstrapTypeRead {
return nil
}
return errors.New("Unable to read bootstrap data from server")
}
runtimeJSON, err := base64.URLEncoding.DecodeString(string(gr.Kvs[0].Value))
@ -118,13 +121,16 @@ func storeBootstrapData(cfg *config.Control) error {
}
defer cli.Close()
gr, err := cli.Get(context.TODO(), k3sRuntimeEtcdPath)
if err != nil {
return err
}
if len(gr.Kvs) > 0 && string(gr.Kvs[0].Value) != "" {
return nil
if cfg.BootstrapType != bootstrapTypeWrite {
gr, err := cli.Get(context.TODO(), k3sRuntimeEtcdPath)
if err != nil {
return err
}
if len(gr.Kvs) > 0 && string(gr.Kvs[0].Value) != "" {
return nil
}
}
certData, err := readRuntimeBootstrapData(cfg.Runtime)
if err != nil {
return err