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
Add migration command #870
Add migration command #870
Conversation
This will be used to migrate from etcd to crd
cmd/migration/main.go
Outdated
| } | ||
| crdDao, err = crd.NewDao(options.MigrationNamespace) | ||
| if err != nil { | ||
| panic(fmt.Sprintf("Unable to connect to crd - %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: I don't think this connects to the crd resource. It only creates the client. Maybe a different error message should be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on more reviews before updating this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shawn-hurley might also be worth a precheck on the bundle resource. Maybe something like this:
_, err := resources.Bundle.Bundles(c.config.Namespace).List(metav1.ListOptions{})
if err != nil {
....
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the bundles already exist it will error and the migration will fail, I think it would be better to attempt to migrate IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code portion now. There are changes to the makefile and spec file needed.
Makefile
Outdated
| @@ -19,6 +19,7 @@ vendor: ## Install or update project dependencies | |||
|
|
|||
| broker: $(SOURCES) ## Build the broker | |||
| go build -i -ldflags="-s -w" ./cmd/broker | |||
| go build -i -ldflags="-s -w" ./cmd/migration | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't feel right. The broker Makefile target is the ACTUAL broker binary. This target says build the broker binary if any of the $(SOURCES) have changed.
I would expect the following:
migration: $(SOURCES) ## Build the migration tool
go build -i -ldflags="-s -w" ./cmd/migration| @@ -69,6 +70,7 @@ prep-local: ## Prepares the local dev environment | |||
|
|
|||
| build-image: ## Build a docker image with the broker binary | |||
| env GOOS=linux go build -i -ldflags="-s -s" -o ${BUILD_DIR}/broker ./cmd/broker | |||
| env GOOS=linux go build -i -ldflags="-s -s" -o ${BUILD_DIR}/migration ./cmd/migration | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆗
| @@ -178,6 +179,7 @@ rm -rf src | |||
| %install | |||
| install -d -p %{buildroot}%{_bindir} | |||
| install -p -m 755 broker %{buildroot}%{_bindir}/asbd | |||
| install -p -m 755 migration %{buildroot}%{_bindir}/migration | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need a line under the %files section for the migration
%{_bindir}/migration
``
Similar to `asbd`
https://github.com/shawn-hurley/ansible-service-broker/blob/11b100561dc09b374a2a76aef5e99a0364e77b8d/ansible-service-broker.spec#L283
| @@ -43,6 +43,7 @@ WORKDIR /go/src/github.com/openshift/ansible-service-broker | |||
|
|
|||
| RUN go build -i -ldflags="-s -w" ./cmd/broker | |||
| RUN mv broker /usr/bin/asbd | |||
| RUN mv migration /usr/bin/migration | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
| @@ -23,6 +23,7 @@ RUN mkdir /var/log/ansible-service-broker \ | |||
|
|
|||
| COPY entrypoint.sh /usr/bin/ | |||
| COPY broker /usr/bin/asbd | |||
| COPY migration /usr/bin/migration | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
|
|
||
| import ( | ||
| "encoding/json" | ||
| "flag" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stock flag is probably okay for this. But it is weird to have a different one than we are using for the broker:
"github.com/jessevdk/go-flags"Not a blocker just pointing it out.
|
The rest looks okay. |
|
Add migration to the clean target |
Describe what this PR does and why we need it:
We need a way to migrate from ETCD to CRD for openshift ansible
Changes proposed in this pull request
Trello: https://trello.com/c/KlFLeFI0
example job.yaml: