Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
956a21cd
Unverified
Commit
956a21cd
authored
Jan 07, 2019
by
Saugat Acharya
Committed by
GitHub
Jan 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Aesthetic changes
* Remove multiple spaces after full stop * Include a single space after a comment * Fixed a typo ```diff - eixst + exist ``` * Make comment and function name the same
parent
8b3b5a9f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
pv_controller.go
pkg/controller/volume/persistentvolume/pv_controller.go
+16
-16
No files found.
pkg/controller/volume/persistentvolume/pv_controller.go
View file @
956a21cd
...
...
@@ -59,25 +59,25 @@ import (
// This controller is intentionally written in a very verbose style. You will
// notice:
//
// 1.
Every 'if' statement has a matching 'else' (exception: simple error
//
checks for a client API call)
// 2.
Things that may seem obvious are commented explicitly
// 1. Every 'if' statement has a matching 'else' (exception: simple error
// checks for a client API call)
// 2. Things that may seem obvious are commented explicitly
//
// We call this style 'space shuttle style'.
Space shuttle style is meant to
// We call this style 'space shuttle style'. Space shuttle style is meant to
// ensure that every branch and condition is considered and accounted for -
// the same way code is written at NASA for applications like the space
// shuttle.
//
// Originally, the work of this controller was split amongst three
// controllers.
This controller is the result a large effort to simplify the
// PV subsystem.
During that effort, it became clear that we needed to ensure
// controllers. This controller is the result a large effort to simplify the
// PV subsystem. During that effort, it became clear that we needed to ensure
// that every single condition was handled and accounted for in the code, even
// if it resulted in no-op code branches.
//
// As a result, the controller code may seem overly verbose, commented, and
// 'branchy'.
However, a large amount of business knowledge and context is
// 'branchy'. However, a large amount of business knowledge and context is
// recorded here in order to ensure that future maintainers can correctly
// reason through the complexities of the binding behavior.
For that reason,
// reason through the complexities of the binding behavior. For that reason,
// changes to this file should preserve and add to the space shuttle style.
//
// ==================================================================
...
...
@@ -92,7 +92,7 @@ import (
// represented here as pvc.Spec.VolumeName and pv.Spec.ClaimRef. The bi-
// directionality is complicated to manage in a transactionless system, but
// without it we can't ensure sane behavior in the face of different forms of
// trouble.
For example, a rogue HA controller instance could end up racing
// trouble. For example, a rogue HA controller instance could end up racing
// and making multiple bindings that are indistinguishable, resulting in
// potential data loss.
//
...
...
@@ -247,7 +247,7 @@ func (ctrl *PersistentVolumeController) syncClaim(claim *v1.PersistentVolumeClai
}
}
//checkVolumeSatisfyClaim checks if the volume requested by the claim satisfies the requirements of the claim
//
checkVolumeSatisfyClaim checks if the volume requested by the claim satisfies the requirements of the claim
func
checkVolumeSatisfyClaim
(
volume
*
v1
.
PersistentVolume
,
claim
*
v1
.
PersistentVolumeClaim
)
error
{
requestedQty
:=
claim
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
requestedSize
:=
requestedQty
.
Value
()
...
...
@@ -392,10 +392,10 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(claim *v1.PersistentVol
klog
.
V
(
4
)
.
Infof
(
"synchronizing unbound PersistentVolumeClaim[%s]: volume is unbound, binding"
,
claimToClaimKey
(
claim
))
if
err
=
checkVolumeSatisfyClaim
(
volume
,
claim
);
err
!=
nil
{
klog
.
V
(
4
)
.
Infof
(
"Can't bind the claim to volume %q: %v"
,
volume
.
Name
,
err
)
//send an event
//
send an event
msg
:=
fmt
.
Sprintf
(
"Cannot bind to requested volume %q: %s"
,
volume
.
Name
,
err
)
ctrl
.
eventRecorder
.
Event
(
claim
,
v1
.
EventTypeWarning
,
events
.
VolumeMismatch
,
msg
)
//volume does not satisfy the requirements of the claim
//
volume does not satisfy the requirements of the claim
if
_
,
err
=
ctrl
.
updateClaimStatus
(
claim
,
v1
.
ClaimPending
,
nil
);
err
!=
nil
{
return
err
}
...
...
@@ -549,7 +549,7 @@ func (ctrl *PersistentVolumeController) syncVolume(volume *v1.PersistentVolume)
// 2) apiserver if not found in informer cache
// to make sure we will not reclaim a PV wrongly.
// Note that only non-released and non-failed volumes will be
// updated to Released state when PVC does not e
ix
st.
// updated to Released state when PVC does not e
xi
st.
if
volume
.
Status
.
Phase
!=
v1
.
VolumeReleased
&&
volume
.
Status
.
Phase
!=
v1
.
VolumeFailed
{
obj
,
err
=
ctrl
.
claimLister
.
PersistentVolumeClaims
(
volume
.
Spec
.
ClaimRef
.
Namespace
)
.
Get
(
volume
.
Spec
.
ClaimRef
.
Name
)
if
err
!=
nil
&&
!
apierrs
.
IsNotFound
(
err
)
{
...
...
@@ -1096,8 +1096,8 @@ func (ctrl *PersistentVolumeController) reclaimVolume(volume *v1.PersistentVolum
return
nil
}
//
doRerecycleVolumeOperationcycleVolume recycles a volume. This method is
//
running in
standalone goroutine and already has all necessary locks.
//
recycleVolumeOperation recycles a volume. This method is running in
// standalone goroutine and already has all necessary locks.
func
(
ctrl
*
PersistentVolumeController
)
recycleVolumeOperation
(
volume
*
v1
.
PersistentVolume
)
{
klog
.
V
(
4
)
.
Infof
(
"recycleVolumeOperation [%s] started"
,
volume
.
Name
)
...
...
@@ -1331,7 +1331,7 @@ func (ctrl *PersistentVolumeController) isVolumeUsed(pv *v1.PersistentVolume) ([
// doDeleteVolume finds appropriate delete plugin and deletes given volume, returning
// the volume plugin name. Also, it returns 'true', when the volume was deleted and
// 'false' when the volume cannot be deleted because
of
the deleter is external. No
// 'false' when the volume cannot be deleted because the deleter is external. No
// error should be reported in this case.
func
(
ctrl
*
PersistentVolumeController
)
doDeleteVolume
(
volume
*
v1
.
PersistentVolume
)
(
string
,
bool
,
error
)
{
klog
.
V
(
4
)
.
Infof
(
"doDeleteVolume [%s]"
,
volume
.
Name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment