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

#Fixes 3243 #3774

Merged
merged 3 commits into from
Mar 14, 2023
Merged

#Fixes 3243 #3774

merged 3 commits into from
Mar 14, 2023

Conversation

m4rc3l-h3
Copy link
Contributor

Summary

Updated remove_extra_resources function used in microk8s reset command to delete extra resources (e.g., services). As the command created in this function did not include the resources to delete and executing the command in subprocess.run would possibly fail silently, those resources were available even after the reset (see change below).
This in turn might lead and lead to unintended side-effects. For example, surviving resources caused the configuration issue described in #1823 in my local setup.

Closes #3243
References #1823

Changes

In line 235 I added the rs variable from the for loop to the creation of the cmd variable (similar to line 128).

Testing

  1. Build and installed microk8s locally following (https://github.com/canonical/microk8s/blob/master/docs/build.md)[https://github.com/canonical/microk8s/blob/master/docs/build.md].

  2. Created test service and configMap using the following files

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app.kubernetes.io/name: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376

and

apiVersion: v1
kind: ConfigMap
metadata:
  name: game-demo
data:
  # property-like keys; each key maps to a simple value
  player_initial_lives: "3"
  ui_properties_file_name: "user-interface.properties"

  # file-like keys
  game.properties: |
    enemy.types=aliens,monsters
    player.maximum-lives=5    
  user-interface.properties: |
    color.good=purple
    color.bad=yellow
    allow.textmode=true 
  1. Verified creation of serviceand configMap in default namespace using the following commands:
  • sudo microk8s kubectl get svc
  • sudo microk8s kubectl get configMaps
  1. Executed microk8s reset

  2. Verified that resources were deleted as expected using command from step 3.

Possible Regressions

As changes are local to only one function of the reset.py script, it is believed that no other functions are impacted

Checklist

  • Read the contributions page.
  • Submitted the CLA form, if you are a first time contributor.
  • The introduced changes are covered by unit and/or integration tests.

Notes

As far as I could see, the reset.py script was not covered by unit test, however, the changes and the expected behavior was successfully tested manually as described above.

Copy link
Member

@berkayoz berkayoz left a comment

Choose a reason for hiding this comment

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

Hey @m4rc3l-h3 ,
Thank you for your contribution. Everything looks good to me.
Manually tested on my local machine, everything seems to work alright.
I'll go ahead and merge your changes.

@berkayoz berkayoz merged commit e696740 into canonical:master Mar 14, 2023
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.

microk8s.reset does not remove resources
3 participants