Skip to content

Add task to report on code synchronization status #196

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

Merged
merged 47 commits into from
Aug 22, 2021
Merged

Conversation

davidsandilands
Copy link
Contributor

@davidsandilands davidsandilands commented Aug 13, 2021

This task runs and produces output based on the debug status on the primary server example output below

  "in_sync" : true,
  "production" : {
    "in_sync" : true,
    "latest_commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea",
    "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
      "sync" : true,
      "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
    },
    "pe-compiler-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
      "sync" : true,
      "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
    },
    "pe-compiler-davidsand-1-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
      "sync" : true,
      "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
    },
    "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net-orchestrator" : {
      "sync" : true,
      "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
    }
  },
  "development" : {
    "in_sync" : true,
    "latest_commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2",
    "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
      "sync" : true,
      "commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
    },
    "pe-compiler-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
      "sync" : true,
      "commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
    },
    "pe-compiler-davidsand-1-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
      "sync" : true,
      "commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
    },
    "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net-orchestrator" : {
      "sync" : true,
      "commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
    }
  }
}```

@davidsandilands davidsandilands requested a review from a team as a code owner August 13, 2021 14:59
Copy link
Contributor

@reidmv reidmv left a comment

Choose a reason for hiding this comment

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

Hey @davidsandilands!

This looks pretty good! While we could take this as-is, it might be worth doing some additional refinement to take this from being a fairly raw Ruby script, to being structured in a way that makes it conducive to testing and breaking down into smaller methods.

I would suggest taking a look at how get_peadm_config.rb is modeled. Namely:

  • Wrap the code in a Ruby class CodeSyncStatus

  • Use a CodeSyncStatus#initialize method to save @params

    def initialize(params)
      @params = params
    end
    
  • Include a method to run the task, CodeSyncStatus#execute!

  • At the bottom of the file, invoke #execute! using a stanza like:

    # Run the task unless an environment flag has been set, signaling not to. The
    # environment flag is used to disable auto-execution and enable Ruby unit
    # testing of this task.
    unless ENV['RSPEC_UNIT_TEST_MODE']
      CodeSyncStatus(JSON.parse(STDIN.read)).execute!
    end
    

That's how we're currently making Ruby tasks testable in peadm.

Note that we should probably switch all of this over to using ruby_task_helper instead sometime soon. We just haven't done that yet. Originally we didn't want to encumber the dependency since we were supporting old versions of PE that didn't work with it, but I don't think we have that constraint anymore.

See here for a simple example of how a Ruby task that uses ruby_task_helper might look.

@davidsandilands
Copy link
Contributor Author

Updated as suggested https://52.156.134.29/ is available for play with the task I checked locally by manipulating and hard setting variables to mismatch and checking failures if an environment is only partially deployed (you can mock this by not waiting for code deploy to finish)

As per discussion with @mcka1n added some extra structure which made some checking easier

{
  "sync" : true,
  "test1" : {
    "sync" : true,
    "servers" : {
      "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-compiler-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-compiler-davidsand-1-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net-orchestrator" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      }
    },
    "latest_commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
  },
  "test2" : {
    "sync" : true,
    "servers" : {
      "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-compiler-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-compiler-davidsand-1-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net-orchestrator" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      }
    },
    "latest_commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
  },
  "production" : {
    "sync" : true,
    "servers" : {
      "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-compiler-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-compiler-davidsand-1-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      },
      "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net-orchestrator" : {
        "sync" : true,
        "commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
      }
    },
    "latest_commit" : "0ea2d64f8ac3db2d1e4bb0c1ce4e8d93735f46ea"
  },
  "development" : {
    "sync" : true,
    "servers" : {
      "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
      },
      "pe-compiler-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
      },
      "pe-compiler-davidsand-1-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net" : {
        "sync" : true,
        "commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
      },
      "pe-server-davidsand-0-d43377.h1bgkrbmw3xu5mervr4yvrwrba.xx.internal.cloudapp.net-orchestrator" : {
        "sync" : true,
        "commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
      }
    },
    "latest_commit" : "93027145096d9f1e0b716b20b8129618d0a2c7e2"
  }
}

Copy link
Contributor

@reidmv reidmv left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

mcka1n
mcka1n previously requested changes Aug 20, 2021
Copy link
Contributor

@mcka1n mcka1n left a comment

Choose a reason for hiding this comment

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

@davidsandilands I left a couple of comments on the Ruby class (just cosmetics)

Overall the logic looks good to me :)

@davidsandilands davidsandilands requested a review from mcka1n August 20, 2021 19:21
@davidsandilands davidsandilands dismissed mcka1n’s stale review August 22, 2021 10:03

I made the change as part of my commit

@davidsandilands davidsandilands merged commit a2f449e into main Aug 22, 2021
@davidsandilands davidsandilands deleted the SOLARCH-558 branch August 22, 2021 10:03
@reidmv reidmv changed the title SOLARCH-558 code sync status task Include code synchronization state in peadm::status Sep 10, 2021
@reidmv reidmv changed the title Include code synchronization state in peadm::status Add task to report on code synchronization status Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants