Skip to content

Conversation

@khanhtc1202
Copy link
Member

@khanhtc1202 khanhtc1202 commented Dec 18, 2020

What this PR does / why we need it:

The namespace in KubernetesDeploymentInput config currently is not a required field. In case of deleting resource on unset that namespace field, namespace default will be used ( as a default namespace of k8s ) leads to not found resources to delete bug.

Which issue(s) this PR fixes:

Fixes #1275

Does this PR introduce a user-facing change?:

Add rpc api and pipectl command to list applications

Comment on lines 250 to 256
// getNamespaceForRun returns namespace used on kubectl apply/delete commands
// priority: config.KubernetesDeploymentInput > kubernetes.ResourceKey
func (p *provider) getNamespaceForRun(k ResourceKey) string {
if p.input.Namespace != "" {
return p.input.Namespace
}
return k.Namespace
Copy link
Member Author

Choose a reason for hiding this comment

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

We could get the namespace from ResourceKey ( from manifest files ) or from KubernetesDeploymentInput ( which could be empty on unset currently ). IMO, namespace value from KubernetesDeploymentInput should have a higher priority than the value from ResourceKey, in case of mismatch, the current not found resources to delete error will be raised.
How do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I think the one in the user-defined manifest should be more prioritized than pipe.yaml when applying.

Copy link
Member

Choose a reason for hiding this comment

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

To be simple, the piped's role is basically just to perform kubectl apply -f manifest.yaml.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm... but on the second thought, the case that user clearly defines its namespace in the .pipe.yaml, I'm begging to feel it's better to override the base manifest.

Copy link
Member

Choose a reason for hiding this comment

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

One vote from me for taking the namespace value from the Input with higher priority.

Copy link
Member Author

@khanhtc1202 khanhtc1202 Dec 18, 2020

Choose a reason for hiding this comment

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

Hmm... but on the second thought, the case that user clearly defines its namespace in the .pipe.yaml, I'm begging to feel it's better to override the base manifest.

yep, I feel the same either. Since the manifest should be treated as a base, and config on .pipe.yaml lay on that base and those who defined the config should be aware of where should the deployment they set will be applied to.

@khanhtc1202
Copy link
Member Author

/cc @nakabonne

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.26%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/kubernetes/kubernetes.go provider.getNamespaceForRun -- 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.26%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/kubernetes/kubernetes.go provider.getNamespaceToRun -- 0.00% +0.00%

@nghialv
Copy link
Member

nghialv commented Dec 18, 2020

Nice catch!

return p.kubectl.Delete(ctx, p.getNamespaceToRun(k), k)
}

// getNamespaceToRun returns namespace used on kubectl apply/delete commands
Copy link
Member

Choose a reason for hiding this comment

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

nit nit: . at end of the line. (Just the convention of our team. )

Copy link
Member Author

Choose a reason for hiding this comment

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

🙆‍♀️

@nakabonne
Copy link
Member

Except for the stuff mentioned by nghialv, looks good. Great work 👍
/lgtm

@pipecd-bot pipecd-bot removed the lgtm label Dec 18, 2020
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.26%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/kubernetes/kubernetes.go provider.getNamespaceToRun -- 0.00% +0.00%

@nghialv
Copy link
Member

nghialv commented Dec 18, 2020

Great. Thank you.
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by nghialv.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot pipecd-bot merged commit 0dfa31e into master Dec 18, 2020
@pipecd-bot pipecd-bot deleted the fix-not-found-resource-bug branch December 18, 2020 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The canary resources are not deleted successfully when the namespace was specified in the manifests but not in pipe.yaml

5 participants