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

Add PVC Provisioning Job #916

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AleTopp
Copy link

@AleTopp AleTopp commented Dec 3, 2024

Description

Added Job that changes the owner of the MyDrive from root (default) to user 1010 (CrownLabsUserID), so that it is writable by tenants inside Instances deployed as containers (that run as user CrownLabsUserID). If the Job completes, it adds a label to the PVC pvc-provisioning: completed to flag it.

Fixes issue: NFS MyDrive cannot be written from containers since owner is root

~ Alessio Giliberti, Chiara Mercurio

@AleTopp AleTopp requested a review from a team as a code owner December 3, 2024 16:24
@kingmakerbot
Copy link
Collaborator

Hi @AleTopp. Thanks for your PR.

I am @kingmakerbot.
You can interact with me issuing a slash command in the first line of a comment.
Currently, I understand the following commands:

  • /rebase: Rebase this PR onto the master branch
  • /merge: Merge this PR into the master branch
  • /hold: Adds hold label to prevent merging with /merge
  • /unhold: Removes the hold label to allow merging with /merge
  • /deploy-staging: Deploy a staging environment to test this PR (the build-all flag enables user environments building)
  • /undeploy-staging: Manually undeploy the staging environment

Make sure this PR appears in the CrownLabs changelog, adding one of the following labels:

  • kind/breaking: 💥 Breaking Change
  • kind/feature: 🚀 New Feature
  • kind/bug: 🐛 Bug Fix
  • kind/cleanup: 🧹 Code Refactoring
  • kind/docs: 📝 Documentation

@QcFe
Copy link
Collaborator

QcFe commented Dec 16, 2024

Managed to have a look. Overall logic now seems fine. Minor changes:

  • switch from CreateOrUpdate to r.Update for pvc labels, since for sure you already have the pvc there.
  • change 'pvc-provisioning' to 'mydrive-provisioning'. Also I'd likely add a new 'pending' value that can be used to retrieve all tenants that for any reason are stuck on provisioning.
  • as you can see here there are issues with linting. you can go to your go settings in vscode and select golangci-lint as the linter, to get in sync with the linter we're using in the pipeline
  • we'll still deploy now and, if it works, we can still already test the logic

@QcFe
Copy link
Collaborator

QcFe commented Dec 16, 2024

/deploy-staging

@kingmakerbot
Copy link
Collaborator

Your staging environment has been correctly deployed/updated!
Available here: Frontend, Qlkube
Operators: add the crownlabs.polito.it/operator-selector=staging-916 label to your tenant.

Copy link
Collaborator

@QcFe QcFe left a comment

Choose a reason for hiding this comment

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

almost there :)

Comment on lines +60 to +61
// ProvisionJobLabel -> Key of the label added by the Provision Job to flag the PVC.
ProvisionJobLabel = "mydrive-provisioning"
Copy link
Collaborator

Choose a reason for hiding this comment

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

please move labels where others are

@@ -517,6 +532,32 @@ func (r *TenantReconciler) createOrUpdateTnPersonalNFSVolume(ctx context.Context
return err
}
klog.Infof("PVC Secret for tenant %s %s", tn.Name, pvcSecOpRes)

val, ok := pvc.Labels[ProvisionJobLabel]
if !ok || val != ProvisionJobValueOk {
Copy link
Collaborator

Choose a reason for hiding this comment

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

split the logic based on check. if no labels create, if label is not ok, check if it's done, etc


klog.Infof("PVC Provisioning Job completed for tenant %s", tn.Name)
} else if chownJob.Status.Failed == 1 {
klog.Errorf("PVC Provisioning Job failed for tenant %s", tn.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably better to move into a warning (if exists)

Suggested change
klog.Errorf("PVC Provisioning Job failed for tenant %s", tn.Name)
klog.Warningf("PVC Provisioning Job failed for tenant %s", tn.Name)

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.

3 participants