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

provider/kubernetes: Add support for resource_quota #13914

Merged
merged 1 commit into from
May 8, 2017

Conversation

radeksimko
Copy link
Member

Test plan

make testacc TEST=./builtin/providers/kubernetes TESTARGS='-run=TestAccKubernetesResourceQuota_'
=== RUN   TestAccKubernetesResourceQuota_basic
--- PASS: TestAccKubernetesResourceQuota_basic (9.02s)
=== RUN   TestAccKubernetesResourceQuota_generatedName
--- PASS: TestAccKubernetesResourceQuota_generatedName (8.44s)
=== RUN   TestAccKubernetesResourceQuota_withScopes
--- PASS: TestAccKubernetesResourceQuota_withScopes (9.43s)
=== RUN   TestAccKubernetesResourceQuota_importBasic
--- PASS: TestAccKubernetesResourceQuota_importBasic (4.34s)

Related upstream bug: kubernetes/kubernetes#44539

Copy link
Contributor

@stack72 stack72 left a comment

Choose a reason for hiding this comment

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

@radeksimko looking good - have a few questions inline but nothing alarming

func resourceKubernetesResourceQuotaCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*kubernetes.Clientset)

metadata := expandMetadata(d.Get("metadata").([]interface{}))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does expandMetadata not return error status whereas expandResourceQuoteSpec does? Is there no change metadata could not return an error?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's merely because expandResourceQuoteSpec has to parse "resource list" and that may error out, expandMetadata doesn't have to parse anything like that.
https://github.com/hashicorp/terraform/pull/13914/files#diff-886d9a6a55a7569117aaf167990fed25R223

log.Printf("[INFO] Submitted new resource quota: %#v", out)
d.SetId(buildId(out.ObjectMeta))

err = resource.Retry(1*time.Minute, func() *resource.RetryError {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is 1 minute enough here?

Copy link
Member Author

@radeksimko radeksimko Apr 27, 2017

Choose a reason for hiding this comment

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

It is plenty of time based on my testing - it is usually ready within a few seconds.

log.Printf("[INFO] Reading resource quota %s", name)
resQuota, err := conn.CoreV1().ResourceQuotas(namespace).Get(name)
if err != nil {
log.Printf("[DEBUG] Received error: %#v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be manually deleted? If so, can we catch it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's why there's resourceKubernetesResourceQuotaExists 😉

}

func resourceKubernetesResourceQuotaUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*kubernetes.Clientset)
Copy link
Contributor

Choose a reason for hiding this comment

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

Even if it's only spec that changes here, we are going to update the metadata - correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

ops := patchMetadata("metadata.0.", "/metadata/", d) should return empty slice of PatchOperations if it has no changes and if we have reached the Update() function it's clear that we have something to update - either spec or metadata, so it is there just to initialize the slice, really.

I could change it to something like

ops := make([]PatchOperations, 0, 0)
if d.HasChange("metadata") {
    ops = append(ops, patchMetadata("metadata.0.", "/metadata/", d)
}

if you think it's better?

@stack72
Copy link
Contributor

stack72 commented May 8, 2017

Your answers sound good :) LGTM!

@radeksimko radeksimko merged commit 296a3b2 into master May 8, 2017
@radeksimko radeksimko deleted the f-k8s-resource-quota branch May 8, 2017 11:43
@ghost
Copy link

ghost commented Apr 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants