Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1748452: data/bootstrap: Replace openshift.sh with cluster-bootstrap #1381

Merged
merged 2 commits into from
Oct 1, 2019

Commits on Sep 17, 2019

  1. data/bootstrap: Replace openshift.sh with cluster-bootstrap

    With this commit, I take advantage of
    openshift/cluster-bootstrap@fc5e0941 (start: wire the library-go
    dynamic client create, 2019-02-05, openshift/cluster-bootstrap#14) to
    replace our previous openshift.sh (with a minor change to the manifest
    directory).  I'm currently using a cp in bootkube.sh to shift those
    manifests into the generic directory; I plan on consolidating
    Openshift into Manifests in pkg/asset/manifests in follow-up work.
    
    This change is especially important since the pivot to loopback
    kubeconfigs in openshift.sh: 82d81d9 (data/data/bootstrap: use
    loopback kubeconfig for API access, 2019-07-24, openshift#2086), because once
    cluster-bootstrap (launched from bootkube.sh) decides it's done it
    tears down the bootstrap control plane.  Without the bootstrap control
    plane, further attempts by openshift.sh to push manifests via the
    loopback kubeconfig fail [1].
    
    We could roll reporting into bootkube.sh as well (dropping
    progress.service), but Abhinav wanted to keep it separate [2].
    
    [1]: https://bugzilla.redhat.com/show_bug.cgi?id=1748452
    [2]: openshift#1381 (comment)
    wking committed Sep 17, 2019
    Configuration menu
    Copy the full SHA
    108a45b View commit details
    Browse the repository at this point in the history
  2. pkg/asset/machines/userdata: Convert from List to single Secret

    This may have been what was giving us errors like:
    
      Sep 10 19:41:16 ip-10-0-3-146 bootkube.sh[1605]: "99_openshift-cluster-api_master-user-data-secret.yaml": unable to convert asset "99_openshift-cluster-api_master-user-data-secret.yaml" to unstructed
      Sep 10 19:41:16 ip-10-0-3-146 bootkube.sh[1605]: "99_openshift-cluster-api_worker-user-data-secret.yaml": unable to convert asset "99_openshift-cluster-api_worker-user-data-secret.yaml" to unstructed
    
    after failing this cast to *unstructured.Unstructured [2].  I don't
    have a theory for why the unstructured cast fails for Lists, but
    that's what I see in local testing:
    
      $ cat test.go
      package main
    
      import (
        "io/ioutil"
        "log"
        "os"
    
        "github.com/ghodss/yaml"
        "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
        "k8s.io/apimachinery/pkg/runtime"
      )
    
      func main() {
        file, err := os.Open("test.yaml")
        if err != nil {
          log.Fatal(err)
        }
    
        manifestBytes, err := ioutil.ReadAll(file)
        if err != nil {
          log.Fatal(err)
        }
    
        manifestJSON, err := yaml.YAMLToJSON(manifestBytes)
        if err != nil {
          log.Fatal(err)
        }
    
        manifestObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, manifestJSON)
        if err != nil {
          log.Fatal(err)
        }
        log.Print(manifestObj)
        log.Print("")
    
        manifestUnstructured, ok := manifestObj.(*unstructured.Unstructured)
        if !ok {
          log.Fatal(manifestUnstructured)
        }
    
        log.Print(manifestUnstructured)
      }
      $ cat <<EOF >test.yaml
      > apiVersion: v1
      > kind: Secret
      > metadata:
      >   name: master-user-data
      >   namespace: openshift-machine-api
      > type: Opaque
      > data:
      >   disableTemplating: dHJ1ZQo=
      >   userData: dHJ1ZQo=
      > EOF
      $ go run test.go
      2019/09/12 10:32:07 &{map[kind:Secret metadata:map[name:master-user-data namespace:openshift-machine-api] type:Opaque apiVersion:v1 data:map[userData:dHJ1ZQo= disableTemplating:dHJ1ZQo=]]}
      2019/09/12 10:32:07
      2019/09/12 10:32:07 &{map[apiVersion:v1 data:map[disableTemplating:dHJ1ZQo= userData:dHJ1ZQo=] kind:Secret metadata:map[name:master-user-data namespace:openshift-machine-api] type:Opaque]}
      $ cat <<EOF >test.yaml
      > kind: List
      > apiVersion: v1
      > metadata:
      >   resourceVersion: ""
      >   selfLink: ""
      > items:
      > - apiVersion: v1
      >   kind: Secret
      >   metadata:
      >     name: master-user-data
      >     namespace: openshift-machine-api
      >   type: Opaque
      >   data:
      >     disableTemplating: dHJ1ZQo=
      >     userData: dHJ1ZQo=
      > EOF
      $ go run test.go
      2019/09/12 10:33:20 &{map[kind:List metadata:map[resourceVersion: selfLink:] apiVersion:v1] [{map[metadata:map[name:master-user-data namespace:openshift-machine-api] type:Opaque apiVersion:v1 data:map[disableTemplating:dHJ1ZQo= userData:dHJ1ZQo=] kind:Secret]}]}
      2019/09/12 10:33:20
      2019/09/12 10:33:20 <nil>
      exit status 1
    
    [1]: openshift#1381 (comment)
    [2]: https://github.com/openshift/library-go/blob/7d4acc018c610623ee1413b1e7aebe2ac675d35f/pkg/assets/create/creater.go#L264
    wking committed Sep 17, 2019
    Configuration menu
    Copy the full SHA
    b982886 View commit details
    Browse the repository at this point in the history