-
Notifications
You must be signed in to change notification settings - Fork 38
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
[KO-290] Allow enabling security in the existing deployed cluster #273
Changes from 7 commits
908a9b8
ec4b349
e259de7
19aa4ad
fba1862
e9a798d
f26f3f0
e04f709
572f8bf
01c36b2
1821f74
13756a1
96cc9e7
6cb8357
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,41 +37,39 @@ func AerospikeAdminCredentials( | |
desiredState, currentState *asdbv1.AerospikeClusterSpec, | ||
passwordProvider AerospikeUserPasswordProvider, | ||
) (user, pass string, err error) { | ||
var enabled bool | ||
var ( | ||
enabled bool | ||
currentSecurityEnabled bool | ||
desiredSecurityEnabled bool | ||
currentSecurityErr error | ||
desiredSecurityErr error | ||
) | ||
|
||
outgoingVersion, err := asdbv1.GetImageVersion(currentState.Image) | ||
if err != nil { | ||
incomingVersion, newErr := asdbv1.GetImageVersion(desiredState.Image) | ||
if newErr != nil { | ||
return "", "", newErr | ||
} | ||
outgoingVersion, outgoingVersionErr := asdbv1.GetImageVersion(currentState.Image) | ||
if outgoingVersionErr == nil { | ||
// It is possible that this is a new cluster and current state is empty. | ||
currentSecurityEnabled, currentSecurityErr = asdbv1.IsSecurityEnabled( | ||
outgoingVersion, currentState.AerospikeConfig, | ||
) | ||
} else { | ||
currentSecurityErr = outgoingVersionErr | ||
} | ||
|
||
enabled, newErr = asdbv1.IsSecurityEnabled( | ||
incomingVersion, incomingVersionErr := asdbv1.GetImageVersion(desiredState.Image) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we check for the enable security from spec by default? If it is not enabled then look into the status. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea here was to send Aerospike credentials if security is enabled in either the spec or status. Following that, we check for |
||
if incomingVersionErr == nil { | ||
desiredSecurityEnabled, desiredSecurityErr = asdbv1.IsSecurityEnabled( | ||
incomingVersion, desiredState.AerospikeConfig, | ||
) | ||
if newErr != nil { | ||
return "", "", newErr | ||
} | ||
} else { | ||
enabled, err = asdbv1.IsSecurityEnabled( | ||
outgoingVersion, currentState.AerospikeConfig, | ||
) | ||
if err != nil { | ||
incomingVersion, newErr := asdbv1.GetImageVersion(desiredState.Image) | ||
if newErr != nil { | ||
return "", "", newErr | ||
} | ||
desiredSecurityErr = incomingVersionErr | ||
} | ||
|
||
// Its possible this is a new cluster and current state is empty. | ||
enabled, newErr = asdbv1.IsSecurityEnabled( | ||
incomingVersion, desiredState.AerospikeConfig, | ||
) | ||
if newErr != nil { | ||
return "", "", newErr | ||
} | ||
} | ||
if currentSecurityErr != nil && desiredSecurityErr != nil { | ||
return "", "", desiredSecurityErr | ||
} | ||
|
||
enabled = currentSecurityEnabled || desiredSecurityEnabled | ||
|
||
if !enabled { | ||
// Return zero strings if this is not a security enabled cluster. | ||
return "", "", nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better name would be IsSecurityEnabled