zowe / zowe-install-packaging

Packaging repository for the Zowe install scripts and files
Eclipse Public License 2.0
27 stars 52 forks source link

zwe init --update-config does not work if the file is already open #3887

Closed Rahul-Kejriwal closed 2 months ago

Rahul-Kejriwal commented 3 months ago

Describe the bug --update-config param in zwe init does not update zowe.yaml file if zowe.yaml already open but the messages in the log still says that it was updated successfully

To Reproduce Steps to reproduce the behavior:

  1. open the zowe.yaml in editor
  2. Execute the zwe init command with --update-config
  3. The log messages say the yaml file was updated in the zowe.certicate section
  4. The zowe.yaml file was Not updated.

Expected behavior --update-config parameter always updates zowe.yaml file and generate error messages like 'File already Open' or 'File in use' in case it's not able to update the file.

Logs

-------------------------------------------------------------------------------
>> Update certificate configuration to zowe.yaml

- update "zowe.certificate.keystore.type" with value: PKCS12
- update "zowe.certificate.keystore.file" with value: /var/lpp/zowe/v2/keystore/localhost/localhost.keystore.p12
- update "zowe.certificate.keystore.password" with value: password
- update "zowe.certificate.keystore.alias" with value: localhost
- update "zowe.certificate.truststore.type" with value: PKCS12
- update "zowe.certificate.truststore.file" with value: /var/lpp/zowe/v2/keystore/localhost/localhost.truststore.p12
- update "zowe.certificate.truststore.password" with value: password
- update "zowe.certificate.pem.key" with value: /var/lpp/zowe/v2/keystore/localhost/localhost.key
- update "zowe.certificate.pem.certificate" with value: /var/lpp/zowe/v2/keystore/localhost/localhost.cer
- update "zowe.certificate.pem.certificateAuthorities" with value: /var/lpp/zowe/v2/keystore/local_ca/local_ca.cer

>> Zowe configuration is updated successfully.

-------------------------------------------------------------------------------

Additional context The above Log messages issued says that the zowe.yaml config file has been updated but actually it was not since the file was already in use.

MarkAckert commented 3 months ago

In this scenario, where was the zowe.yaml file opened? Zowe Explorer for VSCode, ISPF, USS + VI/VIM?

Rahul-Kejriwal commented 3 months ago

zowe.yaml was opened in Zowe Explorer for VSCode.

MarkAckert commented 3 months ago

The Zowe Explorer for VSCode does not lock the remote file in USS, so the zwe init ... --update-config flag would have worked as expected on the backend and modified zowe.yaml. To reflect those changes to zowe.yaml your VSCode environment, you need to right click the file in Zowe Explorer for VSCode and select Pull from mainframe to see the latest changes. If you didn't run the Pull from mainframe and saved the zowe.yaml file in your VSCode environment, it would overwrite the remote file which reverts the changes made by --update-config.

I don't believe there's any way to lock a USS file today using Zowe Explorer, or that zwe init would respect the lock.

cc @adam-wolfe for awareness and in case I misstated anything.

Rahul-Kejriwal commented 2 months ago

Hi Mark, I think you were right that we would see the changes when we pull from mainframe after the successful completion of zwe init command.

I think we can close this issue. Thanks.