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

replace --force --dry-run=server will ignore the dry-run flag #1222

Closed
alam0rt opened this issue Jun 1, 2022 · 2 comments · Fixed by kubernetes/kubernetes#110326
Closed
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@alam0rt
Copy link

alam0rt commented Jun 1, 2022

What happened:

Executed kubectl replace -f - --force --dry-run=server and object was indeed replaced

 % kubectl create cm foo --from-literal foo=bar --dry-run=client -o yaml > foo.yaml
 % kubectl apply -f foo.yaml
 % kubectl create cm foo --from-literal baz=foo --dry-run=client -o yaml > foo.yaml
 % kubectl replace -f foo.yaml --force --dry-run=server
 % kubectl get -f foo.yaml -o yaml
apiVersion: v1
data:
  baz: foo
kind: ConfigMap
metadata:
  creationTimestamp: "2022-06-01T02:49:56Z"
  name: foo
  namespace: sandbox
  resourceVersion: "585111136"
  uid: d8899f20-a087-4ace-a95a-7baa5277526e

What you expected to happen:

For the replace operation to have been a dry run.

How to reproduce it (as minimally and precisely as possible):

kubectl create cm foo --from-literal foo=bar --dry-run=client -o yaml > foo.yaml
kubectl apply -f foo.yaml
kubectl create cm foo --from-literal baz=foo --dry-run=client -o yaml > foo.yaml
kubectl replace -f foo.yaml --force --dry-run=server

Anything else we need to know?:
Don't think so!

Environment:

  • Kubernetes client and server versions (use kubectl version):
 % k version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"archive", BuildDate:"2021-09-16T04:22:31Z", GoVersion:"go1.17.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.9", GitCommit:"6df4433e288edc9c40c2e344eb336f63fad45cd2", GitTreeState:"clean", BuildDate:"2022-04-13T19:52:02Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration:
  • OS (e.g: cat /etc/os-release): darwin/OS X 12.3.1
@alam0rt alam0rt added the kind/bug Categorizes issue or PR as related to a bug. label Jun 1, 2022
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 1, 2022
@ardaguclu
Copy link
Member

Thanks for the issue @alam0rt. It looks that when force flag is set, dry-run is not be used as seen in here https://github.com/kubernetes/kubernetes/blob/e389b2723e6af29a9f70509fe8ff6e5121c30681/staging/src/k8s.io/kubectl/pkg/cmd/replace/replace.go#L275.

I think this is misleading and I opened a PR to return error message in such cases.

@ardaguclu
Copy link
Member

/triage accepted
/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants