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

Include additional parts of deploy manifest step #4

Merged
merged 9 commits into from
Jun 26, 2020
Merged

Include additional parts of deploy manifest step #4

merged 9 commits into from
Jun 26, 2020

Conversation

groeges
Copy link

@groeges groeges commented Jun 25, 2020

What type of PR is this?
/kind feature

What does does this PR do / why we need it:

Which issue(s) this PR fixes:

Fixes #?

How to test changes / Special notes to the reviewer:

groeges added 8 commits June 25, 2020 16:05
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
@groeges groeges marked this pull request as ready for review June 25, 2020 16:00
Copy link
Owner

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Just a few comments

conditions := status["conditions"].([]interface{})
for i := range conditions {
c := conditions[i].(map[string]interface{})
klog.V(4).Infof("Condition returned\n%s\n", c)
Copy link
Owner

Choose a reason for hiding this comment

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

should you put this log inside the if?

Copy link
Author

Choose a reason for hiding this comment

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

I wanted to be able to see what all the conditions we had were, so had it outside. Will probably remove later.

Comment on lines +341 to +345
deployJSON, err := deploymentManifest.MarshalJSON()
if err != nil {
return errors.Wrap(err, "Deployment manifest is invalid")
}
klog.V(3).Infof("Deploy manifest:\n\n%s\n", deployJSON)
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need it in JSON? It is just to print it out?

Copy link
Author

Choose a reason for hiding this comment

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

I was just using that to test that the manifest was valid, and then thought I could print it out.

Comment on lines 427 to 429
// Need to wait for a second to give the server time to create the artifacts
time.Sleep(2 * time.Second)

Copy link
Owner

Choose a reason for hiding this comment

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

Just needs a TODO to replace with wait

Copy link
Author

Choose a reason for hiding this comment

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

Have added a TODO


// Check to see whether deployed resource already exists. If not, create else update
instanceFound := false
list, err := a.Client.DynamicClient.Resource(gvr).Namespace(namespace).List(metav1.ListOptions{})
Copy link
Owner

Choose a reason for hiding this comment

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

could we do a Get() instead of List()?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, probably. Will do that in a new PR though!

Copy link
Author

Choose a reason for hiding this comment

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

Have made change to use Get rather than List.

deploymentManifest.SetUnstructuredContent(newService)
}
}
instanceFound = true
Copy link
Owner

Choose a reason for hiding this comment

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

should we break from the for here?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, but if we do a Get rather than a List it wont be an issue and this code will get refactored. Will fix in new PR.

Copy link
Author

Choose a reason for hiding this comment

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

Use of Get had made doing a break unecessary.

log.Infof("Updating %s...", gvk.Kind)
result, err = myclient.Resource(gvr).Namespace(namespace).Update(deploymentManifest, metav1.UpdateOptions{})
}
_ = manifestFile.Close()
Copy link
Owner

Choose a reason for hiding this comment

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

we would want to return this error. I would rather write a defer where we create the files as such:

defer func() {
      merr := manifestFile.Close()
      if err == nil {
            err = merr
      }
}()

Copy link
Author

Choose a reason for hiding this comment

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

Agree

Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
@groeges
Copy link
Author

groeges commented Jun 25, 2020

@EnriqueL8 Have made a few changes as requested and pushed again to the branch. Hopefully this will be OK to merge.

@@ -62,7 +62,7 @@ func (po *PushOptions) DevfilePush() (err error) {
platformContext = nil
} else {
kc := kubernetes.KubernetesContext{
Namespace: po.namespace,
Namespace: po.KClient.Namespace,
Copy link
Owner

Choose a reason for hiding this comment

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

Do we need this?

@EnriqueL8 EnriqueL8 merged commit 7129292 into EnriqueL8:deploy_command Jun 26, 2020
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.

2 participants