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

feat: delete wait refreshing pr #8345

Closed

Conversation

pasha-codefresh
Copy link
Member

@pasha-codefresh pasha-codefresh commented Feb 2, 2022

I have reopened #2575 due to inactivity in original PR

Closes: #2555

Signed-off-by: pashavictorovich <pavel@codefresh.io>
Signed-off-by: pashavictorovich <pavel@codefresh.io>
@codecov
Copy link

codecov bot commented Feb 2, 2022

Codecov Report

Merging #8345 (412e30b) into master (51bab9c) will decrease coverage by 0.53%.
The diff coverage is 0.00%.

❗ Current head 412e30b differs from pull request most recent head d5b9b87. Consider uploading reports for the commit d5b9b87 to get more accurate results

@@            Coverage Diff             @@
##           master    #8345      +/-   ##
==========================================
- Coverage   42.80%   42.27%   -0.54%     
==========================================
  Files         186      176      -10     
  Lines       23306    22894     -412     
==========================================
- Hits         9976     9678     -298     
+ Misses      11902    11833      -69     
+ Partials     1428     1383      -45     
Impacted Files Coverage Δ
cmd/argocd/commands/app.go 0.52% <0.00%> (-0.01%) ⬇️
server/repository/repository.go 36.40% <0.00%> (-16.02%) ⬇️
controller/cache/cache.go 12.15% <0.00%> (-8.62%) ⬇️
cmd/util/app.go 47.10% <0.00%> (-3.31%) ⬇️
util/helm/cmd.go 28.48% <0.00%> (-1.17%) ⬇️
reposerver/repository/repository.go 58.53% <0.00%> (-0.70%) ⬇️
util/helm/helm.go 60.81% <0.00%> (-0.53%) ⬇️
server/application/application.go 31.27% <0.00%> (-0.50%) ⬇️
util/cache/cache.go 53.93% <0.00%> (-0.42%) ⬇️
util/settings/settings.go 47.53% <0.00%> (-0.38%) ⬇️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30415e0...d5b9b87. Read the comment docs.

Signed-off-by: pashavictorovich <pavel@codefresh.io>
Signed-off-by: pashavictorovich <pavel@codefresh.io>
@chetan-rns
Copy link
Member

@pasha-codefresh Could you please resolve the conflicts?

@pasha-codefresh
Copy link
Member Author

yes @chetan-rns , will try solve it today

…te-wait-v

Signed-off-by: pashavictorovich <pavel@codefresh.io>

# Conflicts:
#	cmd/argocd/commands/app.go
@pasha-codefresh
Copy link
Member Author

@chetan-rns merged, could you please review PR?

Signed-off-by: pashavictorovich <pavel@codefresh.io>
}
selectedResources := parseSelectedResources(resources)
if !watch.sync && !watch.health && !watch.operation && !watch.suspended && !watch.delete {
Copy link
Member

Choose a reason for hiding this comment

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

A minor nit:

Suggested change
if !watch.sync && !watch.health && !watch.operation && !watch.suspended && !watch.delete {
if (watch == watchOpts{}) {

client: acdClient,
appName: appName,
timeout: timeout,
watch: watchOpts{operation: true},
Copy link
Member

Choose a reason for hiding this comment

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

Since we are waiting for the application to sync is it necessary to enable sync in the watchOpts?

return nil, fmt.Errorf("application '%s' health state has transitioned from %s to %s", opts.appName, prevState.Health, newState.Health)
}
if opts.watch.delete && newState.Health == string(health.HealthStatusMissing) {
newState.Message = strings.Replace(newState.Message, "created", "deleted", 1)
Copy link
Member

Choose a reason for hiding this comment

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

Sometimes the wait command prints that the resource is deleted even though it is only being synced. In the below message, the deployment.apps/test is shown as deleted during sync

2022-03-03T14:18:38+05:30            Service            test                  test  OutOfSync  Missing              
2022-03-03T14:18:57+05:30         ServiceAccount        test                  test    Synced  Missing              
2022-03-03T14:18:57+05:30            Service        test                  test    Synced  Healthy              
2022-03-03T14:18:57+05:30         ServiceAccount        test                  test    Synced   Missing              serviceaccount/test created
2022-03-03T14:18:57+05:30            Service            test                  test    Synced   Healthy              service/test created
2022-03-03T14:18:57+05:30   apps  Deployment            test                  test  OutOfSync  Missing              deployment.apps/test deleted
2022-03-03T14:18:57+05:30   apps  Deployment        test                  test    Synced  Progressing              deployment.apps/test created
2022-03-03T14:19:08+05:30   apps  Deployment        test                  test    Synced  Healthy              deployment.apps/test created

Steps to reproduce:

  1. Create an app with manual sync
  2. argocd app wait test --delete
  3. Sync the application

if opts.watch.delete {
_, err := appClient.Get(context.Background(), &applicationpkg.ApplicationQuery{Name: &opts.appName})
if err != nil {
if strings.HasSuffix(err.Error(), "not found") {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if strings.HasSuffix(err.Error(), "not found") {
if apierr.IsNotFound(err) {

Maybe using IsNotFound(err) error type check from "k8s.io/apimachinery/pkg/api/errors" is a better option here?

@pasha-codefresh
Copy link
Member Author

@chetan-rns i have decided close this pr and reopen it with smaller parts ( it was just reopening of stale pr ). After your review I understand that it may include few bugs so I think splitting it and deliver with more tests and better code will be correct decision here

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.

Add a wait function on deletion
2 participants