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

Fixes odo update from git to binary/local and vice versa #518

Merged
merged 1 commit into from
Jul 20, 2018

Conversation

mik-dass
Copy link
Contributor

@mik-dass mik-dass commented Jun 7, 2018

To achieve this, two functions have been added SetupForSupervisor and CleanupAfterSupervisor in occlient.go. Also some other functions are added in occlient to add and remove initContainers, volumeMounts and volumes to the deploymentConfig. Also updateDcAnnotations in occlient is added to update the annotations in the deploymentConfig.

Issue: #439
Signed-off-by: mdas mrinald7@gmail.com

var err error
projectName := client.GetCurrentProjectName()
from, _, ctype, err := GetComponentSource(client, componentName, applicationName, projectName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a function to return Component type - GetComponentType. You shouldn't modify GetComponentSource just to get this information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kadel Ok sorry forgot that there was a function for getting the component type

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URLs are deleted after the component is updated

@mik-dass
Copy link
Contributor Author

@kadel Ok What are the other components that need to be preserved before the deletion?

@kadel
Copy link
Member

kadel commented Jun 12, 2018

@kadel Ok What are the other components that need to be preserved before the deletion?

everything ;-)

@kadel
Copy link
Member

kadel commented Jun 12, 2018

Also after running an update from 'local' to 'binary' DeploymentConfig still has annotations as 'local' component.

@mik-dass
Copy link
Contributor Author

@kadel I mean storage, urls and? I might be forgetting more

@kadel
Copy link
Member

kadel commented Jun 12, 2018

@kadel I mean storage, urls and? I might be forgetting more

I think that is all. As rule you shouldn't touch anything expect DeploymentConfigs and BuildConfigs

@mik-dass mik-dass added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 13, 2018
@mik-dass mik-dass force-pushed the update_fix branch 2 times, most recently from 72626fa to 69e1d26 Compare June 20, 2018 14:19
@mik-dass mik-dass changed the title Trying updating the component by first deleting Fixes odo update from git to binary/local and vice versa Jun 20, 2018
@mik-dass
Copy link
Contributor Author

@kadel Done. I have updated the approach and now it does not delete the component before the update instead it updates the buildConfig, deploymentConfigs and triggers the build. Please have a look.

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it works, but to make sure we need to have a good test suite probably (e2e) that will test all possible update combinations.

This also needs unit tests.

// AddBootstrapInitContainer adds the bootstrap init container to the deployment config
// dc is the deployment config to be updated
// dcName is the name of the deployment config
func (c *Client) AddBootstrapInitContainer(dc *appsv1.DeploymentConfig, dcName string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function need Client receiver?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I guess, I will remove it. Also should I make it private?

// dc is the deployment config to be updated
// dcName is the name of the deployment config
func (c *Client) AddBootstrapInitContainer(dc *appsv1.DeploymentConfig, dcName string) {
appRootVolumeName := fmt.Sprintf("%s-s2idata", dcName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appRootVolumeName is constructed in the multiple places. Could we generate this name in one place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I will create a private function to fetch this

// AddBootstrapVolume adds the bootstrap volume to the deployment config
// dc is the deployment config to be updated
// dcName is the name of the deployment config
func (c *Client) AddBootstrapVolume(dc *appsv1.DeploymentConfig, dcName string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function need Client receiver?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I guess, I will remove it. Also should I make it private?

// AddBootstrapVolumeMount mounts the bootstrap volume to the deployment config
// dc is the deployment config to be updated
// dcName is the name of the deployment config
func (c *Client) AddBootstrapVolumeMount(dc *appsv1.DeploymentConfig, dcName string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function need Client receiver?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I guess, I will remove it. Also should I make it private?

// UpdateBuildConfig updates the BuildConfig file
// buildConfigName is the name of the BuildConfig file to be updated
// projectName is the name of the project
// gitUrl equals to the git URL of the source and is equals to "" if the source is of type dir or binary
// annotations contains the annotations for the BuildConfig file
func (c *Client) UpdateBuildConfig(buildConfigName string, projectName string, gitUrl string, annotations map[string]string) error {
const bootstrapperURI = "https://github.com/kadel/bootstrap-supervisored-s2i"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is duplicate, it is already defined in Boostrap function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I make it a global variable?

@@ -876,6 +910,81 @@ func (c *Client) UpdateBuildConfig(buildConfigName string, projectName string, g
return nil
}

// AddSupervisorToDC adds the supervisor to the deployment config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this is the correct name for this function. It doesn't add a supervisor to the deployment config. The supervisor is added to the image via BuildConfig, this just adds initContainer and volume that is needed for it work properly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kadel Can you suggest any name? I am confused

// builderImage is the name of the builderImage type
// projectName is the name of the project
// annotations are the updated annotations for the new deployment config
func (c *Client) RemoveSupervisorFromDC(dcName string, builderImage string, projectName string, annotations map[string]string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar concern as with AddSupervisorToDC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kadel Can you suggest any name? I am confused here too

@mik-dass mik-dass force-pushed the update_fix branch 7 times, most recently from 45fc5a8 to 880796d Compare June 26, 2018 07:37
@mik-dass mik-dass force-pushed the update_fix branch 3 times, most recently from d30eb22 to a26749c Compare June 26, 2018 12:10
"{{.name}}{{end}}{{end}}'")
Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName))

// checking for source-type in dc
Copy link
Member

@kadel kadel Jun 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could create function rather than copy/pasting those 4 check this to every test ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok good idea 👍

@mik-dass mik-dass force-pushed the update_fix branch 3 times, most recently from 5581d81 to 7e04722 Compare June 27, 2018 09:49
@mik-dass mik-dass force-pushed the update_fix branch 4 times, most recently from a644bd9 to 52d62b8 Compare July 12, 2018 16:33
@@ -79,6 +79,10 @@ test-e2e:
test-demo:
go test -v github.com/redhat-developer/odo/tests/e2e --ginkgo.focus="katacodaDemo" -ginkgo.v

.PHONY: test-update-e2e
test-update-e2e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that those tests are never run on travis :-(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, need to make a travis.yml entry for this. Something like this: https://github.com/redhat-developer/odo/blob/master/.travis.yml#L46

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kadel @ashetty1 Done, it's running separately as a separate job now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mik-dass Fantastic!

@cdrage
Copy link
Member

cdrage commented Jul 16, 2018

New changes LGTM!

@@ -330,7 +330,7 @@ func GetComponentSource(client *occlient.Client, componentName string, applicati
// Component name is the name component to be updated
// to indicates what type of source type the component source is changing to e.g from git to local or local to binary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguments for this function were changes, comment needs to reflect that

@@ -55,6 +55,9 @@ const (

// The length of the string to be generated for names of resources
nameLength = 5
// git repository that will be used for bootstraping
bootstrapperURI = "https://github.com/kadel/bootstrap-supervisored-s2i"
bootstrapperRef = "v0.0.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using v0.0.2 now, why is this downgraded?

annotations[componentSourceTypeAnnotation] = to
err = client.UpdateBuildConfig(namespacedOpenShiftObject, projectName, "", annotations)
}
log.Debugf("Updating component %s, to %s (%s).", componentName, newSource, newSourceType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be:
"Updating component from %s to %s"


// SetupForSupervisor adds the supervisor to the deployment config
// dcName is the name of the deployment config to be updated
// builderImage is the name of the builderImage type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no "builderImage" in this function


// CleanupAfterSupervisor removes the supervisor from the deployment config
// dcName is the name of the deployment config to be updated
// builderImage is the name of the builderImage type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no "builderImage" in this function

// builderImage is the name of the builderImage type
// projectName is the name of the project
// annotations are the updated annotations for the new deployment config
func (c *Client) SetupForSupervisor(dcName string, projectName string, annotations map[string]string, labels map[string]string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is labels argument?
It would be explained why it is used only in CreatePVC

@@ -103,6 +103,24 @@ func waitForCmdOut(cmd string, expOut string) bool {
}
}

func SourceTest(appTestName string, source string, sourceType string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs comment explaining what this function is for

@@ -422,3 +449,314 @@ var _ = Describe("odoe2e", func() {
})
})
})

var _ = Describe("updateE2e", func() {
appTestName := "testing"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be this and following variables constants?

@mik-dass mik-dass force-pushed the update_fix branch 3 times, most recently from 7cb69d8 to eccf6e0 Compare July 18, 2018 16:09
@mik-dass
Copy link
Contributor Author

@kadel I have made the changes, please have a look again

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last comments ;-)


var _ = Describe("updateE2e", func() {

bootStrapSupervisorURI := "https://github.com/kadel/bootstrap-supervisored-s2i"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this variables be constant?

})

It("should update component from binary to local", func() {
runCmd("git clone https://github.com/marekjelen/katacoda-odo-backend " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not using wildflyUri1?`

})

It("should update component from local to git", func() {
runCmd("odo update wildfly --git https://github.com/marekjelen/katacoda-odo-backend")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not using wildflyUri1?

})

It("should update component from binary to git", func() {
runCmd("odo update wildfly --git https://github.com/marekjelen/katacoda-odo-backend")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not using wildflyUri1?

})

It("should update component from local to local", func() {
runCmd("git clone https://github.com/mik-dass/katacoda-odo-backend " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not using wildflyUri2?

})

It("should update component from git to git", func() {
runCmd("odo update wildfly --git https://github.com/mik-dass/katacoda-odo-backend")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not using wildflyUri2?

@mik-dass
Copy link
Contributor Author

@kadel Done

To achieve this, two functions have been added SetupForSupervisor and CleanupAfterSupervisor in occlient.go. Also some other functions are added in occlient to add and remove initContainers, volumeMounts and volumes to the deploymentConfig. Also updateDcAnnotations in occlient is added to update the annotations in the deploymentConfig.

Signed-off-by: mdas <mrinald7@gmail.com>
@cdrage
Copy link
Member

cdrage commented Jul 19, 2018

@mik-dass Please update the commit description as well as the PR description before this is merged 👍

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Great work @mik-dass! 🎉

@cdrage Feel free to merge it once your concerns are addressed.

@cdrage
Copy link
Member

cdrage commented Jul 20, 2018

@kadel I have edited @mik-dass 's PR description with what he put in the commit description!

To achieve this, two functions have been added SetupForSupervisor and CleanupAfterSupervisor in occlient.go. Also some other functions are added in occlient to add and remove initContainers, volumeMounts and volumes to the deploymentConfig. Also updateDcAnnotations in occlient is added to update the annotations in the deploymentConfig.

Mergin' time

t.Errorf("created PVC spec not matching with expected values, expected: %s, got %s", createdPVC.Spec, tt.createdPVC.Spec)
}
} else if err == nil && tt.wantErr {
t.Errorf("test failed, expected: %s, got %s", "error", "no error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you're refereing for the part that it should be err and tt.wantErr for the "error" and "no error" parts?

} else if err == nil && tt.wantErr {
t.Errorf("test failed, expected: %s, got %s", "error", "no error")
} else if err != nil && !tt.wantErr {
t.Errorf("test failed, expected: %s, got %s", "no error", "error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞

@mik-dass
Copy link
Contributor Author

@kadel #605 will solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants