Skip to content

Conversation

tpereirasplunk
Copy link
Contributor

@tpereirasplunk tpereirasplunk commented Feb 26, 2021

Needs https://github.com/splunk/splunk-operator/pull/262/files to be merged to work.

Tested locally:

[1] {"level":"info","ts":1614362873.529494,"msg":"Checking status of Monitoring Console Pod"}
[1] {"level":"info","ts":1614362873.7195148,"msg":"MC statefulset found","POD":"splunk-smoke-ob-monitoring-console","READY":"1/1"}
[1] {"level":"info","ts":1614362873.939373,"msg":"MC Pod Found","POD":"splunk-smoke-ob-monitoring-console-0","READY":"1/1"}
[1] {"level":"info","ts":1614362874.1707141,"msg":"NAME READY STATUS RESTARTS AGE"}
[1] {"level":"info","ts":1614362874.170743,"msg":"splunk-op-smoke-ob-5b6c9f9d44-fhxm8 1/1 Running 0 5m"}
[1] {"level":"info","ts":1614362874.1707468,"msg":"splunk-smoke-ob-fmp-license-master-0 1/1 Running 0 4m53s"}
[1] {"level":"info","ts":1614362874.17075,"msg":"splunk-smoke-ob-fmp-standalone-0 1/1 Running 0 4m52s"}
[1] {"level":"info","ts":1614362874.170753,"msg":"splunk-smoke-ob-monitoring-console-0 1/1 Running 0 96s"}
[1] {"level":"info","ts":1614362874.170756,"msg":""}
[1] '{"hec_token":"MEIyNjIwQTEtNzc1QS0yMDc3LTY0NUItQkY0OTA3NjM3QkZF","idxc_secret":"WENsU3FSTVcxdzhQRzFmSmtwWkhXelEy","pass4SymmKey":"dmY3MDk2ZlRXZWVtQ2hDY1NOaTZQeWI1","password":"cFpvRzVUeVp4Y0pSck1YUXhRd3VWUm1k","shc_secret":"Sk1ZS1VITTdVQklLWVZQUGVLaW1nVzd2"}'
[1] rest_response
[1] {MEIyNjIwQTEtNzc1QS0yMDc3LTY0NUItQkY0OTA3NjM3QkZF WENsU3FSTVcxdzhQRzFmSmtwWkhXelEy dmY3MDk2ZlRXZWVtQ2hDY1NOaTZQeWI1 cFpvRzVUeVp4Y0pSck1YUXhRd3VWUm1k Sk1ZS1VITTdVQklLWVZQUGVLaW1nVzd2}
[1] '{"hec_token":"ZEdWemRGOTJZV3gxWlE9PQ==","idxc_secret":"WENsU3FSTVcxdzhQRzFmSmtwWkhXelEy","pass4SymmKey":"dmY3MDk2ZlRXZWVtQ2hDY1NOaTZQeWI1","password":"cFpvRzVUeVp4Y0pSck1YUXhRd3VWUm1k","shc_secret":"Sk1ZS1VITTdVQklLWVZQUGVLaW1nVzd2"}'
[1] rest_response
[1] {ZEdWemRGOTJZV3gxWlE9PQ== WENsU3FSTVcxdzhQRzFmSmtwWkhXelEy dmY3MDk2ZlRXZWVtQ2hDY1NOaTZQeWI1 cFpvRzVUeVp4Y0pSck1YUXhRd3VWUm1k Sk1ZS1VITTdVQklLWVZQUGVLaW1nVzd2}

MonitoringConsolePod = "splunk-%s-monitoring-console-%d"

// SecretObject Secret object Template
SecretObject = "splunk-%s-secret"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Change to SecretObjectName ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use the secretObjectName in the function itself after i fill in the 'namespace'. Think it would be ok to keep as it is

return false
}
return true

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: extra line unnecessary here?

secretName := fmt.Sprintf(SecretObject, ns)
secret := newSecretSpec(ns, secretName, data)
//Update object using spec
err := deployment.updateCR(secret)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does updateCR take care of a case where secret object is not present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. If the object is not present. It creates the object with the details specified

Copy link
Collaborator

Choose a reason for hiding this comment

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

And if it does exist, does it update? If yes we are good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. This fcn is mainly to update it. But does take care of the scenario when object is not present


//Convert object to map for update
var data map[string][]byte
err = json.Unmarshal([]byte(out), &data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious, how does the unmarshal convert the variable out to a map? And what data type is out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Out is a Json object. Unmarshal will convert it to a map. Tested it out when running the local changes

Copy link
Collaborator

@akondur akondur Mar 2, 2021

Choose a reason for hiding this comment

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

Does the input to unmarshal need to be of a certain type for it to convert it to a map? i.e []byte? How does it determine the key and value pairs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the object is initially built into a json out of the exec.command() function using the struct defined at the top. Here we take care of any extra fields that might have come accidentally. Post that its simple to convert from json to map and then to update

@tpereirasplunk tpereirasplunk deleted the CSPL-542 branch March 19, 2021 23:16
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.

4 participants